On 18 Oct 2006 16:21:11 -0400, Darren M. Ward
<Darren.M.Ward at dartmouth.edu> wrote:> Hi all,
>
> I am having issues comparing models with lmer. As an example, when
> I run the code below the model summaries (AIC, BIC, loglik) differ between
> the summary() and anova() commands. Can anyone clear up what's wrong?
'summary' uses REML or ML depending on what 'method' was used,
whereas
'anova' always uses ML (presumably at the parameter values that
maximize the REML if method="REML"). With
'method="ML"' in the lmer
calls, you should see the same in both.
-Deepayan
> Thank you!
>
> Darren Ward
>
> library(lme4)
> data(sleepstudy)
> fm1<-lmer(Reaction ~ Days + (1|Subject), sleepstudy)
> summary(fm1)
> fm2<-lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
> summary(fm2)
> anova(fm1, fm2)
>
> Sample output:
>
> > summary(fm1)
> Linear mixed-effects model fit by REML
> Formula: Reaction ~ Days + (1 | Subject)
> Data: sleepstudy
> AIC BIC logLik MLdeviance REMLdeviance
> 1792 1802 -893.2 1794 1786
>
> > summary(fm2)
> Linear mixed-effects model fit by REML
> Formula: Reaction ~ Days + (Days | Subject)
> Data: sleepstudy
> AIC BIC logLik MLdeviance REMLdeviance
> 1754 1770 -871.8 1752 1744
>
> > anova(fm1, fm2)
> Data: sleepstudy
> Models:
> fm1: Reaction ~ Days + (1 | Subject)
> fm2: Reaction ~ Days + (Days | Subject)
> Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
> fm1 3 1800.10 1809.68 -897.05
> fm2 5 1761.98 1777.95 -875.99 42.115 2 7.158e-10 ***
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
'.' 0.1 ' ' 1
> > sessionInfo()
> R version 2.4.0 (2006-10-03)
> 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] "methods" "stats" "graphics"
"grDevices" "utils" "datasets"
> [7] "base"
>
> other attached packages:
> vegan lme4 Matrix lattice
> "1.8-3" "0.9975-6" "0.9975-3"
"0.14-9"
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
--
http://www.stat.wisc.edu/~deepayan/