[R-sig-ME] different AIC value from anova() and AIC() for lm

Ben Bolker bbolker at gmail.com
Sun Dec 19 19:54:19 CET 2010


On 10-12-19 12:26 PM, Jude Phillips wrote:
> Hi,
> 
> I'm trying to compare models with same fixed effects but different
> random effects, but I've noticed that for lm models, I get a different
> AIC value when I compare models with anova, compared to when I just
> use the AIC command to calculate AIC.  I've put an example below using
> the Orthodont data.  I'm worried about his because an editor has asked
> me to use AICc rather than AIC to compare models.  My plan was to use
> the AICc command in the AICcmodavg package, to calculate AICc for each
> model and compare them manually, but now I'm not sure this will work.
> 
  It looks like the difference is due to the REML condition:

AIC(fm4Orth.lm)
AIC(logLik(fm4Orth.lm,REML=TRUE))

  I figured this out by a combination of:

trace(anova,browser)
anova.lme
debug(anova.lme)

 etc.



> Thanks, Jude Girard
> PhD candidate
> GLEL, Carleton University.
> 
> 
>> fm2Orth.lme <- lme(fixed = distance~Sex*I(age-11), random=~I(age-11)|Subject, data=Orthodont)
>> fm4Orth.lm <- lm( distance ~ Sex * I(age-11), Orthodont )
>> anova( fm2Orth.lme, fm4Orth.lm )
> 
>            Model df      AIC      BIC    logLik   Test  L.Ratio p-value
> fm2Orth.lme     1  8 448.5817 469.7368 -216.2908
> fm4Orth.lm       2  5 493.5591 506.7811 -241.7796 1 vs 2 50.97746  <.0001
> 
>> AIC(fm2Orth.lme, fm4Orth.lm)
>                   df      AIC
> fm2Orth.lme  8 448.5817
> fm4Orth.lm    5 488.2418
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models




More information about the R-sig-mixed-models mailing list