Tutorials › Exam PA - Predictive Analytics › Using AIC to Balance Fit and Complexity

Exam PA · Model Comparison, Offsets, and Weights · Tutorial 365 of 966

Using AIC to Balance Fit and Complexity

Calculate AIC consistently and use its fit-versus-complexity trade-off to compare candidate GLMs without treating the smallest value as proof of a universally best model.

Advanced 11 min read

What You'll Learn

  • Calculate AIC from a maximized log-likelihood and the number of estimated parameters.
  • Count model parameters consistently, including an estimated dispersion parameter where appropriate.
  • Explain why the complexity penalty is twice the parameter count.
  • Compare AIC values and interpret their differences in the context of model fit.
  • Recognize likelihood, data, and interpretation traps when applying AIC.

Why AIC Balances Fit and Complexity

A more flexible generalized linear model (GLM) can often fit the observed data better simply because it has more parameters to estimate. AIC, the Akaike information criterion, puts a cost on that added flexibility: it rewards a higher maximized likelihood but penalizes the number of estimated parameters. The result is a single quantity for comparing candidate models fitted to the same response data under comparable likelihood conventions.

AIC is a relative selection criterion, not a test that a model is correct and not a direct measure of predictive accuracy on new observations. Its practical question is narrower: among the candidates being compared, which model offers the more favorable balance of in-sample fit and estimated complexity?

Definition: For a model with maximized log-likelihood \(\ell(\hat{\theta})\) and \(k\) estimated parameters, the Akaike information criterion is
$$ \operatorname{AIC}=-2\ell(\hat{\theta})+2k. $$
Here, \(\hat{\theta}\) denotes the maximum-likelihood estimates. When comparing applicable candidate models, the model with the smaller AIC is preferred by this criterion.

The first term measures lack of fit on a deviance-like scale: a larger maximized log-likelihood (less negative, in common GLM examples) makes \(-2\ell(\hat{\theta})\) smaller. The second term is the complexity penalty. Every additional estimated parameter adds 2 to AIC, so a more complex model needs enough likelihood improvement to offset that increase.

Counting Parameters and Comparing Like with Like

The value \(k\) is the number of freely estimated parameters in the likelihood being used. In a GLM, this normally includes the regression coefficients. If a dispersion parameter is estimated as part of the likelihood, it counts too. For standard binomial and Poisson likelihoods, dispersion is usually fixed by the distributional specification rather than estimated as an additional parameter. A known offset is not an estimated parameter; it is a fixed, known part of the model.

Parameter counting must match the likelihood calculation. Do not count an intercept twice, or count a fixed quantity as if it were estimated. Conversely, do not omit an estimated dispersion parameter merely because it is not a regression coefficient. If software reports the degrees of freedom of the fitted likelihood, check what that count includes before using it.

AIC comparisons require comparable likelihoods. In practice, candidate GLMs should be fitted to the same response observations, and the log-likelihoods must use consistent conventions for the response distribution and likelihood constants. A likelihood calculated on one subset of observations cannot be fairly compared with one calculated on a different subset. Nor should values based on incompatible likelihood definitions be treated as directly comparable.

Worked Example: Comparing Two Poisson Claim-Frequency Models

A hypothetical insurer fits two Poisson GLMs to the same policy records, with the same response definition and likelihood convention. Model A has maximized log-likelihood \(-128.4\) and \(k=3\) estimated parameters. Model B has maximized log-likelihood \(-124.9\) and \(k=5\). Calculate both AIC values and identify the model preferred by AIC.

Method. Apply \(\operatorname{AIC}=-2\ell(\hat{\theta})+2k\) to each model, using the stated parameter counts.

For Model A, the fit term is \[ -2(-128.4)=256.8, \] and the penalty is \[ 2(3)=6. \] Therefore, \[ \operatorname{AIC}_A=256.8+6=262.8. \]

For Model B, the fit term is \[ -2(-124.9)=249.8, \] and the penalty is \[ 2(5)=10. \] Therefore, \[ \operatorname{AIC}_B=249.8+10=259.8. \]

Comparison and check. Model B has the smaller AIC, by \(262.8-259.8=3.0\), so it is preferred among these candidates by AIC. Its log-likelihood improves by \(3.5\), reducing the fit term by \(2(3.5)=7.0\); its two additional parameters raise the penalty by \(2(2)=4.0\). The net AIC reduction is \(7.0-4.0=3.0\), agreeing with the direct calculation. This method avoids the common mistake of choosing the model with the better log-likelihood alone.

Why the Penalty Is \(2k\)

AIC is motivated by expected information loss. Suppose the data arise from an unknown distribution \(f\), while a candidate model uses a fitted distribution \(g_{\hat{\theta}}\). The Kullback–Leibler divergence from \(f\) to that fitted model is the expected value, under \(f\), of the log-density difference. The term involving \(f\) does not depend on which candidate is selected, so comparing expected information loss amounts to comparing the expected negative log-likelihood of future observations under each fitted model.

The maximized likelihood is evaluated on the same data used to estimate the parameters. That makes it optimistic as an estimate of performance on new data: the fitted parameters have, in effect, adapted to random features of the training sample. Under regularity conditions for maximum-likelihood estimation, the expected in-sample log-likelihood optimism is approximately \(k\) log-likelihood units. Since AIC uses negative twice the log-likelihood, the corresponding correction is approximately \(2k\) deviance units.

$$ \text{estimated future }(-2\ell) \ \approx\ \text{observed }(-2\ell)+2k \ =\ -2\ell(\hat{\theta})+2k. $$

