Tutorials › CAS Exam 8 - Advanced Ratemaking › Common Errors in GLM Residual Analysis

CAS Exam 8 · Residuals and Goodness of Fit · Tutorial 240 of 989

Common Errors in GLM Residual Analysis

Use the response distribution, fitted variance, exposure, and leverage to interpret residual diagnostics correctly and avoid common GLM screening errors.

Intermediate 10 min read

What You'll Learn

  • Distinguish raw, Pearson, and deviance residuals and identify what each measures
  • Compare residuals only after accounting for their response scale and fitted variance
  • Interpret frequency residuals consistently when exposure differs across observations
  • Separate an unusual residual from an influential observation
  • Check residual calculations and avoid misleading diagnostic conclusions

Why Residual Errors Matter

A residual is a discrepancy between an observed response and the response predicted by a fitted model. But that discrepancy is not automatically comparable across observations, response distributions, or exposure amounts. A raw difference of 3 could be substantial for a count with fitted mean 4 and negligible for a count with fitted mean 100. A residual of $500 could be large or small depending on the variability of the modeled severity.

Residual analysis is useful only when the residual is interpreted on the scale appropriate to the model. This tutorial focuses on frequent errors in that interpretation: comparing incompatible scales, ignoring fitted variance, mistaking residual magnitude for influence, and overlooking exposure. These checks complement the earlier material on Pearson and deviance goodness of fit, dispersion, and leverage.

Definition: For response \(Y_i\) and fitted mean \(\hat{\mu}_i\), the raw residual is \(e_i=y_i-\hat{\mu}_i\). In a GLM with \(\operatorname{Var}(Y_i)=\phi V(\mu_i)/w_i\), where \(\phi\) is the dispersion parameter and \(w_i\) is a prior weight, the Pearson residual is $$ r_{Pi}=\frac{y_i-\hat{\mu}_i}{\sqrt{\hat{\phi}V(\hat{\mu}_i)/w_i}}. $$ It expresses the raw difference in units of its estimated standard deviation. The deviance residual is the signed square root of that observation’s contribution to the model deviance. Its exact contribution depends on the response distribution.

A standardized residual is a diagnostic, not a proof that an observation is well modeled. Even Pearson residuals can be only approximately unit variance after parameters have been estimated; fitted values, leverage, dispersion estimation, and the response distribution affect their interpretation. Compare like with like, inspect patterns as well as individual values, and use the residual definition that matches the model.

Do Not Compare Raw Residuals as Though They Share a Scale

The raw residual retains the response’s units: counts for a count model, dollars for a severity model, and so on. It is useful for describing the direction and absolute size of an error in those units, but it does not account for the variability expected at the fitted mean. The Pearson residual makes that adjustment using the model’s variance function. The deviance residual provides a likelihood-based discrepancy whose contribution is defined by the assumed response distribution.

For a Poisson response, the variance equals the mean, so observations with different fitted means have different residual standard deviations. A common Poisson deviance residual is $$ r_{Di}=\operatorname{sign}(y_i-\hat{\mu}_i) \sqrt{2\left[y_i\log\left(\frac{y_i}{\hat{\mu}_i}\right)-(y_i-\hat{\mu}_i)\right]}, $$ with \(y_i\log(y_i/\hat{\mu}_i)=0\) when \(y_i=0\). This definition assumes a Poisson response; it should not be applied unchanged to another response distribution.

Worked Example: Equal Raw Errors, Different Poisson Evidence

A hypothetical claim-count model assumes independent Poisson responses. Two rating cells have observed and fitted counts of 8 and 5 in cell A, and 103 and 100 in cell B. Calculate their raw and Pearson residuals, then compare their Poisson deviance residuals. Use the Poisson variance assumption \(\operatorname{Var}(Y_i)=\mu_i\).

Method. Calculate each raw residual as \(y_i-\hat{\mu}_i\), then divide it by \(\sqrt{\hat{\mu}_i}\) for the Pearson residual. For the deviance residual, use the Poisson formula above.

Cell A. The raw residual is \(8-5=3\). The fitted standard deviation is \(\sqrt{5}=2.2361\), so the Pearson residual is \(3/2.2361=1.3416\). For the deviance residual, \(\log(8/5)=\log(1.6)=0.4700\). Thus the deviance contribution is \(2[8(0.4700)-3]=2(0.7600)=1.5200\), and \(r_{DA}=\sqrt{1.5200}=1.2329\).

Cell B. The raw residual is \(103-100=3\). The fitted standard deviation is \(\sqrt{100}=10\), so the Pearson residual is \(3/10=0.3000\). Since \(\log(103/100)=\log(1.03)=0.0296\), the deviance contribution is \(2[103(0.0296)-3]\), or more precisely \(2[103(0.0295588)-3]=0.0891\). Therefore \(r_{DB}=\sqrt{0.0891}=0.2985\).

