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) Thanks, Arnau. ------------------------------------------------------------ Arnau Mir Torres Edifici A. Turmeda Campus UIB Ctra. Valldemossa, km. 7,5 07122 Palma de Mca. tel: (+34) 971172987 fax: (+34) 971173003 email: arnau.mir at uib.es URL: http://dmi.uib.es/~arnau
>>>>> "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
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