amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
442 stars 107 forks source link

Error obtaining OR and CI for glm for pooled model #164

Closed ealeph closed 5 years ago

ealeph commented 5 years ago

Hello,

I used MICE for multiple imputations for missing values in a data set. I'm running a logistic regression model on the data set and need to obtain odds ratios (OR) and 95% confidence intervals (CI) for the model covariates.

My code looks like this: model1 <- with(imp_data, glm(var0~var1+var2+var3, family=binomial(link="logit"))) pooled_model1 <- pool(model1) summary(pooled_model1, conf.int = TRUE, conf.level = 0.95, exponentiate = TRUE)

when I run the model, I get the following error: In process_mipo(z, object, conf.int = conf.int, conf.level = conf.level, ... : Exponentiating coefficients, but model did not use a log or logit link function

I saw that it was asked before but could not find an explanation for the error or how to solve it.

Thanks!

stefvanbuuren commented 5 years ago

Thanks for alerting. This appears to be a bug in formerly working code.

I just learned that R 3.5.2 made some fixes to the summary() and confint() methods, and this may have broken the summary.mipo method in mice. Will track it down.

stefvanbuuren commented 5 years ago

It is actually not an error, but a warning. Run this in R.3.5.2:

imp <- mice(nhanes2, seed = 12323, print = FALSE)
fit <- with(imp, glm(hyp ~ chl, family = binomial(link = "logit")))
est <- pool(fit)
summary(est, conf.int = TRUE)
            estimate std.error statistic   df p.value    2.5 % 97.5 %
(Intercept)  -5.7361    3.8425     -1.49 14.2   0.157 -13.9640 2.4918
chl           0.0235    0.0185      1.27 14.4   0.225  -0.0161 0.0631
summary(est, conf.int = TRUE, exponentiate = TRUE)
            estimate std.error statistic   df p.value    2.5 % 97.5 %
(Intercept)  0.00323    3.8425     -1.49 14.2   0.157 8.62e-07  12.08
chl          1.02379    0.0185      1.27 14.4   0.225 9.84e-01   1.07
Warning message:
In process_mipo(z, object, conf.int = conf.int, conf.level = conf.level,  :
  Exponentiating coefficients, but model did not use a log or logit link function

The values for the estimate and for the confidence intervals are correctly exponentiated. The procedure gives a warning, but I think you can ignore it.

stefvanbuuren commented 5 years ago

Closing because there does not seem anything wrong.