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

syn.constant

Synthesizing Method for Fixed Values by Design in synthpop


Description

Defines a synthesizing method for fixed values of a variable by design in the synthpop package.

Usage

syn.constant(y, x, xp, fixed_values, ...)

Arguments

y

Original data vector of length n

x

Matrix (n \times p) of original covariates

xp

Matrix (k \times p) of synthesised covariates

fixed_values

Vector containing fixed values

...

Further arguments to be passed

Details

When using the synthesis method "mice" in synthpop::syn, the function argument has to appear as rf.fixed_values (convention in synthpop).

Value

A vector of length k with synthetic values of y.

See Also

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: SD2011 | Fixed values for variable sex
#############################################################################

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)
pred <- imp0$predictor.matrix
method <- imp0$method

#** constant vector
method["sex"] <- "constant"
fixed_values <- data.frame( sex=rep(dat$sex[c(1,2)], each=1000) )
imp <- synthpop::syn( dat, method=method, k=2000, m=1,
                rf.fixed_values=fixed_values)
table(imp$syn$sex)

## 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.