0

How can I use the simulate function on a pooled GLM from MICE?

I have my MICE-imputed data in the object miceData. On this data i made a model as such:

form3 <- survived ~  sex + age * pclass - 1
glm3 <- glm.mids(data=miceData, form3, family = binomial(link=logit))
glm_pooled <- pool(glm3)

I now which to simulate data from this model in an equlivivant way of the following:

form3 <- survived ~  sex + age * pclass - 1
glm3_ref <- glm(form3, family = binomial(link=logit), data = titanic)
yNew <- simulate(glm3_ref)[,1]

How can i do this?

Landscape
  • 249
  • 1
  • 2
  • 13

1 Answers1

0

So you need is a glm-object that has the coefficients you obtained in glm_pool but otherwise looks like a usual (i.e. not imputation-based) glm output.

You can do that by first creating a glm-object from one complete dataset (one imputation) and then changing the coefficients:

glm_sim <- glm(form3, family = binomial(link=logit), data = mice::complete(miceData, action = 1) )
glm_sim$coefficients <- glm_pooled$pooled$estimate #please check if the order of estimates is correct!

Then use glm_sim as you intended. However, as others (who know a lot more than I do) have pointed out, be very cautious with this because anything derived from other components of glm_sim is still only based on a single imputation sample and thus not valid. For instance, model diagnostics will be useless.

benimwolfspelz
  • 679
  • 5
  • 17