I am trying to run a layered model for multiple imputed data (created using Amelia); the sample is based on a cluster sample with a group = 24, N = 150.
library("ZeligMultilevel") ML.model.0 <- zelig(dv~1 + tag(1|group), model="ls.mixed", data=a.out$imputations) summary(ML.model.0)
This code produces the following error code:
Error in object[[1]]$result$call : $ operator not defined for this S4 class
If I run OLS regression, it works:
model.0 <- zelig(dv~1, model="ls", data=a.out$imputations) m.0 <- coef(summary(model.0)) print(m.0, digits = 2) Value Std. Error t-stat p-value [1,] 45 0.34 130 2.6e-285
I am pleased to present a working example. .
require(Zelig) require(Amelia) require(ZeligMultilevel) data(freetrade) length(freetrade$country)
I think the problem is with the way Zelig interacts with the Amelia mi class. So I turned to the alternative package R: lme4.
require(lme4) write.amelia(obj=a.out, file.stem="inmi", format="csv", na="NA") diff <-list(5)
The result is the following:
[[1]] [1] 5 [[2]] NULL [[3]] NULL [[4]] NULL [[5]] Linear mixed model fit by REML Formula: polity ~ 1 + (1 | country) Data: data.to.use AIC BIC logLik deviance REMLdev 1006 1015 -499.9 1002 999.9 Random effects: Groups Name Variance Std.Dev. country (Intercept) 14.609 3.8222 Residual 17.839 4.2236 Number of obs: 171, groups: country, 9 Fixed effects: Estimate Std. Error t value (Intercept) 2.878 1.314 2.19
The results remain unchanged when I replace diff[[5]] with diff[[4]] , diff[[3]] , etc. However, I am wondering if these are true results for a combined dataset or for a single set of imputed data. Any thoughts? Thank you