mice.impute.constant.Rd
Defines a fixed vector of values for imputation of a variable.
The method is particularly useful for the generation of
synthetic datasets, see syn_mice
(Example 1).
mice.impute.constant(y, ry, x, fixed_values, ... )
Incomplete data vector of length n
Vector of missing data pattern (FALSE
-- missing,
TRUE
-- observed)
Matrix (n
x p
) of complete
covariates.
Vector containing fixed values
More arguments to be passed to imputation function
Vector of imputed values
if (FALSE) {
#############################################################################
# EXAMPLE 1: Example with fixed imputed values
#############################################################################
data(nhanes, package="mice")
dat <- nhanes
#* define methods
method <- c(age="", bmi="constant", hyp="norm", chl="pmm")
fixed_values <- list( bmi=rep(27,9) )
#* impute
imp <- mice::mice(dat, method=method, m=1, maxit=3, fixed_values=fixed_values)
table(mice::complete(imp, action=1)$bmi)
}