I am using the MICE package in R to impute my dataset to deal with missing values. I have missing values in both the response and the predictor variables. I am interested in following Paul T. Von Hippel's (2007) suggestion to impute the data including the response variables but not using the imputed response variables in the glm. I have figured out how to do that in MICE but I would like to also use the data in package mami to run model selection. I can't run the data in mami as it seems to refuse to run if there are any missing data which there are since we are missing data in the response variables. I get the error:

 Error in mami(imp, model = "gaussian", outcome = 
  c("j_immerged2"), method = "MA.criterion",  : 
  There is still missing data but you specified the data is 

Is there any way around this problem? Is there a different package I can use to run model selection on imputed data with missing data?

P.S. I did run a large number of imputations and impute both the response and predictor variables and for analysis at first. However, reviewers were not particularly fond of the choice to impute the response variables, hence why I am trying to analyze the data as stated above.

citation from above: Von Hippel, P. T. 2007. Regression with missing Ys: an improved strategy for analyzing multiply imputed data. Sociological Methodology, 37: 83-117.

  • 2
    $\begingroup$ Have you tried removing the rows that have a missing response variable? That would be an easy work-around. $\endgroup$ Nov 6, 2020 at 19:52
  • $\begingroup$ Thanks. Yes I agree that would be easiest but I'm not sure how to do that in mice after imputation since I need the data to help inform the imputation itself. $\endgroup$ Nov 7, 2020 at 2:59
  • 3
    $\begingroup$ How about removing the rows from the output of MICE before sending it to mami? $\endgroup$ Nov 7, 2020 at 14:09

1 Answer 1


Ok, I think (hope) this is correct.

First I created a copy of the response column and told MICE not to use it in the imputation (so essentially there is one column with the response that is imputed and used in the imputation process and one exact copy not used).

Second, I ran the imputation and then created a long format version of all your datasets:


Third, I removed all rows with an NA in the non-imputed response variable column:

imp4<-imp3 %/% drop_na("response")

Fourth, I converted it back to mids object:

impA <- as.mids(imp4)

I was then able to run my glm with the imputed dataset and run model selection in MAMI because there were no longer any missing values.

  • $\begingroup$ That seems correct. I would have achieved the same by having an indicator variable resmiss <- is.na(amandasresponse) and then conditioned on that so i never got confused by having two variables with the same content but it comes to the same thing. $\endgroup$
    – mdewey
    Nov 8, 2020 at 16:42
  • $\begingroup$ Well, I thought that worked but it turns out I was wrong. I am still getting this error in MAMI: Error in names(X[[m]])[-c(outcome, var.remove)] : only 0's may be mixed with negative subscripts $\endgroup$ Nov 8, 2020 at 18:03
  • $\begingroup$ You now need to move to a programming site, possibly R-help, and give a minimal reproducible example. The problem is that you can have positive subscripts in R or negative ones but not mixed and somehow that is what you have got. $\endgroup$
    – mdewey
    Nov 9, 2020 at 10:22
  • $\begingroup$ Ok thanks. I have sent an email to the author of MAMI to see if they can help me out. I appreciate your feedback. $\endgroup$ Nov 9, 2020 at 17:16
  • $\begingroup$ @AmandaGoldberg This was so unbelievably helpful; thank you. +1 $\endgroup$ May 31, 2023 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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