if (FALSE) {
#############################################################################
# EXAMPLE 1: Nested multiple imputation and conversion into an object of class
# NestedImputationList
#############################################################################
library(BIFIEsurvey)
data(data.timss2, package="BIFIEsurvey" )
datlist <- data.timss2
# remove first four variables
M <- length(datlist)
for (ll in 1:M){
datlist[[ll]] <- datlist[[ll]][, -c(1:4) ]
}
# nested multiple imputation using mice
imp1 <- miceadds::mice.nmi( datlist, m=3, maxit=2 )
summary(imp1)
# create object of class NestedImputationList
datlist1 <- miceadds::mids2datlist( imp1 )
datlist1 <- miceadds::NestedImputationList( datlist1 )
# estimate linear model using with
res1 <- with( datlist1, stats::lm( ASMMAT ~ female + migrant ) )
# pool results
mres1 <- mitools::MIcombine( res1 )
summary(mres1)
coef(mres1)
vcov(mres1)
}
Run the code above in your browser using DataLab