Check and trap avoided. Both raw residuals equal 3, but the standardized residuals do not: the same count difference is much less surprising relative to a fitted count of 100 than to a fitted count of 5. Treating the raw residuals as equally concerning would ignore the Poisson variance. Values are rounded to four decimals.

Keep the Response Distribution and Fitted Variance in View

The denominator of a Pearson residual is not a generic standard deviation. It comes from the assumed conditional variance of the response. For example, a Poisson model has \(V(\mu)=\mu\), while a binomial response with \(n_i\) trials and success probability \(\pi_i\) has variance \(n_i\pi_i(1-\pi_i)\). A Gaussian model with constant variance uses a different variance structure. Consequently, residual magnitudes from different families are not automatically comparable, even if their raw differences happen to be numerically similar.

A GLM may also estimate a dispersion parameter. If \(\hat{\phi}\ne 1\), omitting it changes the Pearson residual’s scale. Do not insert a dispersion adjustment without checking the model’s variance specification, and do not interpret a Pearson residual computed with one convention as though it used another. For example, a Poisson model conventionally fixes \(\phi=1\); an estimated dispersion adjustment is a different modeling choice.

Worked Example: Raw Differences Across Two Response Scales

A hypothetical portfolio analysis produces two fitted responses. For a claim-severity observation, assume a Gaussian model with fitted mean $5,000 and known standard deviation $1,000; the observed severity is $5,500. For a claim-count observation, assume a Poisson model with fitted mean 4; the observed count is 7. Calculate the raw and Pearson residuals for both, and explain why the raw residuals cannot be compared directly.

Severity. The raw residual is \(5{,}500-5{,}000=\$500\). Under the stated Gaussian variance assumption, the fitted standard deviation is $1,000, so the Pearson residual is \(500/1{,}000=0.5000\).

Frequency. The raw residual is \(7-4=3\) claims. For a Poisson response, the fitted standard deviation is \(\sqrt{4}=2\), so the Pearson residual is \(3/2=1.5000\).

Check and trap avoided. The raw values, $500 and 3 claims, have different units and cannot be ranked as measures of unusualness. On their respective fitted-variance scales, the count residual is larger: 1.5000 versus 0.5000. This comparison is illustrative rather than a formal comparison of model fit, because the responses come from different distributions. The calculation assumes the stated standard deviation is the severity model’s conditional standard deviation and rounds to four decimals.

Exposure Changes the Precision of Frequency Residuals

For a frequency model with exposure \(e_i\), a standard Poisson formulation is $$ N_i\sim\operatorname{Poisson}(e_i\lambda_i),\qquad \log E[N_i]=\log(e_i)+\boldsymbol{x}_i^\mathsf{T}\boldsymbol{\beta}. $$ Here \(N_i\) is the count, \(\lambda_i\) is the expected frequency per exposure unit, and \(\log(e_i)\) is an offset. The count’s fitted mean is \(\hat{\mu}_i=e_i\hat{\lambda}_i\); its Poisson variance is also \(e_i\hat{\lambda}_i\). A rate residual and a count residual are different raw quantities, but the Pearson residual can be written consistently on either scale: $$ \frac{N_i-e_i\hat{\lambda}_i}{\sqrt{e_i\hat{\lambda}_i}} = \frac{N_i/e_i-\hat{\lambda}_i}{\sqrt{\hat{\lambda}_i/e_i}}. $$ This equality holds for \(e_i>0\) under the stated Poisson frequency model. The rate-scale residual’s standard deviation shrinks as exposure increases, because a rate based on more exposure is more precise under the model.

Important distinction: An offset accounts for exposure in the fitted mean; it does not make all raw count residuals comparable. Under the Poisson model, exposure also affects the variance through the fitted count mean. A residual calculation that uses a rate but ignores its exposure-dependent variance loses that distinction.

Worked Example: Same Observed Rate, Different Exposure

A hypothetical Poisson frequency model estimates \(\hat{\lambda}=0.10\) claims per exposure unit for each of two cells. Cell A has exposure \(e_A=10\) and zero claims; cell B has exposure \(e_B=100\) and zero claims. Calculate the fitted count, raw count residual, observed-rate residual, and Pearson residual for each cell.

Cell A. The fitted count is \(10(0.10)=1\), and the raw count residual is \(0-1=-1\). The observed rate is \(0/10=0\), so its rate residual is \(0-0.10=-0.10\). The Pearson residual is \((-1)/\sqrt{1}=-1.0000\).

Cell B. The fitted count is \(100(0.10)=10\), and the raw count residual is \(0-10=-10\). The observed rate is \(0/100=0\), so its rate residual is again \(0-0.10=-0.10\). The Pearson residual is \((-10)/\sqrt{10}=-3.1623\).

Check and trap avoided. Both cells have the same raw rate residual, but the larger-exposure cell provides more evidence against the fitted frequency: its Pearson residual has greater magnitude. Comparing the raw count residuals, \(-1\) and \(-10\), is also misleading because the counts were observed over different exposures. The result follows from the assumed Poisson model and uses four decimal places for Pearson residuals.

