[R-sig-ME] weights and lmer2
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Thu Apr 12 20:16:24 CEST 2007
Hi, all,
Is the weights argument supposed to work with lmer2? I'm trying to
replicate some analysis from nlme::lme but am having difficulty with the
weights argument. Here's some funny data to work with:
set.seed(42)
z <- expand.grid(A = 1:5, B = 1:4, r = 1:2)
n <- nrow(z)
z$w <- rpois(n, 100)
z$y <- rnorm(n, ifelse(z$A%%2, 1, 2) + ifelse(z$A%%2 & z$B%%2, -1, 1))
z[1:2] <- lapply(z[1:2], factor)
## Session 1 with lmer2
library(lme4)
fit <- lmer2(y ~ (1 | A) + (1 | A:B), z)
wfit <- lmer2(y ~ (1 | A) + (1 | A:B), z, weights = w)
## Session 2 with lme
library(nlme)
fit <- lme(y ~ 1, z, ~1 | A/B)
wfit <- lme(y ~ 1, z, ~1 | A/B, weights = ~w)
vfit <- lme(y ~ 1, z, ~1 | A/B, correlation = varFixed(~w))
## Standard deviations from Session 1 (lmer2)
fit wfit
A:B 0.9371798 0.9371798
A 0.8673610 0.8673610
Residual 0.7908478 0.7908478
## Standard deviations from Session 2 (lme)
fit wfit vfit
(Intercept) | B %in% A 0.9371788 0.90186678 0.90186678
(Intercept) | A 0.8673608 0.87420501 0.87420501
Residual 0.7908482 0.07878061 0.07878061
It appears that the weights argument has no effect for lmer2 (or for
lmer, which I also tried).
Thanks,
--sundar
More information about the R-sig-mixed-models
mailing list