Generates a dataset with longitudinal data containing missing covariates and outcomes. The function allows customization of random effects, residuals, and the alignment of covariates to simulate data under different conditions.
simulation_imputation(
n_subject = 800,
seed = NULL,
nonrandeff = FALSE,
nonresidual = FALSE,
alligned = FALSE
)A list containing:
X_misMatrix of missing covariates.
Y_misVector of missing outcomes.
ZMatrix of complete random predictors.
subject_idVector of subject IDs.
timeTime points for each observation.
X_OMatrix of original complete covariates (for evaluation).
Y_OVector of original complete outcomes (for evaluation).
Number of subjects in the dataset. Each subject has multiple observations. Default: 800.
Random seed for reproducibility. Default: 123.
Logical value indicating whether the random effects are non-normal. Default: FALSE.
Logical value indicating whether the residuals are non-normal. Default: FALSE.
Logical value indicating whether the covariates should be aligned (TRUE)
or shuffled (FALSE). Default: FALSE. If it is shuffled, we will return covariate order as X1, X2, X3, X4, X5, X6, X9, X8, X7. If it is alligned, we will return covariate order as X1, X2, X3, X4, X5, X6, X7, X8, X9.
This function creates longitudinal data for multiple subjects, each observed across 6 time points. Non-normal or normal random effects and residual conditions can be specified. Missing values are introduced based MAR assumption. The alignment of covariates can be customized to test different imputation scenarios.
simulated_data <- simulation_imputation(
n_subject = 800,
seed = 123,
nonrandeff = TRUE,
nonresidual = TRUE,
alligned = FALSE
)
Run the code above in your browser using DataLab