A Large Residual Is Not the Same as Influence

A residual describes how far an observation’s response is from its fitted value under a particular fit. Influence describes how much the fitted model or its predictions would change if that observation were removed or otherwise perturbed. These are related but distinct questions. A large residual can occur at a covariate pattern that is common in the data and has little leverage. Conversely, an observation with a less striking residual may occupy an unusual predictor position and substantially affect the fitted coefficients.

Leverage summarizes how unusual an observation’s predictor configuration is relative to the fitted model. Influence diagnostics combine information about discrepancy and leverage; they are not interchangeable with raw residual rankings. In GLMs, a commonly used approximate Cook’s distance for screening is $$ D_i\approx \frac{r_{Pi}^2h_{ii}}{p(1-h_{ii})^2}, $$ where \(r_{Pi}\) is a Pearson residual, \(h_{ii}\) is the observation’s leverage, and \(p\) is the number of fitted regression parameters. This approximation is not a universal exact formula for every GLM or software convention. A large value flags a case for investigation; it does not establish that the observation is erroneous or that the model should be refitted without it.

Worked Example: Ranking Approximate Influence Rather Than Raw Residuals

A hypothetical GLM has \(p=3\) fitted regression parameters. Two observations have Pearson residuals and leverages as follows: observation A has \(r_{PA}=2.5\) and \(h_{AA}=0.02\); observation B has \(r_{PB}=1.2\) and \(h_{BB}=0.35\). Use the stated approximate Cook’s distance formula to compare their screening values.

Observation A. The numerator is \(2.5^2(0.02)=6.25(0.02)=0.125\). The denominator is \(3(1-0.02)^2=3(0.98^2)=3(0.9604)=2.8812\). Therefore \(D_A\approx0.125/2.8812=0.0434\).

Observation B. The numerator is \(1.2^2(0.35)=1.44(0.35)=0.504\). The denominator is \(3(1-0.35)^2=3(0.65^2)=3(0.4225)=1.2675\). Therefore \(D_B\approx0.504/1.2675=0.3976\).

Check and trap avoided. Observation A has the larger Pearson residual, but observation B has the larger approximate Cook’s distance: \(0.3976>0.0434\). Ranking influence by residual size alone would therefore give the wrong screening conclusion. Because this is a GLM approximation, the values are prompts for further investigation, not universal cutoffs. Values are rounded to four decimals.

A Practical Sequence for Checking Residuals

Before interpreting a residual plot or singling out an observation, establish what each plotted quantity represents. This short sequence prevents many avoidable errors.

1
Identify the response and its distribution.
Confirm whether the modeled response is a count, rate, severity, proportion, or another quantity. The response determines the units and variance structure.
2
Confirm the fitted mean and variance.
Use the model’s stated variance function, dispersion, and weights to calculate a standardized residual. Do not assume a constant variance across observations.
3
Check exposure and the analysis unit.
For frequency, distinguish the claim count from the rate per exposure unit, and verify that exposure has entered the model appropriately.
4
Separate discrepancy from influence.
Use residuals to assess response discrepancy and leverage or influence diagnostics to assess the effect on the fitted model. Investigate influential cases in context rather than deleting them automatically.

The most common exam trap is to select the largest raw residual and call it the most serious observation. That conclusion may fail because the response scales differ, the fitted variances differ, exposure differs, or the observation has little influence on the fitted model. A defensible interpretation names the residual type, states the relevant variance or exposure assumption, and distinguishes unusual response behavior from model influence.

Check Your Understanding

For each problem, identify the scale or diagnostic that is relevant before interpreting the result.

  1. A Poisson model has fitted mean 16 for a cell with observed count 22. Calculate the raw and Pearson residuals. (Answer: Raw residual \(=6\); Pearson residual \(=6/\sqrt{16}=1.5000\).)
  2. A Poisson frequency model has fitted frequency \(0.08\), exposure 25, and observed count 0. Find the fitted count, raw rate residual, and Pearson residual. (Answer: Fitted count \(=25(0.08)=2\); raw rate residual \(=0-0.08=-0.08\); Pearson residual \(=(0-2)/\sqrt{2}=-1.4142\).)
  3. A Gaussian severity model has fitted mean $60 and conditional variance \(144\). An observation is $72. Find its raw and Pearson residuals. (Answer: Raw residual \(=\$12\); standard deviation \(=\sqrt{144}=\$12\); Pearson residual \(=1.0000\).)
  4. For a Poisson observation, \(y=4\) and \(\hat{\mu}=1\). Calculate its signed deviance residual using the Poisson definition. (Answer: \(r_D=+\sqrt{2[4\log(4)-3]}=+\sqrt{5.0904}=2.2562\).)
  5. A GLM has \(p=4\). An observation has Pearson residual \(2\) and leverage \(0.25\). Calculate its approximate Cook’s distance using the screening formula in this tutorial. (Answer: \(D\approx[2^2(0.25)]/[4(0.75^2)]=1/2.25=0.4444\).)
Clinical Biostats