Nested Designs #2

Spray Example

> spray <- data.frame(spray=gl(3,24), tree=gl(4,6,72),

+     leaf=gl(6,1,72),

+     nitrogen=c(4.5,7.04,4.98,5.48,6.54,7.2,5.78,7.69,

+     12.68,5.89,4.07,4.08,13.32,15.05,12.67,12.42,

+     10.03,13.5,11.59,8.96,10.95,9.87,10.48,12.79,

+     15.32,14.97,14.81,14.26,15.88,16.01,14.53,14.51,

+     12.61,16.13,13.65,14.78,10.89,10.27,12.21,12.77,

+     10.45,11.44,15.12,13.79,15.32,11.95,12.56,15.31,

+     7.18,7.98,5.51,7.48,7.55,5.64,6.7,8.28,

+     6.99,6.4,4.96,7.03,5.94,5.78,7.59,7.21,

+     6.12,7.13,4.08,5.46,5.4,6.85,7.74,6.81))

> save.image()

> require(lme4)

Loading required package: lme4
Loading required package: lattice
Loading required package: Matrix

> spray.lmer <- lmer(nitrogen ~ spray + (1|spray:tree), data=spray)

> spray.lmer

Linear mixed model fit by REML ['lmerMod']
Formula: nitrogen ~ spray + (1 | spray:tree) 
   Data: spray 

REML criterion at convergence: 281.1485 

Random effects:
 Groups     Name        Variance Std.Dev.
 spray:tree (Intercept) 4.214    2.053   
 Residual               2.152    1.467   
Number of obs: 72, groups: spray:tree, 12

Fixed effects:
            Estimate Std. Error t value
(Intercept)    9.065      1.069   8.478
spray2         4.666      1.512   3.086
spray3        -2.490      1.512  -1.646

Correlation of Fixed Effects:
       (Intr) spray2
spray2 -0.707       
spray3 -0.707  0.500

> spray.re <- ranef(spray.lmer, condVar=T)

> spray.re

An object of class "ranef.lmer"
[[1]]
    (Intercept)
1:1 -2.86447979
1:2 -2.18099802
1:3  3.47116586
1:4  1.57431195
2:1  1.36158785
2:2  0.58748714
2:3 -2.20480469
2:4  0.25572970
3:1  0.28990379
3:2  0.13938420
3:3  0.04876527
3:4 -0.47805326

> trellis.device(windows, width=4, height=4, pointsize=10)

> qqmath(spray.re,

+   main="Caterpillar Plot of Random Effects\ntree(spray)")

$`spray:tree`

> dev.off()

null device 
          1

(spray01.png here)