# \donttest{
# obs
n <- 5000
# n missing
n_missing <- 1000
# variables
p <- 16
# data
Y <- MASS::mvrnorm(n, rep(0, p), ptsd_cor1)
# for checking
Ymain <- Y
# all possible indices
indices <- which(matrix(0, n, p) == 0,
arr.ind = TRUE)
# random sample of 1000 missing values
na_indices <- indices[sample(5:nrow(indices),
size = n_missing,
replace = FALSE),]
# fill with NA
Y[na_indices] <- NA
# missing = 1
Y_miss <- ifelse(is.na(Y), 1, 0)
# true values (to check)
true <- unlist(sapply(1:p, function(x)
Ymain[which(Y_miss[,x] == 1),x] ))
# impute
fit_missing <- impute_data(Y, progress = FALSE, iter = 250)
# impute
fit_missing <- impute_data(Y,
progress = TRUE,
iter = 250)
# }
Run the code above in your browser using DataLab