This function simulates data from a cosinor model with a single covariate, where the time scale is month, and optionally allows for single covariate effects on the mean, amplitude, and acrophase.
simulate_cosinor(
n,
mesor,
amp,
acro,
period = 24,
n_components,
beta.group = FALSE,
beta.mesor,
beta.amp,
beta.acro,
n_period = 1,
family = c("gaussian", "poisson", "binomial", "gamma"),
...
)Returns simulated data in a data.frame.
The sample size. An integer greater than 0.
A numeric. The MESOR (midline estimating statistic of
rhythm) for group = 0. The MESOR is independent of the cosinor
components, so only one value is allowed even if there are multiple
components in the data being simulated.
A numeric. The amplitude value (for group = 0 if
grouped data are being simulated (beta.group = TRUE)). If simulating
data with multiple components, specify a vector with values for each
component. E.g: amp = c(5, 10).
A numeric. The acrophase value in radians
(for group = 0 if grouped data are being simulated
(beta.group = TRUE)). If simulating data with multiple components,
specify a vector with values for each component. E.g: acr = c(0, pi)
for two components.
The period of the rhythm data (for group = 0 if
grouped data are being simulated (beta.group = TRUE)).
If simulating data with multiple components, specify a vector with values
for each component. E.g: period = c(12, 6) for two components.
The number of components in the model.
This must match the length of the inputs for amp and acro.
A logical. If TRUE a second group of data
will be simulated and included in the returned data set. If FALSE,
beta.acro, beta.mesor, and beta.amp arguments will be
ignored.
A numeric. The MESOR value term for group = 1
A numeric. The amplitude value for group = 1.
If simulating data with multiple components, specify a vector with values for
each component. E.g: amp = c(2, 8).
A numeric. The acrophase value in radians
(for group = 1. If simulating data with multiple components,
specify a vector with values for each component. E.g: acr = c(2, 5)
for two components.
A numeric. The number of cycles of the rhythm to be
simulated.
A character. The family (see ?family) of the
simulated dataset. Can handle values in c("poisson", "binomial",
"gamma", "gaussian").
Extra arguments, including alpha that controls the
shape argument when sampling from a gamma distribution
(when family = "gamma"; default is 1), and sd
(standard deviation) which is used when sampling from a normal distribution
(when family = "gaussian"; default is 1). To specify these parameters
for the beta (treatment) group, use beta.alpha and beta.sd
simulate_cosinor(
n = 100,
mesor = 1,
amp = 1,
acro = 1,
period = 24,
family = "gaussian"
)
Run the code above in your browser using DataLab