Bootstrapping an lmer model
On Thu, Nov 3, 2011 at 2:44 PM, Hugo Mildenberger
<Hugo.Mildenberger at web.de> wrote:
Christoph, it appears as if lme4 had dropped the $ operator. A first step to cope with that is to replace "object$call" with "object at call" in "Zelig/R/bootfn.default.R" (i.e. in Zelig package sources),
I don't think that fm$call ever worked with lme4. The '4' in the name is from the use of S4 classes so the only thing that would have worked is fm at call. As of R-2.14.0 there is a base-R function called getCall() which is now used in update, exactly to hide these discrepancies between fitted models represented at S3 or S4 objects. So the preferred form is getCall(fm) instead of either fm$call or fm at call
another involves editing "param.mixed.R" at the same place. But that still isn't enough, because then boot::boot runs into an array index error. I'm attaching a patch against the source tree contained in Zelig_3.5.1.tar.gz, but I almost sure that the param.mixed.R patch is not the right solution, whereas the patch against bootfn.default.R may interfere with other packages. I'd contact the package's authors at this point. The remaining ?Error in t.star[r, ] <- res[[r]] : ? ?incorrect number of subscripts on matrix stems from boot::boot: ?120 ? ? t.star <- matrix(, RR, length(t0)) ?121 ? ? for (r in seq_len(RR)) t.star[r, ] <- res[[r]] res[[r]] is the list returned by param.mer() as defined in Zelig/R/param.mixed.R ?I'd think it can't be correct to assign a nested list to ?t.star. t.star is a matrix with dimensions 100, 3. I hope this still helps a bit. Best regards, Hugo Am 03.11.2011 14:55, schrieb Christoph Scherber:
Dear all, Has anyone written some code to get predicted values from an lmer model using bootstrapping? The only available method seems to be the sim() function in package "Zelig". This works well if you don? do bootstrapping. However, it doesn? seem to work for bootstrap=TRUE: ## require(Zelig) data(voteincome) z.out1 <- zelig(vote ~ education + age + female + tag(1 | state), data = voteincome, model = "logit.mixed") x <- setx(z.out1, education = 4) s.out1 <- sim(z.out1, x = x, bootstrap=TRUE) #Error in `*tmp*`$call : $ operator not defined for this S4 class ## I?e tried to modify some of the internal code from the sim() function, but couldn? get it to work until now. I would greatly appreciate any help, ideas or suggestions. Best wishes, Christoph (using R 2.13.2 on Windows 7 64-Bit)
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models