Tutorials › Exam SRM - Statistics for Risk Modeling › Outlier Screening With GLM Residuals

Exam SRM · Deviance and GLM Diagnostics · Tutorial 372 of 926

Outlier Screening With GLM Residuals

Use signed and standardized GLM residuals to identify unusual responses while keeping response outliers distinct from observations that affect fitted coefficients.

Advanced 10 min read

What You'll Learn

  • Compute signed Pearson and deviance residuals from fitted means and model variances
  • Apply standardization and interpret its approximate leverage adjustment
  • Compare residual evidence across observations with different fitted means
  • Recognize when a response is unusual relative to the fitted GLM
  • Explain why a large residual alone does not show that an observation changes fitted coefficients
  • Avoid treating screening thresholds as automatic deletion rules

Why Screen GLM Residuals?

A generalized linear model (GLM) does not generally have constant response variance. A raw difference between an observed response and its fitted mean can therefore be difficult to interpret: a difference of two may be substantial when the expected variance is small, but ordinary when the expected variance is large. Residual screening addresses this by measuring discrepancies relative to the model’s variance and, when appropriate, accounting approximately for the fact that the model parameters were estimated from the same observations.

A large residual is evidence that an observed response is unusual conditional on the fitted model. It is not, by itself, evidence that the observation strongly changes the fitted coefficients. These are separate questions: residuals measure response discrepancy, whereas coefficient influence concerns how the fitted model changes when an observation’s contribution is altered or removed.

Definition: For observation \(i\), let \(y_i\) be the observed response and \(\hat{\mu}_i\) its fitted mean. A Pearson residual expresses \(y_i-\hat{\mu}_i\) in units of the model-based standard deviation. A deviance residual expresses the observation’s contribution to deviance on a signed square-root scale. A standardized residual further adjusts the residual scale for parameter estimation; common GLM versions use an approximate leverage adjustment.

Signed Pearson and Deviance Residuals

Suppose observations are conditionally independent under a correctly specified GLM, with mean \(\mu_i\) and variance \(\operatorname{Var}(Y_i)=\phi V(\mu_i)/w_i\). Here \(V(\mu_i)\) is the variance function, \(\phi\) is the dispersion parameter, and \(w_i\) is a prior weight. The fitted values replace \(\mu_i\) by \(\hat{\mu}_i\). The Pearson residual is

$$ r_{Pi}=\frac{\sqrt{w_i}(y_i-\hat{\mu}_i)} {\sqrt{\hat{\phi}V(\hat{\mu}_i)}}. $$

Its sign is the sign of \(y_i-\hat{\mu}_i\): positive means the observed response exceeds its fitted mean, and negative means it falls below that mean. The denominator reflects the response variance expected under the model. In a Poisson model, \(V(\mu)=\mu\) and typically \(\phi=1\); in a binomial model for a count of \(m_i\) successes, the variance is \(m_i p_i(1-p_i)\).

The deviance residual uses the observation’s contribution \(D_i\) to the model deviance:

$$ r_{Di}=\operatorname{sign}(y_i-\hat{\mu}_i)\sqrt{D_i}. $$

For example, for a Poisson response with fitted mean \(\hat{\mu}_i\), the contribution is \(D_i=2[y_i\log(y_i/\hat{\mu}_i)-(y_i-\hat{\mu}_i)]\) when \(y_i>0\). When \(y_i=0\), the term \(y_i\log(y_i/\hat{\mu}_i)\) is defined as zero. For a binomial count \(y_i\) out of \(m_i\), fitted probability \(\hat{p}_i\), and fitted mean \(m_i\hat{p}_i\), the contribution is

$$ D_i=2\left[ y_i\log\left(\frac{y_i}{m_i\hat{p}_i}\right) +(m_i-y_i)\log\left(\frac{m_i-y_i}{m_i(1-\hat{p}_i)}\right) \right], $$

with zero-count terms interpreted by continuity. Both residual types retain direction and provide a scale for screening, but they need not have identical magnitudes. Pearson residuals use the variance function directly; deviance residuals use the observation’s likelihood-based contribution to deviance.

Why Standardize?

Residuals computed after fitting are not generally independent, unit-variance observations. Fitting the model uses the responses to estimate coefficients, which tends to reduce the residual variance for observations that have more influence on the fitted values. A commonly used approximate standardized residual divides a Pearson residual by \(\sqrt{1-h_{ii}}\), where \(h_{ii}\) is the observation’s diagonal leverage value from the fitted model. With dispersion included in the residual’s scale as above, the same adjustment is applied to a deviance residual as an approximation:

$$ r_{Pi}^{*}\approx\frac{r_{Pi}}{\sqrt{1-h_{ii}}}, \qquad r_{Di}^{*}\approx\frac{r_{Di}}{\sqrt{1-h_{ii}}}. $$

This is an approximate adjustment, not a claim that every standardized GLM residual has an exact standard normal distribution. Discrete responses, small samples, estimated dispersion, and model misspecification can all affect the reference distribution. The adjustment is meaningful when the fitted model and its variance assumptions are suitable; it does not repair a misspecified model.

