Skip to content

Instantly share code, notes, and snippets.

@daviddalpiaz
Last active February 27, 2017 18:34
Show Gist options
  • Save daviddalpiaz/ccc49357b215c6185584a6ab84284db6 to your computer and use it in GitHub Desktop.
Save daviddalpiaz/ccc49357b215c6185584a6ab84284db6 to your computer and use it in GitHub Desktop.
extractAIC() vs AIC()
fit_test = lm(dist ~ ., data = cars)
n = length(resid(fit_test))
p = length(coef(fit_test))
-2 * logLik(fit_test) + 2 * p
AIC(fit_test)
extractAIC(fit_test) + n + n * log(2 * pi)
@daviddalpiaz
Copy link
Author

AIC is being calculated with a different p depending on the function used. It is not simply an issue of omitting a constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment