if (FALSE) {
#############################################################################
# EXAMPLE 1: Imputation of NHANES data using the 'syn.normrank' method
#############################################################################
library(synthpop)
data(nhanes, package="mice")
dat <- nhanes
#* empty imputation
imp0 <- mice::mice(dat, maxit=0)
method <- imp0$method
#* define synthpop method 'normrank' for variable 'chl'
method["chl"] <- "synthpop"
synthpop_fun <- list( chl="normrank" )
synthpop_args <- list( chl=list(smoothing="density") )
#* conduct imputation
imp <- mice::mice(dat, method=method, m=1, maxit=3, synthpop_fun=synthpop_fun,
synthpop_args=synthpop_args)
summary(imp)
}
Run the code above in your browser using DataLab