Access to dummy variables in internal mice procedure ('pad' element of mids object from mice procedure)

12 Views Asked by At

The mice package in R (https://www.jstatsoft.org/article/view/v045i03) allows specification of passive imputation for interaction terms. Interaction terms involving a categorical variable will always need to work with dummy variables. These could be specified manually and replace factor versions of the variables in your dataset. However, the authors of the package recommend accessing the dummy versions of the categorical variables that are used internally in mice (see section 3.4: passive imputation, top of page 30 in previously linked manuscript).

"Interactions involving categorical variables need a representation using dummy variables. The mice() function internally creates dummy variables for any factor that are being used as a predictor. The data and names of these dummy variables can be accessed from imp$pad$data."

I cannot seem to access the pad element of the mice object. Has this been removed? Has it been transferred into another element of the mice object? I think I can take an educated guess at what the names of the internal dummy variables are, but it would be good to confirm this.

Reproducible example taken directly from linked manuscript. R version 4.3.1:

install.packages("mice")
library(mice)

str(nhanes2)
nhanes2.ext <- cbind(nhanes2, bmi.chl = NA)
ini <- mice(nhanes2.ext, max = 0, print = FALSE)
head(ini$pad$data, 3)
ini$pad
str(ini)
0

There are 0 best solutions below