mice.impute.synthpop: Using a 'synthpop' Synthesizing Method in the 'mice' Package

View source: R/mice.impute.synthpop.R

mice.impute.synthpopR Documentation

Using a synthpop Synthesizing Method in the mice Package

Description

The function allows to use a synthpop synthesizing method to be used in the mice::mice function of the mice package.

Usage

mice.impute.synthpop(y, ry, x, synthpop_fun="norm", synthpop_args=list(),
     proper=TRUE, ...)

Arguments

y

Incomplete data vector of length n

ry

Vector of missing data pattern (FALSE – missing, TRUE – observed)

x

Matrix (n x p) of complete covariates.

synthpop_fun

Synthesizing method in the synthpop package

synthpop_args

Function arguments of syn_fun

proper

Logical value specifying whether proper synthesis should be conducted.

...

Further arguments to be passed

Value

A vector of length nmis=sum(!ry) with imputed values.

See Also

See syn.mice for using a mice imputation method in the synthpop package.

See synthpop::syn for generating synthetic datasets with the synthpop package.

Examples

## Not run: 
#############################################################################
# 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)

## End(Not run)

miceadds documentation built on May 29, 2024, 11:05 a.m.