##############
# nhanes (one level data)
##############
data(nhanes, package = "mice")
#imp <- mice.par(nhanes)
#fit <- with(data = imp, exp = lm(bmi ~ hyp + chl))
#summary(pool(fit))
##############
#CHEM97Na (Two levels data with 1681 observations and 5 variables)
##############
data(CHEM97Na)
ind.clust<-1#index for the cluster variable
#initialisation of the argument predictorMatrix
predictor.matrix<-mice(CHEM97Na,m=1,maxit=0)$pred
predictor.matrix[ind.clust,ind.clust]<-0
predictor.matrix[-ind.clust,ind.clust]<- -2
predictor.matrix[predictor.matrix==1]<-2
#initialisation of the argument method
method<-find.defaultMethod(CHEM97Na,ind.clust)
#multiple imputation by chained equations (parallel calculation) [1 minute]
#(the imputation process can be followed by opening output.txt files in the working directory)
#res.mice<-mice.par(CHEM97Na,
# predictorMatrix = predictor.matrix,
# method=method,
# path.outfile=getwd())
#multiple imputation by chained equations (without parallel calculation) [4.8 minutes]
#res.mice<-mice(CHEM97Na,
# predictorMatrix = predictor.matrix,
# method=method)
############
#IPDNa (Two levels data with 11685 observations and 10 variables)
############
data(IPDNa)
ind.clust<-1#index for the cluster variable
#initialisation of the argument predictorMatrix
predictor.matrix<-mice(IPDNa,m=1,maxit=0)$pred
predictor.matrix[ind.clust,ind.clust]<-0
predictor.matrix[-ind.clust,ind.clust]<- -2
predictor.matrix[predictor.matrix==1]<-2
#initialisation of the argument method
method<-find.defaultMethod(IPDNa,ind.clust)
#multiple imputation by chained equations (parallel calculation)
#res.mice<-mice.par(IPDNa,
# predictorMatrix = predictor.matrix,
# method=method,
# path.outfile=getwd())
Run the code above in your browser using DataLab