Tutorials › Exam PA - Predictive Analytics › Cross-Model Residual Patterns as Specification Clues

Exam PA · Comparative Modeling and Diagnosis · Tutorial 927 of 966

Cross-Model Residual Patterns as Specification Clues

Use residuals on common validation data to find systematic structure that one model misses or that remains unresolved across models.

Advanced 11 min read

What You'll Learn

  • Define response residuals and Poisson Pearson residuals for model comparison
  • Compare observed and predicted outcomes within meaningful validation segments
  • Recognize nonlinear and interaction patterns that aggregate metrics can hide
  • Judge whether an ensemble reduces, preserves, or shifts a GLM’s residual structure
  • Separate diagnostic clues from proof of a particular model defect

Why Compare Residual Patterns?

Two models can have similar overall validation scores and still make errors in very different places. A GLM might systematically underpredict one range of a predictor and overpredict another, while an ensemble improves that pattern. Alternatively, both models may miss the same subgroup pattern even if one has a slightly lower average error. Comparing residuals across the same validation observations helps reveal these differences.

A residual pattern is a clue about specification, not a verdict. It can suggest that a model does not represent a nonlinear relationship, an interaction, or a subgroup difference. It does not by itself prove which feature should be added, establish a causal explanation, or guarantee that a more flexible model will perform better on new data. This diagnostic approach is aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Definition: For an observed response \(y_i\) and a prediction \(\hat{y}_i\), define the response residual as \(e_i=y_i-\hat{y}_i\). A positive residual means the model underpredicted that observation; a negative residual means it overpredicted. For a binary response \(y_i\in\{0,1\}\) with predicted event probability \(\hat{p}_i\), the response residual is \(e_i=y_i-\hat{p}_i\).

Residuals are most informative for model comparison when both models predict the same held-out observations, use the same response definition and units, and are assessed with the same weights or exposure basis where applicable. In practice, predictions can come from a validation set or be generated out of fold. If a model was fit using an observation, its in-sample residual may look artificially small; that makes it a weaker basis for comparing predictive error.

A Practical Comparison Method

Start with the signed residual, not only its absolute size. Then summarize residuals across groups chosen for a substantive reason: for example, ranges of a continuous predictor, combinations of categorical predictors, or exposure bands. A segment’s total residual can reveal a consistent direction of error even when individual residuals vary.

1
Align the comparison.
Use the same validation cases and outcome definition for every candidate model. Confirm that predictions are on a comparable scale, such as dollars, counts, or event probabilities.
2
Compute signed residuals.
For each case, subtract the model prediction from the observed response. Keep the sign; it identifies overprediction versus underprediction.
3
Summarize by diagnostic groups.
For each group, compare observed totals or averages with predicted totals or averages. Use exposure or other required weights consistently.
4
Compare the patterns, not just the totals.
Ask whether a model reduces a recurring positive or negative pattern, leaves it unchanged, or introduces a new one. Then consider plausible explanations and check them on data not used to select the model.

For an unweighted group \(G\) containing \(n_G\) observations, the mean residual has a direct interpretation:

$$ \bar e_G = \frac{1}{n_G}\sum_{i\in G}(y_i-\hat y_i) = \bar y_G-\overline{\hat y}_G. $$

This identity holds because the sum of the observed values minus the sum of the predictions is \(n_G\) times the difference between their averages. Therefore, a positive group mean residual is exactly an observed group average above its predicted average. For binary outcomes, the same calculation compares the observed event rate with the average predicted probability.

Worked Examples

Worked Example: A GLM Misses Curvature in Claim Severity

A hypothetical insurer compares a linear GLM with a boosted model for claim severity on the same 12 held-out claims. The cases are grouped by an ordered exposure measure. The table gives the observed severity total and each model’s predicted total within each group. Determine whether the residual pattern suggests a systematic difference between the models.

Exposure groupObserved totalGLM predicted totalBoosted predicted total
Low303330
Lower-middle484545
Upper-middle665766
High846984

Method. Calculate each group’s residual total as observed total minus predicted total, then divide by three cases to get the mean residual. This examines direction and scale of error by exposure group rather than relying on one overall score.

