#############################################################################
# EXAMPLE 1: Tricube predictive mean matching for nhanes data
#############################################################################
library(mice)
data(nhanes, package="mice")
set.seed(9090)
#*** Model 1: Use default of tricube predictive mean matching
varnames <- colnames(nhanes)
VV <- length(varnames)
imputationMethod <- rep("tricube.pmm2" , VV )
names(imputationMethod) <- varnames
# imputation with mice
imp.mi1 <- mice( nhanes , m=5 , maxit=4 , imputationMethod= imputationMethod )
#*** Model 2: use item-specific imputation methods
iM2 <- imputationMethod
iM2["bmi"] <- "pmm6"
# use tricube.pmm2 for hyp and chl
# select different scale parameters for these variables
tricube.pmm.scale1 <- list( "hyp" = .15 , "chl" = .30 )
imp.mi2 <- mice.1chain( nhanes , burnin=5 , iter=20 , Nimp=4 ,
imputationMethod= iM2 , tricube.pmm.scale=tricube.pmm.scale1 )
Run the code above in your browser using DataLab