The basic reason for the adjustment is that the variance of a fitted residual is reduced by fitting. In the familiar linear-model case, the residual vector is obtained by projecting the response away from the fitted subspace. Its \(i\)th residual variance is proportional to \(1-h_{ii}\). Dividing by the square root of that factor restores a more comparable variance scale. GLM standardization uses this idea as an approximation; calculating and interpreting the leverage values is a separate diagnostic task.

Worked Example: Screening a Poisson Count

A hypothetical policy-count model has Poisson responses, dispersion \(\phi=1\), and fitted mean \(\hat{\mu}_i=4\) for one policy. The observed count is \(y_i=9\), and model output gives \(h_{ii}=0.19\). Calculate the signed Pearson and deviance residuals, then their approximate standardized versions. Round final values to four decimals.

Method. Compute each signed residual from the fitted mean, then divide by \(\sqrt{1-h_{ii}}\). The Poisson variance function is \(V(\mu)=\mu\).

Pearson residual. The response difference is \(9-4=5\), and the fitted standard deviation is \(\sqrt{4}=2\). Thus \(r_{Pi}=5/2=2.5\), which is positive because the observed count is above the fitted mean.

Deviance residual. The contribution is \(D_i=2[9\log(9/4)-(9-4)]\). Since \(\log(9/4)=\log(2.25)\approx0.8109302\), this gives \(D_i=2[(9)(0.8109302)-5]=2(7.2983718-5)=4.5967436\). Therefore \(r_{Di}=+\sqrt{4.5967436}\approx2.1440\).

Standardization. The adjustment factor is \(\sqrt{1-0.19}=\sqrt{0.81}=0.9\). Hence \(r_{Pi}^{*}\approx2.5/0.9=2.7778\), and \(r_{Di}^{*}\approx2.1440/0.9=2.3822\).

Check and interpretation. Both residuals are positive, as required because \(9>4\). The standardized values are larger than the unstandardized values because the adjustment factor is below one. These values flag a response worth investigating; they do not establish that this policy materially changes the fitted coefficients. The mistake to avoid is calling the observation influential based on the residual alone.

Reading Residuals as Screening Evidence

A residual is a diagnostic signal, not a decision rule. Values with large absolute magnitude warrant attention, but no single cutoff is universally valid for every GLM, sample size, response distribution, and diagnostic purpose. As a rough screening convention, analysts often investigate standardized residuals with absolute values around 2 or larger, and give particular attention to values around 3 or larger. These are prompts for review, not formal tests that prove an observation is erroneous.

The sign matters as well as the magnitude. A large positive residual identifies a response larger than expected under the fitted model; a large negative residual identifies one smaller than expected. Comparing Pearson and deviance residuals can add context. A substantial difference between them may reflect the response distribution and the way deviance measures discrepancy, especially for discrete or highly asymmetric outcomes. It is a reason to inspect the observation and model assumptions, not a reason to choose whichever residual gives the preferred conclusion.

Screening should also account for the setting of the analysis. Check that the response was recorded correctly, that exposure and units are represented correctly, and that the observation is being compared with an appropriate fitted mean. An unusual residual can arise from data error, a rare but valid response, an omitted feature of the mean model, or a variance assumption that does not suit the data. The residual alone cannot determine which explanation is correct.

Worked Example: Why a Raw Binomial Difference Can Mislead

A hypothetical renewal study models the number of renewals among \(m_i=20\) eligible customers as binomial, with fitted probability \(\hat{p}_i=0.20\). For one group, \(y_i=12\) renew. The dispersion is \(\phi=1\), and the fitted model reports \(h_{ii}=0.10\). Calculate the Pearson and deviance residuals and their approximate standardized values. Round final values to four decimals.

Method. The fitted count is \(20(0.20)=4\), and the binomial variance is \(20(0.20)(0.80)=3.2\).

Pearson residual. The raw difference is \(12-4=8\), so \(r_{Pi}=8/\sqrt{3.2}=8/1.7888544\approx4.4721\). The standardized value is \(4.4721/\sqrt{0.90}=4.4721/0.9486833\approx4.7140\).

Deviance residual. The observed non-renewal count is \(20-12=8\). Therefore, \(D_i=2[12\log(12/4)+8\log(8/16)]\) \(=2[12\log(3)+8\log(0.5)]\). Using \(\log(3)\approx1.0986123\) and \(\log(0.5)\approx-0.6931472\), \(D_i=2[(13.1833476)-(5.5451776)]=15.2763400\). Thus \(r_{Di}=+\sqrt{15.2763400}\approx3.9085\), and \(r_{Di}^{*}\approx3.9085/0.9486833=4.1199\).

Check and interpretation. Both residuals are positive, consistent with 12 observed renewals exceeding the fitted count of 4. Both standardized magnitudes are large enough to merit investigation. The raw difference of 8 alone would not show how surprising the count is; the model variance supplies the relevant scale. Nor do these residuals alone show whether the group changes fitted coefficients substantially.

