Generate longitudinal continuous data from a Gaussian antedependence (AD) model of order 0, 1, or 2 using a conditional regression on predecessors.
Usage
simulate_gau(
n_subjects,
n_time,
order = 1L,
mu = NULL,
phi = NULL,
sigma = NULL,
blocks = NULL,
tau = 0,
seed = NULL
)Arguments
- n_subjects
number of subjects
- n_time
number of time points
- order
antedependence order, 0, 1 or 2
- mu
mean parameter;
NULL, scalar, or lengthn_time- phi
dependence parameter; ignored when
order = 0. Fororder = 1,NULL, scalar, or lengthn_time. Fororder = 2,NULLor a 2 byn_timematrix.- sigma
innovation standard deviation;
NULL, scalar, or lengthn_time- 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 toc(0, x, ..., x)with length equal to the number of blocks- seed
optional random seed for reproducibility
Details
For order = 0, each time point is generated independently as
Y[, t] = mu[t] + tau[block] + eps, with eps ~ N(0, sigma[t]^2).
For order = 1, for t >= 2:
Y[, t] = m_t + phi[t] * (Y[, t - 1] - m_{t-1}) + eps_t,
where m_t = mu[t] + tau[block] and eps_t ~ N(0, sigma[t]^2).
For order = 2, for t >= 3:
Y[, t] = m_t + phi[1, t] * (Y[, t - 1] - m_{t-1}) + phi[2, t] * (Y[, t - 2] - m_{t-2}) + eps_t.
If blocks is provided, each subject s belongs to a block and receives a
mean shift tau[blocks[s]]. tau[1] is forced to 0.
Examples
y <- simulate_gau(
n_subjects = 20,
n_time = 6,
order = 1,
phi = 0.4,
seed = 42
)
dim(y)
#> [1] 20 6