This gives the AIC formula and explains its trade-off: improving fit lowers the first term, while estimating more parameters increases the correction for optimism. This is an asymptotic justification, not a guarantee that AIC identifies the true model in every finite sample. The usual interpretation relies on a regular likelihood-based setting, with identifiable parameters and a sufficiently informative sample.

Worked Example: Checking Whether Better Fit Pays for Complexity

Two candidate GLMs use the same response observations and likelihood convention. Model C has log-likelihood \(-86.2\) and \(k=4\). Model D has log-likelihood \(-83.6\) and \(k=6\). Calculate the AIC values, then explain how the fit improvement compares with the extra complexity.

For Model C, \[ -2(-86.2)=172.4,\qquad 2(4)=8, \] so \[ \operatorname{AIC}_C=172.4+8=180.4. \]

For Model D, \[ -2(-83.6)=167.2,\qquad 2(6)=12, \] so \[ \operatorname{AIC}_D=167.2+12=179.2. \]

Model D is preferred by AIC because \(179.2<180.4\), but the advantage is only \(180.4-179.2=1.2\). Its log-likelihood rises by \(2.6\), reducing \(-2\ell\) by \(2(2.6)=5.2\). The two extra parameters add \(2(2)=4.0\) to the penalty, leaving a net reduction of \(5.2-4.0=1.2\). This direct decomposition checks the result and avoids mistaking a better likelihood for an automatic AIC win.

Interpreting AIC Differences

AIC values are most useful as differences within a specified set of candidates. The absolute value alone does not say that a model fits well or poorly. For two models, define the difference as the second model’s AIC minus the smallest AIC in the candidate set. A positive difference means that model has the higher AIC; a difference of zero means a tie on this criterion.

A smaller value identifies the AIC-preferred candidate, but the size and context of the difference matter. A small gap indicates that the criterion gives little separation between the candidates; it does not establish that their practical predictions are identical. AIC also does not establish causation, validate the model assumptions, or account automatically for the consequences of a particular decision. Diagnostics and the purpose of the analysis remain important.

Worked Example: When Added Parameters Cancel the Fit Gain

A hypothetical analyst compares two GLMs fitted to the same observations. Model E has maximized log-likelihood \(-70.0\) and \(k=4\). Model F has maximized log-likelihood \(-67.0\) and \(k=7\). Calculate their AIC values and state what the tie means.

For Model E, \[ -2(-70.0)=140.0,\qquad 2(4)=8, \] so \[ \operatorname{AIC}_E=140.0+8=148.0. \]

For Model F, \[ -2(-67.0)=134.0,\qquad 2(7)=14, \] so \[ \operatorname{AIC}_F=134.0+14=148.0. \]

The AIC values tie. Model F’s log-likelihood improves by \(3.0\), reducing the fit term by \(6.0\); its three additional parameters increase the penalty by \(6.0\). The changes cancel exactly. Neither candidate is preferred over the other by AIC alone. The tie does not prove that the models are equivalent in every respect; it states only that this criterion gives them the same value. This calculation avoids the trap of assuming that a higher maximized likelihood must produce a lower AIC.

A Practical AIC Comparison

A careful calculation is straightforward, but the comparison is only meaningful if the inputs and interpretation are sound. Use the following sequence:

1
Confirm comparability.
Check that candidate models use the same response observations and a consistent likelihood basis.
2
Identify the maximized log-likelihood.
Use the fitted model’s log-likelihood, not an unmaximized value or a likelihood from a different data subset.
3
Count estimated parameters.
Include every parameter estimated in the likelihood, including an estimated dispersion parameter where applicable; exclude fixed known quantities.
4
Calculate and compare.
Compute \(-2\ell(\hat{\theta})+2k\) separately for each candidate. Prefer the smaller value by AIC, then describe the size of the difference without overstating its meaning.

The common errors are mechanical but consequential: dropping the negative sign in \(-2\ell\), using \(k\) instead of \(2k\), counting parameters inconsistently, or comparing log-likelihoods from different observation sets. A further interpretive error is to call the lowest-AIC model “the true model.” AIC selects relative to the candidates and the likelihood setup; it does not certify assumptions or replace judgment about the modeling objective.

Key takeaway: AIC equals minus twice the maximized log-likelihood plus twice the number of estimated parameters. Lower AIC indicates a better fit-complexity balance among comparable candidates, not proof of absolute model adequacy.

Check Your Understanding

For each problem, calculate the requested AIC value or comparison. Assume likelihood conventions and observations are comparable unless the problem states otherwise.

  1. A fitted GLM has maximized log-likelihood \(-41.7\) and \(k=2\). Calculate its AIC. (Answer: 87.4)
  2. Model G has log-likelihood \(-95.0\) and \(k=3\); Model H has log-likelihood \(-92.8\) and \(k=5\). Which has smaller AIC, and by how much? (Answer: Model H, by 0.4)
  3. Model J has log-likelihood \(-120.4\) and \(k=4\); Model K has log-likelihood \(-116.9\) and \(k=7\). Calculate both AIC values and identify the AIC-preferred model. (Answer: AIC\(_J=248.8\), AIC\(_K=247.8\); Model K by 1.0)
  4. Model L has log-likelihood \(-60.2\) and \(k=3\); Model M has log-likelihood \(-58.2\) and \(k=5\). Calculate both AIC values and interpret the result. (Answer: both AIC values are 126.4; they tie by AIC)
  5. Two candidates have AIC values 154.2 and 153.2. What is the AIC difference from the lower value to the higher value, and what does it establish? (Answer: 1.0; the lower-value candidate is preferred by AIC, but this alone does not establish model adequacy or practical equivalence.)
Clinical Biostats