View source: R/simulate_inad.R
| simulate_inad | R Documentation |
Generate longitudinal count data from an INAD model using a thinning operator and an innovation distribution.
simulate_inad(
n_subjects,
n_time,
order = 1L,
thinning = c("binom", "pois", "nbinom"),
innovation = c("pois", "bell", "nbinom"),
alpha = NULL,
theta = NULL,
nb_inno_size = NULL,
blocks = NULL,
tau = 0,
seed = NULL
)
n_subjects |
number of subjects |
n_time |
number of time points |
order |
antedependence order, 0, 1 or 2 |
thinning |
thinning operator, one of |
innovation |
innovation distribution, one of |
alpha |
thinning parameter or vector or matrix; if |
theta |
innovation parameter or vector; if |
nb_inno_size |
size (dispersion) parameter for negative binomial innovations
when |
blocks |
integer vector of length |
tau |
group effect vector indexed by block; |
seed |
optional random seed for reproducibility |
Time 1 observations are generated from the innovation distribution alone.
For times 2 to n_time, counts are generated as thinning of previous
counts plus independent innovations. When order = 0, all time points
are generated from the innovation distribution and the thinning operator
and alpha are ignored.
If blocks is provided, innovations include a block effect. For Poisson and
negative binomial innovations, the innovation mean is theta[t] + tau[blocks[i]].
For Bell innovations, the innovation mean is theta[t] * exp(theta[t]) + tau[blocks[i]].
integer matrix of counts with dimension n_subjects by n_time
y <- simulate_inad(
n_subjects = 20,
n_time = 6,
order = 1,
thinning = "binom",
innovation = "pois",
alpha = 0.3,
theta = 2,
seed = 42
)
dim(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.