| generate_spm | R Documentation |
Generate longitudinal data from a shared-parameter model (SPM) with MNAR monotone dropout (continuous or binary outcomes)
generate_spm(
n,
t_vec,
family = c("gaussian", "bernoulli"),
alpha0,
alpha1,
rho,
sigma_b,
theta,
beta0 = NA_real_,
sigma_e = NA_real_
)
n |
Integer. Sample size (number of subjects). |
t_vec |
Numeric vector of visit times. |
family |
Character. Either |
alpha0, alpha1 |
Numerics. Intercept and time slope in the dropout model (logit link). |
rho |
Numeric. Coupling between the shared random effect |
sigma_b |
Numeric (>0). Standard deviation of the subject-specific
random intercept |
theta |
Numeric. Target effect:
|
beta0 |
Numeric. For |
sigma_e |
Numeric (>0). For |
Outcome model (shared-parameter).
Gaussian: Y_{ik}\mid b_i \sim \mathcal{N}(\beta_1 t_k + b_i, \sigma_e^2),
with \beta_1 = \theta/t_K.
Bernoulli (probit): Y_{ik}\mid b_i \sim \mathrm{Bernoulli}(\Phi(\beta_0 + \beta_1 t_k + b_i)),
with \beta_1 = \{\sqrt{1+\sigma_b^2}\,\Phi^{-1}(\theta) - \beta_0\}/t_K.
Dropout model (MNAR, monotone).
\mathrm{logit}\,\Pr(R_{ik}=0 \mid R_{i,k-1}=1, b_i) = \alpha_0 + \alpha_1 t_k + \rho b_i,
and once dropout occurs (R_{ik}=0), all subsequent R_{i,k'}=0 for k'>k.
A list with:
Ymat |
|
Rmat |
|
dat |
Long-format |
set.seed(1000)
t_vec <- seq(4, 48, 4)
# Continuous outcome
out_c <- generate_spm(
n = 50, t_vec = t_vec, family = "gaussian",
alpha0 = -4, alpha1 = 0.05, rho = -1, sigma_b = 1,
theta = -3.2, sigma_e = 1
)
# Binary outcome
out_b <- generate_spm(
n = 200, t_vec = t_vec, family = "bernoulli",
alpha0 = -4, alpha1 = 0.05, rho = -1, sigma_b = 1,
theta = 0.4, beta0 = -2
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.