Two-Way Random-Effect Model

Newswriting Efficiency Example

> efficiency <- data.frame(eff=scan(),

+   writer=gl(4,3,36), wp=gl(3,12))

1: 116 113 115 129 124 123 119 124 126 123 123 129

13: 120 120 123 124 115 117 119 122 117 114 120 122

25: 117 115 118 123 127 123 130 134 128 117 121 118

37:

Read 36 items

> summary( efficiency.lmer <- lmer(eff~1 + (1|wp) + (1|writer) + (1|wp:writer),

+       data=efficiency) )

Linear mixed model fit by REML ['lmerMod']
Formula: eff ~ 1 + (1 | wp) + (1 | writer) + (1 | wp:writer) 
   Data: efficiency 

REML criterion at convergence: 200.4838 

Random effects:
 Groups    Name        Variance  Std.Dev. 
 wp:writer (Intercept) 1.456e+01 3.8151525
 writer    (Intercept) 2.988e+00 1.7284867
 wp        (Intercept) 5.918e-08 0.0002433
 Residual              9.000e+00 3.0000053
Number of obs: 36, groups: wp:writer, 12; writer, 4; wp, 3

Fixed effects:
            Estimate Std. Error t value
(Intercept)  121.333      1.487   81.62

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

> s664<-"t:/664Spring2014"

> Rimages <- paste(s664,"R","images",sep="/")

> Rimages

[1] "t:/664Spring2014/R/images"

> png(file=paste(Rimages,"efficiency%02d.png",sep="/"),

+     pointsize=10)

> x <- qqmath(re)

> names(re)

[1] "wp:writer" "writer"    "wp"

> x[[1]]$main <- "wp:writer random effects"

> x[[2]]$main <- "writer random effects"

> x[[3]]$main <- "wp random effects"

> # The above can be accomplished by

> # mains <- paste(names(re), "random effects")

> # for(i in 1:3) x[[i]]$main <- mains[i]

> x   # now, 'print' (actually 'plot') it

$`wp:writer`

$writer

$wp

> dev.off()

null device 
          1

> # Three PNG files are produced: efficiency01.png,

> #   efficiency02.png, and efficiency03.png

efficiency01.png

(efficiency01.png here)

efficiency02.png

(efficiency02.png here)

efficiency03.png

(efficiency03.png here)