[R-sig-ME] Bootstrapping an lmer model
Christoph Scherber
Christoph.Scherber at agr.uni-goettingen.de
Thu Nov 3 22:14:41 CET 2011
Dear Hugo & all,
Many thanks for this suggestion; I now temporarily replaced $ by @ in all
relevant functions from Zelig. The problem is that Zelig uses many small
subfunctions that all need to be checked for S4 compatibility (I´ve
contacted the package authors on that).
The missing information was indeed the t.star code in boot(). This should
do the job - I´ll get back to you once I´ve tried it out!
Thanks again for this great help. I guess quite a few users might be
interested in that (given the recent posts about predictions from lmer
models).
All the best
Christoph
> 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
>
More information about the R-sig-mixed-models
mailing list