I want to produce imputations for the missing values using a naive imputation method "Regression imputation " . The first step involves building a model from the observed data then predictions for the incomplete cases are calculated under the fitted model, and serve as replacements for the missing data .

Suppose that we model Ozone by the linear regression function of Solar.R

> library(mice)
> fit <- lm(Ozone ~ Solar.R, data = airquality)
> pred <- predict(fit, newdata = ic(airquality))
# Or alternatively using mice package 
> imp <- mice(airquality[,1:2], method="norm.predict", m=1, maxit=3,seed=1)
> head(airquality[5,1:2])
> head(complete(imp)[5,])

I did not get how the fifth observation is imputed under the fitted model ? , since both Ozone and Solar.R are missing !.


Your linear regression can't predict on the missing data if it doesn't have a predictor. So your value is not imputed.

Although it does involve regressions, Multivariate Imputation by Chained Equations (MICE) is a bit different from your linear regression approach. In a nutshell, missing variables are first tentatively filled, which makes them suitable as predictors, and then they are iteratively imputed. I would suggest looking at the pseudocode in Azur, M. J.; Stuart, E. A.; Frangakis, C. & Leaf, P. J. (2011) Multiple Imputation by Chained Equations: What is it and how does it work?. International journal of methods in psychiatric research, 20, 40-49 to understand what the algorithm does.

| cite | improve this answer | |
  • $\begingroup$ Yes, that"s true , but I didn't get how R imputed the observations in which both Ozon and Solar.R are missing !, since the model includes just one predictor Solar.R. Did u check the code (the 5th obs.) ? or this one sum(as.numeric(!is.na(complete(imp)))) ; dim(airquality[,c(1,2)]) $\endgroup$ – Bahgat Nassour Nov 14 '16 at 17:14
  • $\begingroup$ This is being automatically flagged as low quality, probably because it is so short. At present it is more of a comment than an answer by our standards. Can you expand on it? You can also turn it into a comment. $\endgroup$ – gung - Reinstate Monica Nov 14 '16 at 17:34
  • $\begingroup$ I have expanded the answer $\endgroup$ – Florian Hartig Nov 14 '16 at 17:59
  • $\begingroup$ It is not clear though with only two variables both missing how mice can get started here. $\endgroup$ – mdewey Nov 14 '16 at 18:32
  • 1
    $\begingroup$ Did you read the reference I cited? It explains the algorithm step for step. It works, as I said above, because the NAs are first filled with column means and then iteratively corrected. $\endgroup$ – Florian Hartig Nov 15 '16 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.