3

I've imputed data using the MICE package. Now I would like to present the results of a GLM based on the pooled data.

This is how I came up with the data:

data.imputed <- mice(data, m=5, maxit = 50, method = 'pmm', seed = 500)

And this is what I used to create the model:

model.imputed1 <- with(data = data.imputed, expr = glm(dv ~ iv1 + iv2 + iv3, family=binomial))

model.imputed <- pool(model.imputed1)

However, when I run

AIC(model.imputed)

or

logLik(model.imputed)

for that matter, I receive the message

Error in UseMethod("logLik") : no applicable method for 'logLik' applied to an object of class "c('mipo', 'data.frame')"

This looks like it has something to do with the way mice stores its imputed files. Is there a way to extract these two metrics (AIC and logLik) from this model? How could I convert it into a model from which to extract these two metrics?

Thanks!

TT

1 Answer 1

1

Looking at the structure of the pool result it seems that mice::pool does not store this information.

str(pool(model.imputed1))
#Classes ‘mipo’ and 'data.frame':   0 obs. of  3 variables:
#  $ call  : language pool(object = model.imputed1)
#$ m     : int 40
#$ pooled:'data.frame': 3 obs. of  9 variables:
#  ..$ estimate: num  0.0722 -0.2533 -0.8663
#..$ ubar    : num  0.000422 0.000318 0.029756
#..$ b       : num  2.53e-06 3.41e-05 3.95e-04
#..$ t       : num  0.000425 0.000353 0.030162
#..$ dfcom   : int  10060 10060 10060
#..$ df      : num  9902 2765 9487
#..$ riv     : num  0.00615 0.10989 0.01362
#..$ lambda  : num  0.00611 0.09901 0.01343
#..$ fmi     : num  0.00631 0.09966 0.01364

I am not sure whether Rubin's rules function in the same manner when combining stats like AIC and LL, but one thing you can do is get the AIC and LL for each dataset. Since you only have 5 datasets this should not take long.

First retrieve all the completed datasets in long format.

L_df <- mice::complete(data.imputed,"long",include = F) 

Then create some empty vectors and retrieve the number of imputations (m = 5 in your case).

AIC1<-c()
logLik1 <- c()
m <- max(L_df$.imp)

Then estimate the model for each dataset and store the AIC and LL in the empty vectors just created.

for(i in 1:m){
  model.imputed1 <- glm(dv ~ iv1 + iv2 + iv3, family=binomial, data = L_df[which(L_df$.imp == m),])
  AIC1[i] <- AIC(model.imputed1)
  logLik1[i] <- logLik(model.imputed1)
}

The result of this loop should be 5 values for AIC stored in AIC1 and 5 values of the LL stored in logLik1. You could use these values for reporting the average AIC and its variance between datasets, or report more robust measures such as the median and range (since you only have 5 values).

1

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.