For the GLM, the residual totals from low to high are \(30-33=-3\), \(48-45=3\), \(66-57=9\), and \(84-69=15\). Each group has three cases, so the mean residuals are \(-3/3=-1\), \(3/3=1\), \(9/3=3\), and \(15/3=5\). The GLM changes from overprediction in the low group to increasing underprediction in the higher groups.

For the boosted model, the residual totals are \(30-30=0\), \(48-45=3\), \(66-66=0\), and \(84-84=0\). The corresponding mean residuals are \(0\), \(1\), \(0\), and \(0\). Its remaining positive pattern is confined to the lower-middle group rather than growing across the exposure range.

Check. The observed total is \(30+48+66+84=228\). The GLM predicted total is \(33+45+57+69=204\), giving total residual \(228-204=24\). The boosted total is \(30+45+66+84=225\), giving total residual \(228-225=3\). These totals agree with the sums of the group residuals. The pattern suggests that the GLM’s simple specification misses structure across the ordered exposure measure, while the boosted model reduces that pattern. It does not establish that curvature is the only explanation.

Common mistake avoided: Looking only at total error would conceal where the GLM fails. The signed residuals show that its underprediction is concentrated toward the higher exposure groups.

Worked Example: Main-Effects Classification Hides an Interaction

A hypothetical screening program evaluates an event model on four equally sized validation groups defined by two binary predictors, \(A\) and \(B\). Each group contains 100 people. A main-effects GLM predicts an event probability of \(0.20\) in every group; an ensemble gives group probabilities \(0.10, 0.30, 0.30, 0.10\) for \((A,B)=(0,0),(0,1),(1,0),(1,1)\), respectively. The observed event counts are \(10,30,30,10\). Compare the group residuals and the overall calibration.

Method. For each group, calculate observed event rate minus predicted probability. Equivalently, calculate observed events minus expected events, where expected events equal group size times predicted probability.

For the GLM, expected events are \(100(0.20)=20\) in each group. Its residual totals are \(10-20=-10\), \(30-20=10\), \(30-20=10\), and \(10-20=-10\). Dividing by 100 gives mean response residuals \(-0.10, 0.10, 0.10, -0.10\).

For the ensemble, expected events are \(100(0.10)=10\), \(100(0.30)=30\), \(100(0.30)=30\), and \(100(0.10)=10\). Its residual total in every group is zero, so each group’s mean residual is zero.

The GLM’s overall observed event count is \(10+30+30+10=80\). Its overall expected count is \(20+20+20+20=80\), so the total residual is zero. The ensemble also has total expected count \(10+30+30+10=80\). Thus, both models match the overall event rate of \(80/400=0.20\), but only the ensemble matches the four group rates in this example.

Check. The positive and negative GLM residual totals cancel: \(-10+10+10-10=0\). This verifies why an overall calibration check alone would miss the subgroup pattern. The alternating pattern is consistent with an interaction that the main-effects GLM does not represent; the ensemble predictions capture that pattern here.

Common mistake avoided: Do not infer that a model is well specified merely because total predicted events equal total observed events. Opposing segment errors can cancel exactly.

Worked Example: Exposure-Based Frequency Residuals After an Offset

A hypothetical portfolio’s claim counts are summarized in four mileage bands. Each band has exposure \(e_i=100\) policy-years. A Poisson GLM uses \(\log(e_i)\) as an offset, and a tree-based model is also evaluated on these same bands. The observed claim counts are \(8,12,20,30\); the GLM expected counts are \(10,14,18,22\); and the tree-based expected counts are \(9,12,20,27\). Calculate the signed and Pearson residuals and compare the patterns.

Assume the count \(N_i\), conditional on the predictors and exposure, follows a Poisson distribution with mean \(\mu_i\), so \(E[N_i]=\mu_i\) and \(\operatorname{Var}(N_i)=\mu_i\). The Pearson residual is \((N_i-\mu_i)/\sqrt{\mu_i}\). It standardizes the signed error using the model’s Poisson variance; it is a diagnostic scale, not a guarantee that the model is correct.

Method. First compute observed minus expected claims. Then divide each difference by the square root of the model’s expected count. Since all bands have equal exposure, the count comparisons are directly comparable across bands; the offset accounts for exposure in the GLM’s expected mean.

