Generate longitudinal count data from an INAD model using a thinning operator and an innovation distribution.
Arguments
- n_subjects
number of subjects
- n_time
number of time points
- order
antedependence order, 0, 1 or 2
- thinning
thinning operator, one of
"binom","pois","nbinom"- innovation
innovation distribution, one of
"pois","bell","nbinom"- alpha
thinning parameter or vector or matrix; if
NULL, defaults are used depending on the order- theta
innovation parameter or vector; if
NULL, defaults are used depending on the innovation type. For Poisson and negative binomial innovations,thetais the innovation mean parameter. For Bell innovations,thetais the Bell rate parameter, with innovation meantheta * exp(theta).- nb_inno_size
size (dispersion) parameter for negative binomial innovations when
innovation = "nbinom"; must be positive. IfNULL, defaults to 1. Larger values correspond to less overdispersion (approaching Poisson as size -> Inf).- blocks
integer vector of length
n_subjectsindicating block membership for each subject; ifNULL, no block effect is applied- tau
group effect vector indexed by block;
tau[1]is forced to 0. If scalar x, it is expanded to c(0, x, ..., x) with length equal to the number of blocks- seed
optional random seed for reproducibility
Details
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]].
Examples
y <- simulate_inad(
n_subjects = 20,
n_time = 6,
order = 1,
thinning = "binom",
innovation = "pois",
alpha = 0.3,
theta = 2,
seed = 42
)
dim(y)
#> [1] 20 6