Tutorials › Exam SRM - Statistics for Risk Modeling › Finding GLM Misfit in Residual Patterns

Exam SRM · GLM Modeling Cases · Tutorial 876 of 926

Finding GLM Misfit in Residual Patterns

Learn how to interpret residual plots for GLMs, identify patterns that may signal mean-structure or link misfit, and avoid treating one unusual residual as a trend.

Advanced 12 min read

What You'll Learn

  • Define Pearson and deviance residuals for common GLM outcomes
  • Interpret residual patterns against fitted values and predictors
  • Derive the geometric-mean pattern implied by a Poisson log-linear model
  • Distinguish systematic residual structure from one unusual observation
  • Explain why a residual pattern suggests misfit without identifying its cause uniquely
  • Avoid comparing raw residuals across observations with different fitted variances

Why Residual Patterns Matter

A GLM can produce plausible coefficient estimates and fitted values while still representing the mean response inadequately. Residual plots help reveal this problem: they show whether the model's errors appear structureless or instead vary systematically with fitted values or predictors. A repeated curve or trend is different evidence from one isolated large residual.

The aim is diagnosis, not automatic model selection. A pattern can suggest a missing nonlinear term, an inadequate link, or an omitted predictor, but a residual plot alone usually cannot determine which explanation is correct. The same caution applies to a pattern seen in a small sample: it is a reason to investigate, not proof of a particular defect. These diagnostic ideas are aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus.

Definition: For observation \(i\), let \(y_i\) be the observed response and \(\hat{\mu}_i\) its fitted mean under the GLM. A residual compares the observed response with that fitted mean. A residual pattern is a repeated, organized feature in residuals plotted against fitted values or predictors, such as a trend, curve, or sequence of runs above and below zero.

Residuals for Reading the Plots

The Pearson residual scales the response error by its model-based standard deviation. For a GLM with \(E(Y_i)=\mu_i\) and \(\operatorname{Var}(Y_i)=\phi V(\mu_i)\), its form is

$$ r_{P,i}=\frac{y_i-\hat{\mu}_i}{\sqrt{\hat{\phi}V(\hat{\mu}_i)}}. $$

Here \(V(\mu)\) is the variance function and \(\phi\) is the dispersion parameter. For Poisson and binomial models, the usual dispersion value is \(\phi=1\); for grouped binomial data with \(n_i\) trials and fitted success probability \(\hat p_i\), the fitted mean and variance are \(n_i\hat p_i\) and \(n_i\hat p_i(1-\hat p_i)\). The Pearson residual is therefore not generally the raw difference \(y_i-\hat{\mu}_i\).

The deviance residual uses the observation's contribution to deviance, with the sign of the response error. If \(d_i\) is that nonnegative contribution, then

$$ r_{D,i}=\operatorname{sign}(y_i-\hat{\mu}_i)\sqrt{d_i}. $$

For example, for a Poisson response, \(d_i=2\{y_i\log(y_i/\hat{\mu}_i)-(y_i-\hat{\mu}_i)\}\), with the term \(y_i\log(y_i/\hat{\mu}_i)\) defined as zero when \(y_i=0\). Pearson and deviance residuals scale errors in different ways, but both can be examined for systematic structure. The earlier material on choosing Pearson or deviance residuals addresses which residual is useful in a particular diagnostic setting.

Diagnostic benchmark: A satisfactory mean structure should usually leave residuals scattered on both sides of zero, without a sustained trend or curve against fitted values or a predictor. This is a qualitative benchmark, not a requirement that every residual be small or that every small sample look perfectly random.

Patterns Against Fitted Values and Predictors

A residual-versus-fitted plot asks whether the model's errors change as its predicted mean changes. A smooth curve, a consistent rise or fall, or long runs on one side of zero can indicate that the mean response has not been represented adequately. A residual-versus-predictor plot asks a more targeted question: does the model leave systematic error as a particular predictor changes?

