# Generate data with 20% missing responses
set.seed(123)
data <- data.frame(
Y = c(rnorm(80), rep(NA, 20)),
X1 = rnorm(100),
X2 = runif(100)
)
# Run DMCEM with 50 simulations
result <- DMCEM(data, R = 50, tol = 0.001, nb = 100)
# View imputed values and coefficients
head(result$Yhat)
result$betahat
# Check convergence and variance
result$converged_ratio
result$sigma2
Run the code above in your browser using DataLab