[R] Possible bug in lmer nested analysis with factors
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Fri Sep 16 18:21:17 CEST 2005
My guess is he wants this:
c1 <- factor(c)
d1 <- factor(d)
m <- lmer(a ~ b + (1|c1:d1)+(1|c1))
which assumes d1 is nested within c1.
Take a look at Section 3 in the "MlmSoftRev" vignette:
library(mlmRev)
vignette("MlmSoftRev")
HTH,
--sundar
Doran, Harold wrote:
> I think you might have confused lme code with lmer code. Why do you have
> c/d in the random portion?
>
> I think what you want is
>
>
>>lmer(a ~ b + (1 | c)+(1|d))
>
>
> Which gives the following using your data
>
>
> Linear mixed-effects model fit by REML
> Formula: a ~ b + (1 | c) + (1 | d)
> AIC BIC logLik MLdeviance REMLdeviance
> 108.0239 115.9415 -49.01193 94.57296 98.02386
> Random effects:
> Groups Name Variance Std.Dev.
> d (Intercept) 4.2877e-10 2.0707e-05
> c (Intercept) 4.2877e-10 2.0707e-05
> Residual 8.5754e-01 9.2603e-01
> # of obs: 36, groups: d, 3; c, 2
>
> Fixed effects:
> Estimate Std. Error DF t value Pr(>|t|)
> (Intercept) 0.82928 0.40834 34 2.0309 0.05015 .
> b -0.37563 0.18903 34 -1.9872 0.05500 .
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Yan Wong
> Sent: Friday, September 16, 2005 11:58 AM
> To: R-help
> Subject: [R] Possible bug in lmer nested analysis with factors
>
> Hello,
>
> Is this a bug in the lmer routine?
>
> > library(lme4)
> > ### test case based on rats data from Crawley >
> a<-rnorm(36);b<-rep(1:3,each=12);c<-rep(1:2,each=6,3);d<-rep
> (1:3,each=2,6)
> >
> > ### mixed model works when c & d are numeric, lmer assumes they are
> factors > m <- lmer(a ~ b + (1|c/d)) > > ### but bails out when they
> are actually specified as factors > c<-factor(c); d<-factor(d) > m <-
> lmer(a ~ b + (1| c / d))
>
> Error in lmer(a ~ b + (1 | c/d)) : entry 0 in matrix[0,0] has row
> 2147483647 and column 2147483647
> In addition: Warning message:
> / not meaningful for factors in: Ops.factor(c, d)
>
>
> Cheers
>
> Yan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list