1
$\begingroup$

I am trying to understand how AIC works. I am using data from this tutorial: https://www.jaredknowles.com/journal/2013/11/25/getting-started-with-mixed-effect-models-in-r

library(lme4) # load library
library(arm) # convenience functions for regression in R
lmm.data <- read.table("http://bayes.acs.unt.edu:8083/BayesContent/class/Jon/R_SC/Module9/lmm.data.txt",
                       header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)

When fitting the first model we get this AIC:

MLexamp <- glm(extro ~ open + agree + social, data=lmm.data)
AIC(MLexamp)
[1] 8774.291

From my understanding, if I add a variable which is totally uncorrelated to the model, the AIC should compensate the overfitting to stay the same in mean, but it appears to correct more than that:

res.rand <- replicate(1000, {
  lmm.data$rand.cont <- rnorm(nrow(lmm.data))
  list(aic = AIC(glm(extro ~ open + agree + social + rand.cont, data=lmm.data )),
       adj.r2 = summary(lm(extro ~ open + agree + social + rand.cont, 
                           data=lmm.data))$adj.r.squared)
}, simplify=F)

mean(sapply(res.rand, "[[", "aic"))
[1] 8775.331

sd(sapply(res.rand, "[[", "aic"))
[1] 1.267697

The AIC is in mean 1 point higher than in the first model.

If I estimate adjusted R squared from lm, adding the uncorrelated variable has approximately no effect in mean:

OLSexamp <- lm(extro ~ open + agree + social, data = lmm.data)
summary(OLSexamp)$adj.r.squared
[1] -0.001984873

mean(sapply(res.rand, "[[", "adj.r2"))
[1] -0.00202206

sd(sapply(res.rand, "[[", "adj.r2"))
[1] 0.001057333

Can you figure out what I missed?

$\endgroup$

1 Answer 1

2
$\begingroup$

"From my understanding, if I add a variable which is totally uncorrelated to the model, the AIC should compensate the overfitting to stay the same in mean, but it appears to correct more than that:"

This is incorrect in multiple ways. AIC does not 'compensate' anything.

As you add more parameters to a model, its $R^2$ will increase. At some point, though, you will start to overfit your data, meaning the continued increase in $R^2$ is misleading (predictive performance on a holdout dataset gets worse beyond this point, even though the $R^2$ continues to increase). AIC is a tool that can be used to diagnose this misleading increase in model complexity. It is a number that quantifies relative model fit, and it works in part by penalising models for being more complex i.e. having more parameters. As long as an additional parameter adds some degree of explanatory/predictive power to the model, the AIC will improve (decrease) in spite of the parameter penalty.

And if you add an uncorrelated variable as a predictor, you are making the model more complex while adding essentially zero explanatory/predictive power to it. So the AIC gets worse (increases). Which is exactly what it is designed to do.

$\endgroup$
8
  • $\begingroup$ I meant it compensates overfitting in the sense of the formula $\mathit{AIC} = 2k - 2\ln(L)$: if one adds an uncorrelated random variable, log-likelihood will increase due to overfitting but not AIC thanks to the 2k penalty. In fact, adjusted $R^2$ does not increase after adding uncorrelated variables because it also corrects for overfitting. From my understanding, the difference between adjusted $R^2$ and AIC is that adjusted $R^2$ only represents the true information that is captured by the model, whereas AIC also penalizes for false information. $\endgroup$
    – Jean Paul
    Commented Sep 26, 2019 at 14:27
  • $\begingroup$ @JeanPaul "log-likelihood will increase due to overfitting but not AIC thanks to the 2k penalty". Yes, exactly. Your error is in the earlier quotation "AIC... [will] stay the same in mean, but it appears to correct more than that". It will not stay the same - it will get worse, and that is by design. If it stayed the same when you added an uncorrelated variable, there would be no use in AIC at all. $\endgroup$
    – mkt
    Commented Sep 26, 2019 at 14:59
  • $\begingroup$ @JeanPaul You are correct that adjusted $R^2$ also penalises models for complexity. However, this penalty is not very large and the claim that "...adjusted $R^2$ only represents the true information that is captured by the model" is not accurate. See this comment and the associated answer for more information. $\endgroup$
    – mkt
    Commented Sep 26, 2019 at 15:05
  • $\begingroup$ One limitation that I find for AIC compared to adjusted $R^2$ is that AIC is dependent on sample size in the sense that adding a variable with a very noisy but existent signal will not add useful information if the sample size is too small so the AIC will increase. But with a large enough sample size, the same variable will provide some useful information so the AIC will decrease. One does not have this issue for adjusted $R^2$: even with small sample sizes, it will be positive in mean and it will stay the same in mean when the sample size increases. $\endgroup$
    – Jean Paul
    Commented Sep 26, 2019 at 21:55
  • $\begingroup$ @JeanPaul If you wish to ask a question about comparing AIC and adjusted $R^2$, you are welcome to do so. I believe my present answer has addressed the question you posed. $\endgroup$
    – mkt
    Commented Sep 27, 2019 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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