[R-sig-ME] How to extract the variance of interaction from lme

Ben Bolker bbolker at gmail.com
Sun Aug 25 19:05:12 CEST 2013


Tal Lahav <lahav.t at ...> writes:

> 
> Hello,
> 
> I have a mixed model two-way anova with interaction: y=a+b+a*b+e, where
> both a and b are factors, and b and the interaction a*b are random.
> I used lme: fm <- lme(y ~ a, random = ~ 1|b/a,method="REML").
> I want to extract the variance of the interaction 
> (which should be equal to
> (MSAB-MSE)/n   in a balanced model), is it possible?
> 

  
  It should be possible, via VarCorr(model). 

library(nlme)
data(Pastes,package="lme4")
head(Pastes)
  strength batch cask sample
1     62.8     A    a    A:a
2     62.6     A    a    A:a
3     60.1     A    b    A:b
4     62.3     A    b    A:b
5     62.7     A    c    A:c
6     63.1     A    c    A:c
fm <- lme(strength~cask, random=~1|batch/cask, 
     method="REML", data=Pastes)
VarCorr(fm)
            Variance     StdDev   
batch =     pdLogChol(1)          
(Intercept) 1.5227888    1.2340133
cask =      pdLogChol(1)          
(Intercept) 8.8373194    2.9727629
Residual    0.6779997    0.8234073

  I think the reported 'cask (Intercept)' variance should be
what you want; I hope someone will correct me if necessary.

  Ben Bolker



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