The two plots complement each other. A curve against a predictor may point toward an omitted nonlinear effect of that predictor. A curve against fitted values shows that the error is related to the model's overall prediction, but may not identify which predictor is responsible. For a categorical predictor, compare residuals across its groups rather than treating category labels as a continuous numerical scale.

A pattern does not uniquely identify a link problem. For instance, curvature can result from an inappropriate link, a missing nonlinear predictor effect, an omitted interaction, or a predictor entered on an unsuitable scale. A trend can also reflect an incorrect offset or a data issue. Check the model specification and data construction before changing the link simply because a plot is not flat.

Why a Log-Linear Poisson Fit Has a Geometric Pattern

A useful consistency check follows directly from the Poisson log-link model. Suppose independent counts \(Y_i\) have means \(\mu_i=E_i\exp(\beta_0+\beta_1x_i)\), where \(E_i\) is exposure. If exposures are equal and \(x_i\) increases by one unit at a time, the ratio of successive means is constant.

$$ \frac{\mu_{i+1}}{\mu_i} = \frac{E\exp\{\beta_0+\beta_1(x_i+1)\}} {E\exp(\beta_0+\beta_1x_i)} =\exp(\beta_1). $$

Thus the means form a geometric sequence. This is a consequence of the stated model, not a general property of Poisson data. Unequal exposures change the ratio unless the exposure is accounted for, typically through an offset. The derivation is useful when checking whether a set of claimed fitted means could come from the specified model.

Worked Example: A Curved Pattern Under a Poisson Log Link

A hypothetical portfolio is divided into four risk-score groups, with scores \(x=0,1,2,3\) and equal exposure of one unit per group. A Poisson log-link model with predictor \(\beta_0+\beta_1x\) gives fitted expected counts \(8,12,18,27\). The observed counts are \(9,9,21,26\). Diagnose the residual pattern and check that the supplied fitted means are compatible with the model.

Method. First verify the model-implied means, then calculate Poisson Pearson residuals and inspect their signs and magnitudes against score. This avoids interpreting an impossible set of fitted means as evidence about residual misfit.

The successive fitted-mean ratios are \(12/8=1.5\), \(18/12=1.5\), and \(27/18=1.5\). They are compatible with a log-linear mean: \(\hat{\beta}_0=\log(8)\) and \(\hat{\beta}_1=\log(1.5)\). The model therefore gives \(\hat{\mu}_i=8(1.5)^{x_i}\).

For Poisson observations, \(r_{P,i}=(y_i-\hat{\mu}_i)/\sqrt{\hat{\mu}_i}\). The four calculations are \( (9-8)/\sqrt{8}=1/\sqrt{8}=0.354\); \( (9-12)/\sqrt{12}=-3/\sqrt{12}=-0.866\); \( (21-18)/\sqrt{18}=3/\sqrt{18}=0.707\); and \( (26-27)/\sqrt{27}=-1/\sqrt{27}=-0.192\). Residuals are rounded to three decimals.

The sequence is positive, negative, positive, negative. That repeated alternation may indicate that a straight-line predictor on the log-mean scale is missing structure, such as curvature. However, four groups provide limited evidence; the pattern is a diagnostic clue, not a conclusive test.

As a further consistency check, the observed-minus-fitted errors are \(1,-3,3,-1\). Their sum is \(1-3+3-1=0\), and their score-weighted sum is \(0(1)+1(-3)+2(3)+3(-1)=0\). These are the intercept and slope score conditions for a Poisson log-link fit with these predictors, so the supplied means and counts are consistent with a fitted model.

Common mistake avoided: The means \(8,12,18,27\) are geometric, as the model requires. Arbitrary increasing means need not be compatible with a log-linear predictor; a pattern assessment is meaningful only after the model and the stated fit are internally consistent.

Read the Pattern, Not Just the Largest Residual

The most informative feature is often the arrangement of residuals, not the single largest value. A sustained run on one side of zero can indicate bias over part of the predictor range. A curve that moves from positive to negative and back again can indicate that the modeled mean changes too simply. By contrast, one large residual surrounded by small residuals is unusual at that observation but does not, by itself, establish a systematic mean-structure problem.

