alexanderrobitzsch / miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'.
https://alexanderrobitzsch.github.io/miceadds/
16 stars 2 forks source link

Question on using mice.impute.imputeR.lmFun #28

Closed EdoardoCostantini closed 1 year ago

EdoardoCostantini commented 1 year ago

Hello,

I would like to try out forward step-wise regression as a model-building strategy for the imputation models. From the mice.impute.imputeR.lmFun documentation, I understand that I can use the imputeR::stepForR() method as a univariate imputation in the mice algorithm.

If I follow the example reported in the documentation on the mice.impute.imputeR.lmFun, I would set up the code like this:

# Load packages
library(mice)
library(miceadds)
library(ridge)
library(imputeR)

# Load data
data(nhanes, package = "mice")
dat <- nhanes

# Make hyp a factor
dat$hyp <- as.factor(dat$hyp)

# Define general imputation method 
method <- c(
    age = "",
    bmi = "norm",
    hyp = "imputeR.cFun",
    chl = "imputeR.lmFun" # use one of the imputeR methods for cont. vars
)

# Define specifics of imputeR methods
Fun <- list(
    hyp = imputeR::ridgeC,
    chl = imputeR::stepForR # use forward step-wise method from imputeR
)

# Usual run of mice with and extra "Fun" argument
imp <- mice::mice(dat, method = method, maxit = 10, m = 4, Fun = Fun)

My understanding is that:

Do I understand this correctly?

alexanderrobitzsch commented 1 year ago

"The mice algorithm will estimate the forward stepwise regression to predict "chl" on a bootstrap version of the observed values on "chl" at every iteration."

yes.

"The predictors that the forward stepwise algorithm will scan are the ones defined by the predictor matrix provided in the mice call (the default one in this case)."

yes.

"At every iteration, the step-wise algorithm might select different predictors for the imputation model of "chl"."

yes.

EdoardoCostantini commented 1 year ago

Great. Thank you for responding so quickly.