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

Martin Maechler maechler at stat.math.ethz.ch
Tue Oct 14 18:05:35 CEST 2008

```>>>>> "AMT" == Arnau Mir Torres <arnau.mir at uib.es>
>>>>>     on Tue, 14 Oct 2008 17:13:01 +0200 writes:
>>>>> "AMT" == Arnau Mir Torres <arnau.mir at uib.es>
>>>>>     on Tue, 14 Oct 2008 17:13:01 +0200 writes:

AMT> Hello.

AMT> I need to know how can R compute AIC when I study a regression model?
AMT> For example, if I use these data:
AMT> growth tannin
AMT> 1     12      0
AMT> 2     10      1
AMT> 3      8      2
AMT> 4     11      3
AMT> 5      6      4
AMT> 6      7      5
AMT> 7      2      6
AMT> 8      3      7
AMT> 9      3      8
AMT> and I do
AMT> model <- lm (growth ~ tannin)
AMT> AIC(model)

AMT> R responses:
AMT> 38.75990

AMT> I know the following formula to compute AIC:
AMT> AIC= -2*log-likelihood + 2*(p+1)

AMT> In my example, it would be:
AMT> AIC=-2*log-likelihood + 2*2
AMT> but I don't know how R computes log-likelihood:

AMT> logLik(model)
AMT> 'log Lik.' -16.37995 (df=3)

and so?

Hint:     Your only problem is that your 'p' is wrongly off by one.
2nd Hint: sigma is a parameter, too

```