[R] Degrees of freedom for lm in logLik and AIC

peter dalgaard pdalgd at gmail.com
Mon Mar 28 08:36:53 CEST 2011


On Mar 28, 2011, at 05:36 , Frank Harrell wrote:

> I have a question about the computation of the degrees of freedom in a linear
> model:
> 
> x <- runif(20); y <- runif(20)
> f <- lm(y ~ x)
> logLik(f)
> 'log Lik.' -1.968056 (df=3)
> 
> The 3 is coming from f$rank + 1.  Shouldn't it be f$rank?  This affects
> AIC(f).

I count three parameters in a simple linear regression: alpha, beta, sigma.

From a generic-likelihood point of view, I don't see how you can omit the last one.

-pd

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list