[R-sig-ME] Bootstrapping an lmer model

Hugo Mildenberger Hugo.Mildenberger at web.de
Thu Nov 3 20:44:51 CET 2011


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), 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´t do bootstrapping. However, it doesn´t 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´ve tried to modify some of the internal code from the sim() function, but couldn´t 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Zelig-lme4.patch
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20111103/51104938/attachment-0004.pl>


More information about the R-sig-mixed-models mailing list