Converting a mids, mids.1chain or mids.nmi Object in a Dataset List
Converts a mids
, mids.1chain
or mids.nmi
object in a dataset list.
mids2datlist(midsobj, X=NULL)
midsobj |
Object of class |
X |
Optional data frame of variables to be included in imputed datasets. |
List of multiply imputed datasets of classes
datlist
or nested.datlist
.
## Not run: ############################################################################# # EXAMPLE 1: Imputing nhanes data and convert result into a dataset list ############################################################################# data(nhanes,package="mice") #**** imputation using mice imp1 <- mice::mice( nhanes, m=3, maxit=5 ) # convert mids object into list datlist1 <- miceadds::mids2datlist( imp1 ) #**** imputation using mice.1chain imp2 <- miceadds::mice.1chain( nhanes, burnin=4, iter=20, Nimp=5 ) # convert mids.1chain object into list datlist2 <- miceadds::mids2datlist( imp2 ) ############################################################################# # EXAMPLE 2: Nested multiple imputation and datalist conversion ############################################################################# library(BIFIEsurvey) data(data.timss2, package="BIFIEsurvey" ) datlist <- data.timss2 # list of 5 datasets containing 5 plausible values # remove first four variables M <- length(datlist) for (ll in 1:M){ datlist[[ll]] <- datlist[[ll]][, -c(1:4) ] } #*************** # (1) nested multiple imputation using mice imp1 <- miceadds::mice.nmi( datlist, m=4, maxit=3 ) summary(imp1) #*************** # (2) nested multiple imputation using mice.1chain imp2 <- miceadds::mice.nmi( datlist, Nimp=4, burnin=10,iter=22, type="mice.1chain") summary(imp2) #************** # conversion into a datalist datlist.i1 <- miceadds::mids2datlist( imp1 ) datlist.i2 <- miceadds::mids2datlist( imp2 ) ############################################################################# # EXAMPLE 3: mids object conversion and inclusion of further variables ############################################################################# data(data.ma05) dat <- data.ma05 # imputation resp <- dat[, - c(1:2) ] imp <- mice::mice( resp, method="norm", maxit=2, m=3 ) # convert mids object into datalist datlist0 <- miceadds::mids2datlist( imp ) # convert mids object into datalist and include some id variables datlist1 <- miceadds::mids2datlist( imp, X=dat[,c(1,2) ] ) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.