## Example of predicting longitudinal outcomes
## To make it faster to compile and check, we only run 30 iterations for
## burn-in and 40 for posterior sampling phases.
## Please increase to 3000 and 4000 iterations, respectively, when running the models.
# \donttest{
data <- simulation_prediction(n_subject = 100, seed = 1234, nonlinear = TRUE,
nonrandeff = TRUE, nonresidual = TRUE)
X_train <- data$X_train
Y_train <- data$Y_train
Z_train <- data$Z_train
subject_id_train <- data$subject_id_train
X_test <- data$X_test
Z_test <- data$Z_test
subject_id_test <- data$subject_id_test
model <- BMTrees_prediction(X_train, Y_train, Z_train, subject_id_train,
X_test, Z_test, subject_id_test, model = "BMTrees", seed = 1234)
model$post_predictive_y_test
data2 = simulation_imputation(n_subject = 100, seed = 1234, nonrandeff = TRUE,
nonresidual = TRUE, alligned = FALSE)
X_mis = data2$X_mis # get missing covariates
Y_mis = data2$Y_mis # get missing outcomes
Z = data2$Z # get random predictors
subject_id = data2$subject_id # get subject id
model2 = sequential_imputation(X_mis, Y_mis, Z, subject_id, rep(0, 9), FALSE,
model = "BMTrees", nburn = 30L, npost = 40L, skip = 2L,
verbose = TRUE, seed = 1234)
model2$imputed_data
model2$imputed_data[,,10]
# }
Run the code above in your browser using DataLab