# [R] help about how can R compute AIC?

Bernardo Rangel Tura tura at centroin.com.br
Wed Oct 15 11:14:12 CEST 2008

```Em Ter, 2008-10-14 às 17:13 +0200, Arnau Mir Torres escreveu:
> Hello.
>
> I need to know how can R compute AIC when I study a regression model?
> For example, if I use these data:
>    growth tannin
> 1     12      0
> 2     10      1
> 3      8      2
> 4     11      3
> 5      6      4
> 6      7      5
> 7      2      6
> 8      3      7
> 9      3      8
> and I do
> model <- lm (growth ~ tannin)
> AIC(model)
>
> R responses:
> 38.75990
>
> I know the following formula to compute AIC:
> AIC= -2*log-likelihood + 2*(p+1)
>
> In my example, it would be:
> AIC=-2*log-likelihood + 2*2
> but I don't know how R computes log-likelihood:
>
> logLik(model)
> 'log Lik.' -16.37995 (df=3)

Arnau,

LogLik= -16.37995

AIC= -2*log-likelihood + 2*(p+1)

AIC=-2*-16.37995 + 2*(p+1)

AIC= 32.7599+2*(p+1)

#
# this is very important the model have two
# parameter, because sigma is a parameter to.
# so
#

AIC= 32.7599+2*(2+1)

AIC= 32.7599+6

AIC= 38.7599
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

```