[R] problem with extractAIC()

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Mar 6 19:37:05 CET 2010



On 06.03.2010 15:58, Jordi Moya wrote:
>
>      Dear friends,
>     If I use:
>     model<-lm(y ~ x)
>     and then extractAIC(model), the value that I obtain does not match (not even
>     close):
>     AIC=2*k-2*logLik(model)
>     However, using AIC from the AICcmodavg(), the value matches exactly the
>     above value.
>     I read the help of extractAIC() and could not figure out what was wrong,
>     other than what I call k (number of parameters) is edf in the help and k
>     they use for the value 2 that multiplies my k, their edf, and which is
>     implemeted  as  the  default, thus not possibly being the cause of the
>     missmatch.
>     Does anybody know whether am I missing something or whether there may be a
>     bug in extractAIC()?

?extractAIC tells you

For linear models with unknown scale (i.e., for lm and aov), -2\log L is 
computed from the deviance and uses a different additive constant to 
logLik  and hence AIC.

Hence you want to compare your formula above with

AIC(model)


To compare the code type

stats:::extractAIC.lm

and compare the logLik related devianbce part of it with the

stats:::logLik.lm

as used in AIC().


Best,
Uwe Ligges



>     Best wishes,
>     Jordi Moya-Laraño
>     Cantabrian Institute of Biodiversity (ICAB)
>     Dpto. Biología de Organismos y Sistemas
>     Universidad de Oviedo
>     Catedrático Rodrigo Uría s/n
>     33006-Oviedo
>     Asturias
>     Spain
>     [1]http://www.uniovi.es/icab/jordi.html
>
> References
>
>     1. http://www.uniovi.es/icab/jordi.html
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list