Giter VIP home page Giter VIP logo

Comments (8)

stefvanbuuren avatar stefvanbuuren commented on June 13, 2024

The summary.mira() function has changed in mice 3.0. The names of the columns now conform to the broom package. You can request the estimates directly in the linear or log odds scale, as follows

require(mice, warn.conflicts = FALSE)
packageVersion("mice")
set.seed(123)
nhanes$hyp <- as.factor(nhanes$hyp)

# Can run logistic regression on (non-imputed) dataset
model <- glm(hyp ~ bmi, family = binomial(link = 'logit'), nhanes)
model_or <- exp(cbind(OR = coef(model), confint(model)))

# Using the nhanes dataset as an example
imputed_data <- mice::mice(nhanes, m = 25, method = "pmm", 
                           maxit = 10, seed = 12345, print = FALSE)
imputed_model <- with(imputed_data, 
                      glm(hyp ~ bmi, family = binomial(link = 'logit')))

# linear scale
round(summary(pool(imputed_model), conf.int = TRUE), 3)

# log odds scale
round(summary(pool(imputed_model), conf.int = TRUE, exponentiate = TRUE), 3)

from mice.

mccallad avatar mccallad commented on June 13, 2024

That's hugely helpful - thank you for the very quick reply!

from mice.

jaminday avatar jaminday commented on June 13, 2024

Using mice v3.3.0, when running the above example code I get the following warning when pooling on the log odds scale using round(summary(pool(imputed_model), conf.int = TRUE, exponentiate = TRUE), 3):

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

This is despite computing the imputed_model object with family = binomial(link = 'logit')) as in the example code.

Is it safe to ignore this message, as we know the model was computed using a logit link function?

from mice.

 avatar commented on June 13, 2024

I am experiencing a very similar issue as @jaminday - any update on this?

I am calling the function as follows:

imp_long %>%
 by(as.factor(.$.imp), glm, formula=k2, family=binomial(link="logit")) %>%
  pool() %>% 
   summary(conf.int=T, exponentiate=T) 

Warning message is the same as above.

from mice.

stefvanbuuren avatar stefvanbuuren commented on June 13, 2024

The warning comes from an inappropriate test of the mipo object, which does not preserve the model settings. The warning can be ignored. It is actually superfluous, and therefore removed in mice 3.4.2.

from mice.

missingKobe avatar missingKobe commented on June 13, 2024

The summary.mira() function has changed in mice 3.0. The names of the columns now conform to the broom package. You can request the estimates directly in the linear or log odds scale, as follows

require(mice, warn.conflicts = FALSE)
packageVersion("mice")
set.seed(123)
nhanes$hyp <- as.factor(nhanes$hyp)

# Can run logistic regression on (non-imputed) dataset
model <- glm(hyp ~ bmi, family = binomial(link = 'logit'), nhanes)
model_or <- exp(cbind(OR = coef(model), confint(model)))

# Using the nhanes dataset as an example
imputed_data <- mice::mice(nhanes, m = 25, method = "pmm", 
                           maxit = 10, seed = 12345, print = FALSE)
imputed_model <- with(imputed_data, 
                      glm(hyp ~ bmi, family = binomial(link = 'logit')))

# linear scale
round(summary(pool(imputed_model), conf.int = TRUE), 3)

# log odds scale
round(summary(pool(imputed_model), conf.int = TRUE, exponentiate = TRUE), 3)

Using mice v3.3.0, when running the above example code I get the following warning when pooling on the log odds scale using round(summary(pool(imputed_model), conf.int = TRUE, exponentiate = TRUE), 3):

Using mice v3.15.0, when running the above example code I get the following warning when pooling on the log odds scale using round(summary(pool(imputed_model), conf.int = TRUE, exponentiate = TRUE), 3):
Warning message: Error in Math.data.frame(list(term = 1:35, estimate = c(0.46500606968507, :
non-numeric-alike variable(s) in data frame: term.
I do not know why, This question has been bothering me for a long time, I hope you can reply.

from mice.

gerkovink avatar gerkovink commented on June 13, 2024

The column term from the summary output is categorical, so the warning indicates that the desired process in rounding makes no sense there.

from mice.

missingKobe avatar missingKobe commented on June 13, 2024

Very thanks! That's hugely helpful ! I have also two questions to ask:

  1. I have been using MICE to generate imputed datasets, Is it possible to stratify this imputed datasets according to gender and then perform logistic regression. If so how can I stratify this imputed datasets?
  2. I have been using MICE to generate imputed datasets, Is it possible to run BKMR package analysis (or WQS analysis)using this imputed datasets?
    Many thanks for any assistance.

from mice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.