3
$\begingroup$

I would like to apply the margins function to imputed data (I used mice), but it seems not possible. Do you know if a function exists that calculates marginal effects with imputed data?

Thank you!

Edit: I have modified my code as follows: is it correct? Thank you!

ddply(data_pooled, "imp", function(x){ 
  logregress <-  glm(y ~ var1 + var2 + var3, family = binomial(link="logit"), data=data_pooled)
  
  margin_mod <- margins(logregress, type="response")
  })

margin_summary <- summary(MIcombine(margin_mod))
$\endgroup$
3
  • $\begingroup$ Can you give some more information about what exactly you are doing ? Why can't you just apply the function to each imputation and pool the results ? $\endgroup$ – Robert Long Oct 6 '20 at 14:15
  • $\begingroup$ Thank you @RobertLong for the input, I didn't know that was possible. Let me see if I've understood you: should I use the imputed dataset in the long format (with raw and imputed data) to run the regression and then margins? $\endgroup$ – Ele_456 Oct 6 '20 at 14:35
  • $\begingroup$ No, you apply your function to each imputed dataset and then average the results. I have posted an answer with details. $\endgroup$ – Robert Long Oct 6 '20 at 15:24
6
$\begingroup$

The general approach to analysis of missing data using multiple imputation is

  • create several complete datasets, let's say $m$, using whatever multiple imputation alogorithm you choose

  • perform the final analysis model (eg a regression model) on each complete dataset. That is, you would run $m$ models.

  • pool the results of the analyses. With a linear regression model you would simply average all the estimates of interest to find the pooled estimate. For standard errors, the typical approach is to use Rubin's rules, which incorporate uncertainty both within, and between, imputations. If the sampling distribution of the estimate of interest does not follow a normal distribution, then other methods can be employed. See this question and answer for further details: Applying Rubin's rule for combining multiply imputed datasets

$\endgroup$
3
  • $\begingroup$ I have modified my question with the code I wrote following your suggestion, can you please check it as I am not sure it is correct? Thank you so much! $\endgroup$ – Ele_456 Oct 7 '20 at 9:16
  • 1
    $\begingroup$ I think so, but I'm not completely sure. Please note that questions about software or coding are off topic here - you could ask a follow-on question on stackoverflow. $\endgroup$ – Robert Long Oct 7 '20 at 9:53
  • $\begingroup$ @Ele_456 does this answer your question ? If so, please consider marking it as the accepted answer, and if not, please let us know why. $\endgroup$ – Robert Long Oct 15 '20 at 19:05

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.