[R-sig-ME] crossed random effects example

Reinhold Kliegl reinhold.kliegl at gmail.com
Sun Mar 1 20:57:47 CET 2009


Try:
> data(ScotsSec, package = "mlmRev")
> (fm <- lmer(attain ~ 0 + sex + verbal + (1|primary) + (1|second), ScotsSec) )

Reinhold Kliegl

On Sun, Mar 1, 2009 at 5:44 PM, Jeroen Ooms <jeroenooms at gmail.com> wrote:
> OK, maybe you are right. I tried the link you sent for another
> example. However, also in this example, the variance of the second
> random effect is estimated at zero:
>
> pilots1 <- lmer (y ~ 1 + (1 | group.id) + (1 | scenario.id))
> pilots1
>
> Random effects:
>  Groups      Name        Variance   Std.Dev.
>  scenario.id (Intercept) 1.0333e-01 3.2145e-01
>  group.id    (Intercept) 9.3719e-24 3.0614e-12
>  Residual                4.6738e-02 2.1619e-01
>
> I find this very confusing. Is it also possible to have crossed random
> effects that both have variance? An example would be great. Thanks
> very much!
>
>
> On Sun, Mar 1, 2009 at 5:24 PM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>> The values are the same to one decimal place and nearly the
>> same to two decimal places.
>>
>> On Sun, Mar 1, 2009 at 11:12 AM, Jeroen Ooms <j.c.l.ooms at uu.nl> wrote:
>>> Hello Gabor,
>>>
>>> I don't understand what you mean. lmer reports a variance of treatment
>>> that is practically 0:
>>>
>>> Random effects:
>>> Groups    Name        Variance   Std.Dev.
>>> airport   (Intercept) 1.0369e-01 3.2202e-01
>>> treatment (Intercept) 1.0140e-23 3.1844e-12
>>> Residual              4.6991e-02 2.1677e-01
>>>
>>> It seems as if lmer shows there is no variance at all for the
>>> treatment effect. I think this is quite different than the 0.04
>>> reported in the slide. Are you sure I did not did use the correct
>>> syntax?
>>>
>>>
>>>
>>> On Sun, Mar 1, 2009 at 4:27 PM, Gabor Grothendieck
>>> <ggrothendieck at gmail.com> wrote:
>>>> I suspect that the slide you are referencing mislabeled the
>>>> standard deviations as variances since there is reasonable
>>>> correspondence between your output and the slides if that
>>>> were the case.
>>>>
>>>> Also check out:
>>>> http://www.stat.columbia.edu/~gelman/arm/examples/pilots/
>>>>
>>>> On Sat, Feb 28, 2009 at 6:00 PM, Jeroen Ooms <j.c.l.ooms at uu.nl> wrote:
>>>>> I am trying to learn about crossed random effects modeling in lme4. I
>>>>> found this presentation that provides a small crossed dataset.
>>>>> http://www.biostat.jhsph.edu/~fdominic/teaching/bio656/lectures/5addsin.crosslevels.ppt
>>>>> I would like to reproduce the variance components as reported on slide
>>>>> 9 of the powerpoint. Here is my code:
>>>>>
>>>>> y <- c(0.38,0,0.38,0,.33,1,.12,1,.25,0,.5,.12,.5,1,.12,.86,.5,.67,.33,0,.14,1,0,1,.14,0,.71,0,.29,1,.14,1,.43,0,.29,.86,.86,.86,.14,.75)
>>>>> x2 <- rep(paste("airport",1:8,sep=""),5)
>>>>> x1 <- rep(paste("treatment",1:5,sep=""),rep(8,5))
>>>>> mydata <- data.frame(y=y,airport=x2,treatment=x1)
>>>>> lmer(y~1+(1|airport)+(1|treatment),data=mydata)
>>>>>
>>>>> However, the variance components as reported by lmer are different
>>>>> from the ones in the slides. What formula should I use? thank you!
>>>>>
>>>>> _______________________________________________
>>>>> 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
>




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