weights and lmer2
On 4/12/07, Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> wrote:
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)
It is supposed to work but I'm not sure if it was working in the last released version of the lme4 package. I don't plan on releasing a new version of lme4 until after R-2.5.0 is released. There as changes in the development version of lme4 that require R >= 2.5.0 I'll run your test in the development version later today if someone else doesn't get a chance to do so before me. I'm tied up with classes and midterm exams right now.
## 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
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models