Skip to content
Prev 131510 / 398502 Next

AIC v. extractAIC

Ryan Briscoe Runquist wrote:
The documentation for these functions does explain what's going on,
albeit fairly tersely.  The bottom line is that you should be OK with either
one, provided that you stick to one or the other.

set.seed(1001)
x = runif(100)
y = 1 + 2*x+3*x^2+rnorm(100,sd=0.02)

lm1 = lm(y~x)
lm2 = lm(y~x+I(x^2))

## different
AIC(lm1,lm2)
extractAIC(lm1)
extractAIC(lm2)

## the same
AIC(lm1)-AIC(lm2)
extractAIC(lm1)[2]-extractAIC(lm2)[2]

lm3 = glm(y~x)
lm4 = glm(y~x+I(x^2))

## the same
AIC(lm4)
extractAIC(lm4)