Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

syn_mice

Constructs Synthetic Dataset with mice Imputation Methods


Description

Constructs synthetic dataset with mice imputation methods. The functionality is very similar to the functionality of synthpop::syn in the synthpop package (Nowok, Raab, & Dibben, 2016). Methods defined in synthpop are accessible via mice.impute.synthpop (see Examples).

Usage

syn_mice(data, m=5, k=NULL, syn_check=TRUE, ...)

Arguments

data

Original data frame

m

Number of synthetic datasets

k

Number of observations in synthetic data

syn_check

Logical indicating whether checks in synthpop::syn should be performed.

...

Further arguments to be passed, with conventions in mice::mice

Value

Object of class synds, see synthpop::syn.

References

Nowok, B., Raab, G., & Dibben, C. (2016). synthpop: Bespoke creation of synthetic data in R. Journal of Statistical Software, 74(11), 1-26. doi: 10.18637/jss.v074.i11

See Also

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Synthesization of SD2011 using mice functionality
#############################################################################

library(synthpop)

#** selection of dataset
data(SD2011, package="synthpop")
vars <- c("sex","age","ls","smoke")
dat  <- SD2011[1:1000, vars]
dat$ls <- as.numeric(dat$ls)

#** default synthesis
imp0 <- synthpop::syn(dat)
pred0 <- imp0$predictor.matrix
method0 <- imp0$method

#* define imputation methods
method <- c(sex="synthpop", age="synthpop", ls="synthpop", smoke="logreg")
# only for smoke, an original mice imputation method is used

#- define synthpop functions
synthpop_fun <- list(sex="constant", age="constant", ls="cart")

#- arguments for 'syn.cart' method
synthpop_args <- list(ls=list(smoothing="density"))

#- fixed values for 'syn.constant' method
fixed_values <- dat[,1:2]

#- do synthesization
imp <- miceadds::syn_mice(dat, m=1, synthpop_fun=synthpop_fun, method=method,
            pedictorMatrix=pred0, rf.fixed_values=fixed_values, synthpop_args=synthpop_args)
summary(imp)

## End(Not run)

miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'

v3.11-6
GPL (>= 2)
Authors
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>), Simon Grund [aut] (<https://orcid.org/0000-0002-1290-8986>), Thorsten Henke [ctb]
Initial release
2021-01-21 11:48:47

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.