#form data with NAs in the outcomes
dataEG2.NA <- dataEG2
dataEG2.NA[sample(1:nrow( dataEG2.NA), 1000),"state"] <- NA #specify lots of NAs
#fit a model using dataEG2.NA
fm.est2.NA <- RMC.mod( states=dataEG2.NA[,2], chain.id=dataEG2.NA[,1], X=dataEG2.NA[,-(1:2)])
#impute the missing values. The result will be a matrix
imputedData <- MVfill( fm.est2.NA, states=dataEG2.NA[,2], chain.id=dataEG2.NA[,1], X=dataEG2.NA[,3:4])
print( head( imputedData, 20))
Run the code above in your browser using DataLab