This helper function creates a valid where matrix. The
where matrix is an argument to the mice function.
It has the same size as data and specifies which values
are to be imputed (TRUE) or nor (FALSE).
Usage
make.where(data, keyword = c("missing", "all", "none", "observed"))Examples
head(make.where(nhanes), 3)
#> age bmi hyp chl
#> 1 FALSE TRUE TRUE TRUE
#> 2 FALSE FALSE FALSE FALSE
#> 3 FALSE TRUE FALSE FALSE
# create & analyse synthetic data
where <- make.where(nhanes2, "all")
imp <- mice(nhanes2,
m = 10, where = where,
print = FALSE, seed = 123
)
fit <- with(imp, lm(chl ~ bmi + age + hyp))
summary(pool.syn(fit))
#> term estimate std.error statistic df p.value
#> 1 (Intercept) 142.067628 64.469297 2.2036479 1225.7065 0.02773453
#> 2 bmi 1.507060 2.344434 0.6428249 1047.5045 0.52047843
#> 3 age40-59 14.556536 19.438169 0.7488636 5486.1899 0.45397155
#> 4 age60-99 27.214603 23.548275 1.1556941 1570.7352 0.24798205
#> 5 hypyes 6.328866 21.026830 0.3009900 170.0233 0.76378986
