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"),...)
Arguments
n: The sample size. An integer greater than 0.
mesor: 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.
amp: 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).
acro: 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.
period: 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.
n_components: The number of components in the model. This must match the length of the inputs for amp and acro.
beta.group: 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.
beta.mesor: A numeric. The MESOR value term for group = 1
beta.amp: 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).
beta.acro: 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.
n_period: A numeric. The number of cycles of the rhythm to be simulated.
family: 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
Returns
Returns simulated data in a data.frame.
Examples
simulate_cosinor( n =100, mesor =1, amp =1, acro =1, period =24, family ="gaussian")