Standardization matters when fitted means vary. In a Poisson model, the standard deviation is \(\sqrt{\mu_i}\), so the same raw error has a different scale at different means. For instance, a raw error of 5 at fitted mean 25 gives \(5/\sqrt{25}=1\), whereas a raw error of 10 at fitted mean 100 gives \(10/\sqrt{100}=1\). Comparing raw errors alone would make the second look twice as concerning, even though both Pearson residuals are one.

Worked Example: A Grouped-Binomial Residual Pattern

A hypothetical safety program records the number of successful inspections among 300 units in each of four risk-score groups, with \(x=0,1,2,3\). A logistic model gives fitted success probabilities \(0.20,1/3,0.50,2/3\); the observed success counts are \(63,91,159,197\). Calculate the grouped-binomial Pearson residuals and interpret the sequence.

Method. For each group use fitted mean \(n\hat p\) and variance \(n\hat p(1-\hat p)\). This avoids using a Poisson denominator for binomial data or treating the number of trials as irrelevant.

The fitted success counts are \(300(0.20)=60\), \(300(1/3)=100\), \(300(0.50)=150\), and \(300(2/3)=200\). The residual errors are therefore \(3,-9,9,-3\). The corresponding fitted variances are \(300(0.20)(0.80)=48\), \(300(1/3)(2/3)=200/3\), \(300(0.50)(0.50)=75\), and \(300(2/3)(1/3)=200/3\).

The residuals are \(3/\sqrt{48}=0.433\), \(-9/\sqrt{200/3}=-1.102\), \(9/\sqrt{75}=1.039\), and \(-3/\sqrt{200/3}=-0.367\). Values are rounded to three decimals.

The signs alternate across increasing scores. This suggests checking whether the success-probability mean is too simple for the score relationship, perhaps because the linear predictor misses curvature. It does not establish that the logit link is wrong: a different mean structure could create the same pattern.

For a fit check, the errors sum to \(3-9+9-3=0\), and their score-weighted sum is \(0(3)+1(-9)+2(9)+3(-3)=0\). These are the grouped-binomial logistic score conditions for an intercept and a linear score effect, confirming compatibility of the counts and fitted probabilities with the stated fit.

Common mistake avoided: A residual plot that alternates signs is evidence to investigate the mean relationship, not a direct instruction to replace the logit link. The plot does not isolate the cause.

Systematic Structure Versus One Unusual Observation

The following distinction is central. A sequence of residuals that changes in an organized way across a predictor or fitted-value range supports concern about systematic misfit. A single large residual is instead a localized discrepancy. It deserves checking for recording errors, an unusual response, or a feature not represented by the model, but it cannot establish a trend on its own. Conclusions are especially tentative when there are few observations or only one observation at an extreme predictor value.

A residual plot is also not a complete model check. The model's assumed response distribution and variance behavior matter; residuals can display changing spread even when their mean is approximately correct. Dependence, clustering, and incorrect exposure or denominator construction can also complicate interpretation. Separate those questions from a specific claim that the link or mean structure is wrong.

Worked Example: An Isolated Large Residual in an Audit Sample

A hypothetical Poisson model was fitted using an earlier sample. It is then used to predict independent audit counts, with fitted means \(10,20,40,80,160\) and observed counts \(10,20,42,78,200\), listed in increasing order of fitted mean. Determine whether these observations show a systematic residual pattern or one unusual discrepancy.

Method. Since these are independent audit observations, calculate their Poisson Pearson residuals using \(r_P=(y-\hat{\mu})/\sqrt{\hat{\mu}}\), then inspect the sequence. This avoids assuming that training-sample score conditions must hold in an independent audit sample.

The raw errors are \(0,0,2,-2,40\). The Pearson residuals are \(0/\sqrt{10}=0\), \(0/\sqrt{20}=0\), \(2/\sqrt{40}=0.316\), \(-2/\sqrt{80}=-0.224\), and \(40/\sqrt{160}=3.162\). The values are rounded to three decimals.