Mileage bandObservedGLM expectedGLM signed residualGLM Pearson residualTree expectedTree signed residualTree Pearson residual
1810-2-2/√10 = -0.6329-1-1/√9 = -0.333
21214-2-2/√14 = -0.5351200.000
3201822/√18 = 0.4712000.000
4302288/√22 = 1.7062733/√27 = 0.577

The GLM residuals shift from negative in the first two bands to positive in the last two, with the largest underprediction in band 4. The tree-based model reduces the signed residuals in every band, although it still underpredicts band 4 by three claims. For a count model with the stated assumptions, the displayed Pearson residuals use the expected counts as their variances; for example, the GLM value in band 4 is \(8/\sqrt{22}\), approximately \(1.706\).

Check. The observed total is \(8+12+20+30=70\). The GLM expected total is \(10+14+18+22=64\), so its residual total is \(6\). The tree-based expected total is \(9+12+20+27=68\), so its residual total is \(2\). These equal the sums of the signed residuals in the table. The residual pattern suggests improvement, but the remaining positive error in the highest band warrants further investigation.

Common mistake avoided: Comparing raw count errors across unequal exposures can be misleading. Here exposures are equal; in a general comparison, predictions and residual summaries must respect the exposure basis and any weights used in fitting.

Interpreting Patterns Without Overclaiming

A repeating pattern across a meaningful predictor is more informative than an isolated large residual. For example, a smooth progression from negative to positive residuals may suggest that a fitted relationship is too restrictive. Opposite residual directions across combinations of two factors may suggest an interaction. Residuals that remain concentrated in a particular group for both a GLM and an ensemble suggest that neither model has resolved that pattern, or that some other feature of the data or evaluation setup deserves checking.

These are specification clues, not automatic instructions to add variables. A pattern can arise from an omitted predictor, an inadequate functional form, a small or unusual validation segment, an outcome definition problem, or random variation. The candidate model should be checked with appropriate validation rather than chosen because it makes one diagnostic table look better. In particular, searching many possible groups and reporting only the most striking one can create a misleading impression of systematic error.

  • Preserve the residual sign. Absolute errors measure size but do not reveal consistent overprediction or underprediction.
  • Use comparable predictions and summaries. A count prediction, a rate, and a probability are not interchangeable.
  • Consider group size and uncertainty. A small segment can have a dramatic average residual based on very few observations.
  • Distinguish a local improvement from a general one. A model may fix one pattern while worsening another.
  • Do not read residual association as causation. A group pattern does not show that changing a predictor would change the outcome.
Key takeaway: Compare signed residuals from candidate models on the same validation cases, then examine their direction and size across defensible segments. A model that removes a recurring pattern has addressed a diagnostic weakness in that evaluation; whether the improvement generalizes still requires suitable validation evidence.

Check Your Understanding

For each problem, calculate the requested residual comparison before reading the final answer.

  1. A regression model predicts a group average of 42, while the observed average is 45 for 20 validation cases. What is the group mean residual and its sign? (Answer: \(45-42=3\), positive, so the model underpredicts by 3 on average.)
  2. In a validation group of 50 people, a binary model predicts probability \(0.12\) for every person and 9 events occur. Find the expected event count and the mean response residual. (Answer: Expected count \(50(0.12)=6\); mean residual \(9/50-0.12=0.06\), positive.)
  3. Two equally sized validation segments each contain 40 cases. A model has mean residual \(-2\) in the first and \(+2\) in the second. What is the overall mean residual, and what diagnostic warning follows? (Answer: Overall mean residual \((40(-2)+40(2))/80=0\); the overall average hides opposing segment errors.)
  4. Under a Poisson count model, a segment has observed count 18 and expected count 25. Calculate its signed residual and Pearson residual to three decimals. (Answer: Signed residual \(18-25=-7\); Pearson residual \(-7/\sqrt{25}=-1.400\).)
  5. For three equally sized validation groups, observed event rates are \(0.08, 0.20, 0.32\). A GLM predicts \(0.20\) in all three, while an ensemble predicts \(0.10,0.20,0.30\). Which model has the smaller sum of absolute group-rate residuals, and by how much? (Answer: GLM sum \(0.12+0+0.12=0.24\); ensemble sum \(0.02+0+0.02=0.04\); the ensemble is smaller by \(0.20\).)
Clinical Biostats