0
$\begingroup$

I'm seeing some "inconsistencies" on how R calculates the Akaike Information Criterion (AIC) for linear regression models. I'd like to get its expression so I can calculate it myself. The issues I'm referring to can be seen here:

complex_model <- lm(mpg~hp+wt, mtcars)
simple_model <- lm(mpg~hp, mtcars)
AIC(complex_model)
AIC(simple_model)
step(complex_model)

The difference in AIC between both models stay the same, however the values don't. I understand that for all practical effect in model selection this doesn't change much, but why is the results different? What expressions are these values obtained from?

$\endgroup$
1

1 Answer 1

2
$\begingroup$

See this answer:

What is the difference between AIC() and extractAIC() in R?

I discovered this by inspecting the code of the step() function, looking at the help for extractAIC() and, finding that confusing, searching CrossValidated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.