The first four residuals are close to zero, while the last is substantially positive. The evidence is for one unusual audit observation, not a sustained sequence of errors. The large residual merits investigation, but it is not sufficient by itself to conclude that the model has a systematic mean trend. Additional observations across the predictor range would help distinguish a recurring pattern from a single discrepancy.

Common mistake avoided: Calling the model's mean structure wrong solely because one residual is large overstates what the plot establishes. The observation is unusual relative to its fitted mean, but a pattern requires repeated structure.

A Practical Diagnostic Sequence

Use a consistent sequence rather than deciding from one point or one plot. The sequence below keeps attention on the question this diagnostic addresses: whether fitted means leave organized errors.

1
Confirm the response and fit.
Check the response type, fitted mean, link, predictors, and any exposure or trial denominator. A data-construction error can imitate model misfit.
2
Plot scaled residuals.
Use Pearson or deviance residuals against fitted values, then against important predictors. For categorical predictors, compare residual distributions by group.
3
Describe the repeated feature.
State whether there is a trend, curvature, long run on one side of zero, or only an isolated large residual. Avoid describing random scatter as a systematic pattern.
4
Form a limited diagnosis.
A pattern suggests a mean-structure or link concern, but does not identify its cause uniquely. Check plausible omitted predictors, functional forms, interactions, offsets, and data definitions before drawing a conclusion.

Common Diagnostic Traps

  • Comparing raw residuals at different fitted means. GLM response variances depend on the mean. Use a suitable scaled residual when comparing discrepancies.
  • Equating one large residual with a trend. An isolated point indicates a local discrepancy; systematic misfit is supported by repeated structure.
  • Declaring the link wrong from curvature alone. Curvature can reflect omitted nonlinear terms, omitted predictors, or other specification issues. The plot suggests investigation, not a unique repair.
  • Ignoring the predictor scale. A pattern against a predictor can be hidden when only residuals against fitted values are inspected. Check substantively important predictors as well.
  • Over-reading a small plot. A few observations can produce apparent runs or curves by chance. Describe uncertainty and avoid treating a visual clue as a formal proof.
Key takeaway: Look for repeated structure in appropriately scaled residuals against fitted values and predictors. A trend or curve suggests that the GLM mean may be inadequate; a lone large residual signals an unusual observation, not a systematic pattern by itself.

Check Your Understanding

For each problem, identify the diagnostic implication and check the calculation where requested.

  1. A Poisson log-link model has equal exposure, scores \(x=0,1,2,3\), and \(\hat{\mu}_0=12\), with slope coefficient \(\hat{\beta}_1=\log(1.25)\). Find the fitted mean at \(x=3\). (Answer: \(12(1.25)^3=23.4375\), or 23.44 to two decimals.)
  2. A Poisson observation has \(y=35\) and fitted mean \(\hat{\mu}=25\). Calculate its Pearson residual. (Answer: \((35-25)/\sqrt{25}=2.000\).)
  3. A grouped-binomial observation has \(n=200\), fitted probability \(\hat p=0.40\), and observed successes \(y=92\). Calculate its Pearson residual. (Answer: \((92-80)/\sqrt{200(0.40)(0.60)}=12/\sqrt{48}=1.732\), to three decimals.)
  4. As a predictor increases through five ordered groups, the residuals are \(-1.0,-0.8,0.0,0.9,1.1\). Is this more consistent with random scatter or a systematic feature, and what broad issue should be investigated? (Answer: A systematic increasing trend; investigate whether the mean structure or link leaves predictor-related error, without claiming the plot identifies a unique cause.)
  5. Residuals against fitted values are \(0.2,-0.1,0.1,-0.2,3.1\), with the last value from one observation and no other repeated pattern. What is the most defensible conclusion? (Answer: There is one unusual positive residual to investigate; these values alone do not demonstrate systematic mean-structure misfit.)
Clinical Biostats