Skip to content
Prev 275 / 20628 Next

R questions

Whether or not the BLUPs are very similar to the means depends
on the relative magnitudes of the relevant components of variance.
Try the following code (from p.309 of the 2nd edn of my book with
John Braun):

ant111b.lmer <- lmer(harvwt ~ 1 + (1 | site), data=ant111b)
options(digits=4)

ant111b.lmer

##           Fitted values and residuals in \texttt{lmer()}
s2W <- 0.578; s2L <- 2.37; n <- 4
sitemeans <- with(ant111b, sapply(split(harvwt, site), mean))
grandmean <- mean(sitemeans)
shrinkage <- (n*s2L)/(n*s2L+s2W)
grandmean + shrinkage*(sitemeans - grandmean)
##
## More directly, use fitted() with the lmer object
unique(fitted(ant111b.lmer))
##
## Compare with site means
sitemeans


John Maindonald             email: john.maindonald at anu.edu.au
phone : +61 2 (6125)3473    fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
On 3 Aug 2007, at 5:46 PM, Iasonas Lamprianou wrote: