IQSS / ZeligMultilevel

Five Multi-level Zelig Models
8 stars 3 forks source link

Issue with class of Zelig summaries #4

Open jdbest opened 7 years ago

jdbest commented 7 years ago

I've been running into an issue with imputed output in Zelig multilevel models. Here's a quick example based on one of the demos in the package:

data(voteincome)
z5 <- zlogitmixed$new()
z5
z5$zelig(vote ~ education + age + female + (1 | state),
         data = voteincome)
z5

That works fine. However, if we induce some NAs and impute the data, the model doesn't work:

voteincome$vote[sample(nrow(voteincome), 300)] <- NA
a.out <- amelia(voteincome, noms = c("state", "vote"), idvars = "year")
z5 <- zlogitmixed$new()
z5$zelig(vote ~ education + age + (1 | state), data = a.out$imputations)
z5

(There's a warning from lme4 about a "nearly unidentificable model", but the model converges.) Importantly, however, there is no z5 summary object:

Error in diag(vcovlist[[i]]) : no method for coercing this S4 class to a vector

Is this an lme4 issue or a Zelig issue? It seems like it could run either way.

christophergandrud commented 7 years ago

Thanks for the post @jdbest. ZeligMultilevel isn't really supported or underdevelopment at the moment. We suggest using merTools instead.

@cchoirat do you know if merTools has capabilities to work with imputed data sets?

jknowles commented 7 years ago

Yes - it does. You can use the merList functionality, and there are some answers on StackOverflow. It isn't completely automated (you still have to write some glue code to combine parameter estimates I think), but it's all really easy with lapply or purrr.

https://stats.stackexchange.com/questions/117605/lmer-with-multiply-imputed-data

jdbest commented 7 years ago

Thanks to both of you, @christophergandrud and @jknowles – I saw that there had been recent commits, but I appreciate the update of the project. (The Zelig homepage should probably be updated as well.)

@jknowles the documentation on the stackexchange page is very helpful, as well.

jknowles commented 7 years ago

@jdbest Suggestions/feature requests welcomed on GitHub of course (jknowles/merTools) -- hope it helps