[R-sig-ME] weights and lmer2
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Thu Apr 12 22:01:07 CEST 2007
Douglas Bates said the following on 4/12/2007 11:35 AM:
> 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
>>
Hi, Prof. Bates,
Thanks for the reply. I can wait for next release. I'll just continue
using lme for now. I also forgot to add my sessionInfo if that may be
useful:
> sessionInfo()
R version 2.5.0 beta (2007-04-10 r41119)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
lme4 Matrix lattice
"0.9975-13" "0.9975-11" "0.15-3"
Thanks,
--sundar
More information about the R-sig-mixed-models
mailing list