0

I used the mice package in R to perform multiple imputation for my data:

### multiple inputation by chained equations
imp.data <- mice(data, maxit = 5, m = 5, seed = 92385, print = F)

I want to run a logistic regression model after the MI, and predict the outcome based on the model:

model <- with(imp.data, glm(died ~ agecat + female_1 + insurance + mech + transfer +
                          iss + mxaisbr1 + maxais + cm_chf_1 + cm_mets_1 + cm_liver_1 +
                          cm_htn_c_1 + cm_bldloss_1 + state, family = binomial))

However, the predict command does not work:

predict(pool(model), type = c('response'))

It would be much simpler if I have the data with imputed values, but the imputation got 5 imputed data sets, making the post estimation complicated. Any idea ?

Thanks!!

slamballais
  • 3,161
  • 3
  • 18
  • 29
mandy
  • 483
  • 9
  • 20

1 Answers1

0

I'm not sure if the imputed models are saved as a data.frame or a matrix..

But, if you convert the model to a data.frame you can plug on the columns of interest to your original frame.

imp.data <- data.frame(imp.data)
original.df$NewImputtedColumn <- imp.data[, 1] # Assuming you want column 1

Now, you can easily keep the copies of the imputted models and still only work with a single data.frame in your predictive models.

This is what I tend to do anyway, might not be the standard way (I'm not sure).

You are only taking the inputted values from 1 of the imputed models, right?

Sam
  • 644
  • 4
  • 21
  • 1
    The imputed models are saved as list not as data frame. Thanks for the comments, but I think it makes more sense to pool all information of the 5 imputed data together? take the inputted values from just 1 of the models seems to lead to biased conclusions. But not sure what algorithms to use to take all 5 models into consideration... – mandy Nov 16 '17 at 16:02
  • If you want to average over each of the models first then be my guest. The point is, after you've decided on your final model, it's just a case of converting the type of the imputed model to a data frame and transferring columns back into your original. – Sam Nov 16 '17 at 16:05
  • If you run into additional problems feel free to update your question and ping me. I'd be happy to further assist. – Sam Nov 16 '17 at 16:24