if (FALSE) {
#############################################################################
# EXAMPLE 1: Imputation using sample weights
#############################################################################
data( data.ma01)
set.seed(977)
# select subsample
dat <- as.matrix(data.ma01)
dat <- dat[ 1:1000, ]
# empty imputation
imp0 <- mice::mice( dat, maxit=0)
# redefine imputation methods
meth <- imp0$method
meth[ meth=="pmm" ] <- "weighted.pmm"
meth[ c("paredu", "books", "migrant" ) ] <- "weighted.norm"
# redefine predictor matrix
pm <- imp0$predictorMatrix
pm[, 1:3 ] <- 0
# do imputation
imp <- mice::mice( dat, predictorMatrix=pm, method=meth,
imputationWeights=dat[,"studwgt"], m=3, maxit=5)
}
Run the code above in your browser using DataLab