Tutorials › Regression Analysis (Undergraduate) › AIC for Gaussian Least-Squares Models

Information Criteria and Model Comparison · Tutorial 624 of 991

AIC for Gaussian Least-Squares Models

Learn how the Gaussian likelihood leads to an AIC expression in terms of sample size, residual sum of squares, and the model’s estimated parameters.

Advanced 10 min read

What You'll Learn

  • State the Gaussian regression assumptions used to obtain the AIC formula.
  • Derive the maximum-likelihood estimates of the regression coefficients and error variance.
  • Distinguish the variance estimate using RSS divided by n from the unbiased estimate.
  • Write the full and comparison-ready forms of Gaussian-regression AIC.
  • Count the regression coefficients and error variance in the AIC penalty.

From Gaussian Likelihood to a Regression Criterion

For a least-squares regression model with normally distributed errors, the residual sum of squares (RSS) summarizes how closely the fitted mean values match the observed responses. AIC combines this measure of fit with a penalty for the number of estimated parameters. Deriving the formula makes clear why both the sample size and the parameter count appear, and which version of the variance estimate belongs in the calculation.

The AIC definition is \( \mathrm{AIC}=-2\ell(\hat{\theta})+2K \), where \(\ell(\hat{\theta})\) is the maximized log-likelihood and \(K\) is the number of model parameters estimated by maximum likelihood. The penalty is applied to the likelihood evaluated at its maximum. For Gaussian least-squares regression, the likelihood can be written directly using the RSS.

Model and assumptions: For observations \(i=1,\ldots,n\), suppose \(Y_i=\mathbf{x}_i^\mathsf{T}\boldsymbol{\beta}+\varepsilon_i\), where the predictor values \(\mathbf{x}_i\) are treated as fixed (or the model is considered conditional on them). The errors are independent and \( \varepsilon_i\sim N(0,\sigma^2) \), with the same variance \(\sigma^2\) for every observation. The design matrix has full column rank. Write \(r\) for the number of regression coefficients in \(\boldsymbol{\beta}\), including the intercept if one is present. Assume the fitted RSS is positive. The likelihood then estimates \(r\) regression coefficients and one error variance, so \(K=r+1\).

These assumptions specify the likelihood being maximized. They do not require the predictors themselves to be normally distributed. In this model, the conditional mean of \(Y_i\) is \(\mathbf{x}_i^\mathsf{T}\boldsymbol{\beta}\), and the conditional variance is \(\sigma^2\).

Maximizing the Normal Likelihood

Let \(y_i\) be the observed response and define the residual sum of squares at a candidate coefficient vector \(\boldsymbol{\beta}\) as \( \mathrm{RSS}(\boldsymbol{\beta})=\sum_{i=1}^n(y_i-\mathbf{x}_i^\mathsf{T}\boldsymbol{\beta})^2 \). Independence gives a likelihood equal to the product of the \(n\) normal densities. Taking its logarithm gives:

$$ \ell(\boldsymbol{\beta},\sigma^2) =-\frac{n}{2}\log(2\pi)-\frac{n}{2}\log(\sigma^2) -\frac{\mathrm{RSS}(\boldsymbol{\beta})}{2\sigma^2}. $$

For any fixed positive \(\sigma^2\), the first two terms do not depend on \(\boldsymbol{\beta}\), and the last term decreases as the RSS increases. Thus the coefficient vector that maximizes the likelihood is the least-squares estimate \( \hat{\boldsymbol{\beta}} \), which minimizes the RSS. Write the resulting residual sum of squares as \( \mathrm{RSS}=\mathrm{RSS}(\hat{\boldsymbol{\beta}}) \).

Next, hold the coefficients at their maximum-likelihood values and maximize over the variance. Differentiating the log-likelihood with respect to \(\sigma^2\) and setting the derivative to zero gives:

$$ \frac{\partial \ell}{\partial \sigma^2} =-\frac{n}{2\sigma^2}+\frac{\mathrm{RSS}}{2(\sigma^2)^2}=0 \quad\Longrightarrow\quad \widehat{\sigma}^2_{\mathrm{MLE}}=\frac{\mathrm{RSS}}{n}. $$

This is the maximum-likelihood estimate of the error variance for the stated model. It is not the familiar unbiased estimate \( \mathrm{RSS}/(n-r) \). The unbiased estimate adjusts for fitting regression coefficients; the likelihood maximum uses \(n\) in the denominator. Substituting the maximum-likelihood estimates into the log-likelihood yields the key expression:

$$ \ell(\hat{\boldsymbol{\beta}},\widehat{\sigma}^2_{\mathrm{MLE}}) =-\frac{n}{2}\left[\log(2\pi)+1+\log\left(\frac{\mathrm{RSS}}{n}\right)\right]. $$

The \(1\) inside the brackets appears because \( \mathrm{RSS}/\widehat{\sigma}^2_{\mathrm{MLE}}=n \). Using the AIC definition and \(K=r+1\), the full Gaussian-regression expression is:

Theorem: Under the stated Gaussian regression model, with \(r\) regression coefficients and one estimated error variance,
$$ \mathrm{AIC} =n\left[\log(2\pi)+1+\log\left(\frac{\mathrm{RSS}}{n}\right)\right] +2(r+1). $$

The first term measures lack of fit through the maximized likelihood. The second term is the AIC penalty: two units for each estimated parameter, including the error variance. In this expression, \(\log\) is the natural logarithm.

Full AIC and the Comparison Form

When all candidate models use the same response observations and the same response scale, \(n[\log(2\pi)+1]\) is common to every model. Removing that common quantity does not change which model has the smaller AIC. It is therefore common to calculate a comparison-ready value:

