[R-sig-ME] Bug in weights in lmer

Nick Isaac njbisaac at googlemail.com
Wed Apr 23 14:38:54 CEST 2008


I have unearthed a bug in the way lmer() deals with weights.

Adding weights causes an inflation of the variance estimates. The
phenomenon is easily demonstrated by comparing the following models,
all of which should be identical:

w<-rep(1,nrow(sleepstudy))
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) )
(fm2 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy, weights = w) )
(fm3 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy, weights = w/sum(w)) )

I have tried this with other datasets and models and find the same
general pattern. I find that the inflation factor is correlated with
sum(w) and is higher for cross-classified models than simple nested
ones.

The fixed effect estimates are also changed.

Best wishes, Nick


> sessionInfo()
R version 2.6.2 (2008-02-08)
i386-apple-darwin8.10.1

locale:
en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] lme4_0.999375-13  Matrix_0.999375-7 lattice_0.17-6

loaded via a namespace (and not attached):
[1] grid_2.6.2




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