Dear R collegues, I'm trying to understand what's AIC in R (ver. 1.3.1), and I'm getting a different answer if I look at the AIC(of the fitted model) or the aic in the summary( of the fitted model). Is this correct? Can somebody explain me the difference between the two values? or Is the AIC criterion not appropiated for Poisson models? R session:> t1 <- glm(tax ~ areal, family=poisson(link=log)) > t2 <- summary(t1) > AIC(t1)[1] 2173.717> t2[5]$aic [1] 35206.69> t2[12]$aic [1] 35206.69> t1Call: glm(formula = tax ~ areal, family = poisson(link = log)) Coefficients: (Intercept) areal 3.19610 0.03029 Degrees of Freedom: 283 Total (i.e. Null); 282 Residual Null Deviance: 40600 Residual Deviance: 32880 AIC: 35210> t2Call: glm(formula = tax ~ areal, family = poisson(link = log)) Deviance Residuals: Min 1Q Median 3Q Max -25.259 -8.768 -1.270 6.653 25.605 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 3.1960994 0.0362085 88.27 <2e-16 *** areal 0.0302905 0.0003333 90.88 <2e-16 *** --- Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 40605 on 283 degrees of freedom Residual deviance: 32881 on 282 degrees of freedom AIC: 35207 Number of Fisher Scoring iterations: 3 Thank you very much for your help Juli -- Juli G. Pausas Centro de Estudios Ambientales del Mediterraneo (CEAM) C/ C.R. Darwin 14, Parc Tecnologic, 46980 Paterna, Valencia, SPAIN Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190 mailto:juli at ceam.es http://www.gva.es/ceam GCTE Fire Network - http://www.gva.es/ceam/FireNetwork -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010911/6365c884/attachment.html
On Tue, 11 Sep 2001, juli g. pausas wrote:> Dear R collegues, > I'm trying to understand what's AIC in R (ver. 1.3.1), and I'm getting a > different answer if I look at the AIC(of the fitted model) or the aic in > the summary( of the fitted model). Is this correct? Can somebody explain > me the difference between the two values? or Is the AIC criterion not > appropiated for Poisson models?It's the AIC _function_ that is inappropriate for glm models. There is no glm method, so the lm method is used. Martin: I think you moved AIC and logLik into base R: this needs sorting out. [...] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
[diverted to R-devel; I'm really discussing future development]>>>>> "BDR" == Prof Brian Ripley <ripley@stats.ox.ac.uk> writes:BDR> On Tue, 11 Sep 2001, juli g. pausas wrote: >> Dear R collegues, >> I'm trying to understand what's AIC in R (ver. 1.3.1), and I'm getting a >> different answer if I look at the AIC(of the fitted model) or the aic in >> the summary( of the fitted model). Is this correct? Can somebody explain >> me the difference between the two values? or Is the AIC criterion not >> appropiated for Poisson models? BDR> It's the AIC _function_ that is inappropriate for glm models. BDR> There is no glm method, so the lm method is used. actually, the AIC.lm() is just from the nlme package and it is very much appropriate insofar as it entirely builds on logLik() {itself a generic}. I've found recently, that I'd like to *rename* the current AIC.lm to AIC.default since it is really correct whenever logLik() is correct. For a private package, I recently found that I just could do AIC.myclass <- AIC.lm (and define a correct logLik.myclass !!) where the definition of AIC.myclass would have been unnecessary, had AIC.lm been called AIC.default. AIC() would then barf whenever there's no logLik() method for the given model class which I'd think to be fine (no?) BDR> Martin: I think you moved AIC and logLik into base R: this needs BDR> sorting out. yes. However, I haven't changed the AIC.lm and logLik.lm methods, and the currrent behavior is just what *was* the former behavior after library(nlme) had been called, then. What really needs a fix is logLik.lm(), probably by providing a logLik.glm() method which seems almost trivial, given the way our glm families are implemented, the internal aic() function is really -2*logLik(.). For the quasi "family", the result would be NA, rightly. BTW, I'm more and more wondering if we shouldn't commit these as patches to 1.3.x rather than only for 1.4.. Martin -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._