Sub topic 6
Measuring Fit and Comparing Models: R-squared, Adjusted R-squared, AIC, and BIC
Assume you know simple linear regression, hypothesis tests, p-values, and the meaning of a slope and intercept. This chapter extends those ideas to choosing among multiple regression models.
What model fit measures
A regression model explains variation in a dependent variable using one or more independent variables. Fit measures summarize how closely the model's predictions match the observed values. They do not prove that the model is correctly specified or that the relationships are causal.
The main measures are:
| Measure | Main question | Preferred value |
|---|---|---|
| R-squared | What fraction of sample variation does the model explain? | Higher |
| Adjusted R-squared | How much variation is explained after penalizing extra variables? | Higher |
| AIC | How well does the model fit after penalizing complexity? | Lower |
| BIC | How well does the model fit after a stronger complexity penalty? | Lower |
R-squared
R-squared is the proportion of the sample variation in the dependent variable explained by the regression:
R-squared = 1 − SSE / SST
SSE is the sum of squared errors, and SST is the total sum of squared deviations from the sample mean. R-squared ranges from 0 to 1 in a regression with an intercept.
For example, an R-squared of 0.64 means that the independent variables explain 64% of the sample variation in the dependent variable. The remaining 36% is unexplained by the model.
R-squared never decreases when an additional independent variable is added. Even a variable unrelated to the dependent variable can slightly increase it. Therefore, R-squared alone is unsuitable for comparing models with different numbers of predictors.
Adjusted R-squared
Adjusted R-squared penalizes the model for adding independent variables:
Adjusted R-squared = 1 − [(n − 1) / (n − k − 1)] × (1 − R-squared)
Here, n is the sample size and k is the number of independent variables, excluding the intercept. An added variable increases adjusted R-squared only when its contribution is large enough to justify the loss of degrees of freedom.
A model can have a higher R-squared but a lower adjusted R-squared than another model. This suggests that the added variables improve in-sample fit but do not improve fit enough after accounting for model complexity.
AIC and BIC
The Akaike information criterion, or AIC, and the Bayesian information criterion, or BIC, combine model fit with a penalty for the number of estimated parameters. Their general form is:
- AIC = 2k_parameters − 2 ln(maximized likelihood)
- BIC = k_parameters ln(n) − 2 ln(maximized likelihood)
For ordinary least squares, software computes these values from the residuals and sample size. Compare AIC or BIC only across models estimated on the same dependent variable and observations.
Lower values are preferred. BIC applies a larger penalty than AIC when the sample is larger, so BIC usually favors a more parsimonious model. AIC may retain variables that provide modest predictive improvement.
import numpy as np
import statsmodels.api as sm
rng = np.random.default_rng(42)
n = 200
x1 = rng.normal(size=n)
x2 = rng.normal(size=n)
y = 1.0 + 2.0 * x1 - 1.0 * x2 + rng.normal(size=n)
X_full = sm.add_constant(np.column_stack([x1, x2]))
X_reduced = sm.add_constant(x1)
full = sm.OLS(y, X_full).fit()
reduced = sm.OLS(y, X_reduced).fit()
for name, model in [("Reduced", reduced), ("Full", full)]:
print(name)
print("R-squared:", round(model.rsquared, 4))
print("Adjusted R-squared:", round(model.rsquared_adj, 4))
print("AIC:", round(model.aic, 2))
print("BIC:", round(model.bic, 2))A comparison workflow
Use this sequence when comparing competing models:
- Confirm that the models use the same dependent variable and observations.
- Compare R-squared to describe in-sample explanatory power.
- Compare adjusted R-squared when the models contain different numbers of predictors.
- Compare AIC and BIC to balance fit and complexity.
- Check economic reasoning, statistical significance, and diagnostic tests before selecting a model.
A lower information criterion does not guarantee that a model has the correct functional form. A model with an omitted important variable can still have a favorable AIC or BIC.
Exercise
Model A has R-squared 0.70 and adjusted R-squared 0.66. Model B adds three variables and has R-squared 0.73 but adjusted R-squared 0.64. Which model has stronger adjusted fit, and what should you check before choosing it?
Show answer
Model A has stronger adjusted fit. Also compare AIC and BIC, examine the added variables' economic justification and coefficient tests, and inspect model diagnostics.