# [R] AIC in glm()

yudi@stat.ucc.ie yudi at stat.ucc.ie
Sat Dec 9 22:06:59 CET 2000

```> Date:          Fri, 08 Dec 2000 16:53:26 +0000
> From:          Yvonnick Noel <noel at univ-lille3.fr>
> Subject:       [R] AIC in glm()
> To:            r-help at stat.math.ethz.ch

> Hello,
>
> I just trying to play around with very simple generalized models and have
> tried the following model :
>
> glm(count~t1*t2,family=poisson())
>
> on data from Jim Lindsey's book :
>
> change
>   count t1 t2
> 1    45  1  1
> 2    13  1  2
> 3    12  2  1
> 4    54  2  2
>
> I get :
>
> Call:  glm(formula = change\$count ~ change\$t1 * change\$t2, family = poisson())
>
> Coefficients:
>           (Intercept)             change\$t12             change\$t22
>                 3.807                 -1.322                 -1.242
> change\$t12.change\$t22
>                 2.746
>
> Degrees of Freedom: 3 Total (i.e. Null);  0 Residual
> Null Deviance:      48.11
> Residual Deviance: 6.596e-16    AIC: 28.23
>
> My question is :
>
> how the AIC value is computed here? Because the deviance is null, I expected
> an AIC of 2p = 8. But I'm probably missing something.
>
AIC = -2 log like(at the MLE) + 2p      (Not:  deviance + 2p).

see the following:
> reg_ glm(change\$count~ change\$t1 * change\$t2,family=poisson)
> -2*sum(log(dpois(change\$count,reg\$fit))) + 2*4
[1] 28.23050

(here reg\$fit= change\$count since it is a saturated model.)

------------------------------
Yudi Pawitan: yudi at stat.ucc.ie
Department of Statistics, UCC
Cork, Ireland
Ph : 353-1-490 2906
Fax: 353-1-427 0104
-----------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```