Response Outliers Are Not Automatically Influential

A response outlier is unusual relative to the fitted conditional response distribution. A coefficient-influential observation is one whose presence or contribution materially affects coefficient estimates or fitted conclusions. Large residual magnitude can be one ingredient in influence, but it is not sufficient: the observation’s predictor configuration and its relationship to the rest of the data also matter.

Consequently, residual screening answers a limited question: does this response look unusual given the fitted mean and variance? It does not answer whether the model’s coefficients would change substantially under a case-deletion comparison. That requires a separate influence assessment. Conversely, a moderate residual does not guarantee negligible influence. Keep these conclusions distinct when reporting diagnostics.

Worked Example: Interpreting a Large Residual Without Overclaiming

A hypothetical Poisson model for weekly equipment failures has \(\hat{\mu}_i=1\), \(\phi=1\), and \(h_{ii}=0.19\) for one week. The observed count is \(y_i=5\). A reviewer says, “This week has a large positive standardized residual, so it must be driving the fitted coefficients.” Assess the residual evidence and correct the conclusion. Round final values to four decimals.

Pearson residual. The response difference is \(5-1=4\), and the fitted standard deviation is \(\sqrt{1}=1\). Thus \(r_{Pi}=4\), and \(r_{Pi}^{*}\approx4/\sqrt{0.81}=4/0.9=4.4444\).

Deviance residual. The Poisson contribution is \(D_i=2[5\log(5/1)-(5-1)]\). Since \(\log(5)\approx1.6094379\), \(D_i=2[(5)(1.6094379)-4]=2(8.0471895-4)=8.0943790\). Thus \(r_{Di}=+\sqrt{8.0943790}\approx2.8451\), and \(r_{Di}^{*}\approx2.8451/0.9=3.1612\).

Correction. The positive standardized residuals indicate a response substantially above the fitted mean, so this week merits data and model review. The reviewer’s conclusion about coefficient influence does not follow: the residuals describe the response discrepancy, not the change in coefficients attributable to the observation. A separate influence assessment is needed to support that claim.

Check. Both residual signs are positive because \(5>1\), and standardization increases both magnitudes because \(h_{ii}=0.19\). The values therefore support “unusual response under the fitted model,” not “proven coefficient-driving observation.”

Common Mistakes in Residual Screening

  • Comparing raw errors across different means. The same response difference can represent very different evidence when the model-based variances differ. Use a residual scaled to the GLM variance.
  • Ignoring direction. The sign distinguishes observations above and below their fitted means. Do not report only a magnitude when direction matters.
  • Treating an approximate standardized residual as an exact normal score. Discrete responses and model estimation affect its distribution. Screening thresholds are heuristics unless a suitable formal reference distribution has been established.
  • Declaring influence from a large residual. A large residual signals response discrepancy. It does not by itself establish a substantial change in fitted coefficients.
  • Deleting a flagged observation automatically. First check data quality, model specification, and whether the response is a plausible rare event. Removing a valid observation merely because it is inconvenient can distort the analysis.
Key takeaway: Signed Pearson and deviance residuals measure response discrepancies on scales suited to the fitted GLM; approximate standardization improves comparability after fitting. Use large magnitudes to identify cases for investigation, but keep response outlier evidence separate from evidence that an observation affects fitted coefficients.

Check Your Understanding

For each problem, interpret residual evidence carefully. Unless stated otherwise, use dispersion \(\phi=1\), and round numerical answers to four decimals.

  1. A Poisson GLM gives \(y_i=0\), \(\hat{\mu}_i=2\), and \(h_{ii}=0.19\). Find the standardized Pearson and deviance residuals, including their signs. (Answer: \(r_{Pi}^{*}=-1.5713\), \(r_{Di}^{*}=-2.2222\).)
  2. A binomial observation has \(m_i=10\), \(y_i=9\), fitted probability \(\hat{p}_i=0.50\), and \(h_{ii}=0\). Find the Pearson and deviance residuals. (Answer: \(r_{Pi}=2.5298\), \(r_{Di}\approx2.7132\), both positive.)
  3. A Poisson observation has \(y_i=6\), \(\hat{\mu}_i=3\), and \(h_{ii}=0.36\). Find its standardized Pearson residual and state whether the response is above or below its fitted mean. (Answer: \(r_{Pi}^{*}=2.1651\); the response is above the fitted mean.)
  4. A Bernoulli response has \(y_i=0\), fitted probability \(\hat{p}_i=0.05\), and \(h_{ii}=0.19\). Calculate the standardized Pearson residual. Does its magnitude alone suggest an unusual response? (Answer: \(r_{Pi}^{*}\approx-0.2549\); no, its magnitude is small.)
  5. A GLM output shows one observation with a standardized deviance residual of \(-3.2\). What does the sign indicate, and what additional conclusion cannot be made from this residual alone? (Answer: The response is below its fitted mean and is unusual enough to investigate; the residual alone does not establish that the observation materially affects fitted coefficients.)
Clinical Biostats