$$ \mathrm{AIC}^{*} =n\log\left(\frac{\mathrm{RSS}}{n}\right)+2(r+1). $$

Here \( \mathrm{AIC}^{*} \) differs from full AIC by the same constant for every model in the comparison. The full AIC and the comparison form lead to the same differences between candidate models under these conditions. Use the full expression when an AIC value itself is required; use the reduced form when comparing models on the same observations and response scale.

Worked Example: Calculating Full AIC for a Simple Regression

Suppose a hypothetical Gaussian regression uses \(n=12\) observations. It has an intercept and one slope, so \(r=2\), and its fitted RSS is \(48\) squared response units. Calculate full AIC.

There are \(K=r+1=3\) estimated parameters: two regression coefficients and the error variance. The maximum-likelihood variance estimate is \(48/12=4\) squared response units. Substitute the sample size, RSS, and parameter count into the full expression:

$$ \begin{aligned} \mathrm{AIC} &=12\left[\log(2\pi)+1+\log\left(\frac{48}{12}\right)\right]+2(3)\\ &=12[1.837877+1+\log(4)]+6\\ &=12[1.837877+1+1.386294]+6\\ &\approx 56.69. \end{aligned} $$

The hypothetical model’s full AIC is approximately \(56.69\). This value is a criterion for comparisons, not a measure of the response in its original units.

Worked Example: Using the Comparison Form

A hypothetical regression has \(n=30\), an RSS of \(75\), and four regression coefficients, including its intercept. Calculate the comparison-form AIC.

The model estimates \(K=4+1=5\) parameters once the variance is included. Its mean squared residual, as used in the likelihood expression, is \(75/30=2.5\). Thus:

$$ \begin{aligned} \mathrm{AIC}^{*} &=30\log\left(\frac{75}{30}\right)+2(5)\\ &=30\log(2.5)+10\\ &=30(0.916291)+10\\ &\approx 37.49. \end{aligned} $$

This \(37.49\) is the comparison-form value, not full AIC: it omits \(30[\log(2\pi)+1]\), a constant shared by models with this same \(n\) and response. Using \(75/(30-4)\) in place of \(75/30\) would substitute an unbiased variance estimate for the maximum-likelihood estimate and would not give the Gaussian AIC formula derived here.

How the Parameter Penalty Works

The RSS term and the parameter penalty play different roles. A smaller RSS makes \( n\log(\mathrm{RSS}/n) \) smaller, improving the fit part of the criterion. A larger parameter count raises \(2K\), penalizing additional complexity. In the Gaussian regression expression, the variance contributes one parameter to every model in the comparison, while each additional regression coefficient contributes another.

The following calculation isolates the parameter penalty. Imagine two hypothetical fits to the same 16 responses. The first has an intercept only (\(r=1\)); the second has an intercept and two slopes (\(r=3\)). Suppose both fits have RSS \(24\), as can occur if the added coefficients do not reduce the residual sum of squares. This example focuses on the criterion arithmetic rather than on ranking models.

Worked Example: The Cost of Two Additional Coefficients

For both fits, \(n=16\) and \(\mathrm{RSS}/n=24/16=1.5\). The shared fit component in the comparison form is:

$$ 16\log(1.5)=16(0.405465)\approx 6.487. $$

The intercept-only model estimates \(K=1+1=2\) parameters, so its comparison-form value is:

$$ \mathrm{AIC}^{*}_{\text{intercept only}}=6.487+2(2)=10.49. $$

The model with two slopes estimates \(K=3+1=4\) parameters, so its value is:

$$ \mathrm{AIC}^{*}_{\text{two slopes}}=6.487+2(4)=14.49. $$

With identical RSS, the model with two additional regression coefficients has an AIC two units larger for each added coefficient, or four units in total. If the richer model reduced the RSS, its fit term would also change; the calculation here demonstrates only the penalty component.

Why the Exact Formula Matters

The derivation prevents several common calculation errors. The logarithm applies to the residual mean square \( \mathrm{RSS}/n \), not to the RSS alone. The variance estimate in the likelihood is \( \mathrm{RSS}/n \), not the unbiased estimate \( \mathrm{RSS}/(n-r) \). And the parameter count includes the estimated error variance as well as the regression coefficients.

AIC is meaningful as a relative model-selection criterion: a smaller AIC indicates a more favorable tradeoff between maximized likelihood and parameter count among the models being compared. It is not a hypothesis test, and the difference between AIC values is not a p-value. AIC also does not establish that a selected regression is correct; the candidate models and assumptions still need to be appropriate for the intended analysis.

Common pitfall: A student fits a regression with an intercept and two slopes, counts only the three regression coefficients, and uses \( \mathrm{RSS}/(n-3) \) in the formula. The correction is to use the Gaussian maximum-likelihood estimate \( \mathrm{RSS}/n \) and count \(K=3+1=4\) parameters, including the estimated error variance.

Check Your Understanding

Answer each question using the Gaussian-regression assumptions and formulas developed above.

  1. A model has an intercept and three slopes. How many parameters enter the AIC penalty when the error variance is estimated?
  2. Why does maximizing the normal likelihood over the regression coefficients produce the least-squares estimates?
  3. A regression has \(n=25\) and RSS \(=50\). What maximum-likelihood estimate of the error variance is used in the AIC derivation?
  4. Under what conditions can the common term \(n[\log(2\pi)+1]\) be omitted when comparing AIC values?
  5. If two fits have the same \(n\) and RSS, how does the comparison-form AIC change when one fit has one additional regression coefficient?