Why the Response Distribution Changes the Residual Plot
A residual is the difference between an observed response and its fitted mean, but the size of that difference cannot be interpreted without considering how response variability changes with the mean. For example, a residual of 100 may be ordinary for a response with a fitted mean of 1,000 and unexpectedly large for a response with a fitted mean of 100. A plot of unscaled residuals can therefore display a changing spread even when the assumed distribution is appropriate.
For a generalized linear model (GLM), the conditional mean is \(\mu_i=E[Y_i\mid\mathbf{x}_i]\), where \(\mathbf{x}_i\) denotes the predictors for observation \(i\). The response distribution specifies a variance function \(V(\mu_i)\), and, in many models, a dispersion parameter \(\phi\). A residual plot should be interpreted against this assumed mean-variance relationship. The calculations below use fitted means as known; fitted-model leverage can further affect residual variability, but is not the focus here.
The table summarizes common variance assumptions and the corresponding unit deviance contributions. For Poisson and negative binomial models, the displayed deviance contributions are on their likelihood scale; for Gamma, inverse Gaussian, and Tweedie models, \(d_i\) is the unit deviance and the scaled contribution is \(d_i/\phi\). The signed deviance residual is \(\operatorname{sign}(y_i-\mu_i)\sqrt{d_i}\) for Poisson and negative binomial, and \(\operatorname{sign}(y_i-\mu_i)\sqrt{d_i/\phi}\) for the other three families.
| Response distribution | Conditional variance | Unit deviance contribution |
|---|---|---|
| Poisson | \(\mu\) | \(2[y\log(y/\mu)-(y-\mu)]\) |
| Negative binomial NB2 | \(\mu+\alpha\mu^2\) | \(2[y\log(y/\mu)-(y+1/\alpha)\log((1+\alpha y)/(1+\alpha\mu))]\) |
| Gamma | \(\phi\mu^2\) | \(2[(y-\mu)/\mu-\log(y/\mu)]\) |
| Inverse Gaussian | \(\phi\mu^3\) | \((y-\mu)^2/(y\mu^2)\) |
| Tweedie, \(1<p<2\) | \(\phi\mu^p\) | \(2[y^{2-p}/((1-p)(2-p))-y\mu^{1-p}/(1-p)+\mu^{2-p}/(2-p)]\) |
In the Poisson expression, take \(y\log(y/\mu)=0\) when \(y=0\). The same zero convention applies to the \(y\log(y/\mu)\) term in the negative binomial deviance. The Tweedie expression at \(y=0\) is defined by its limit: \(d=2\mu^{2-p}/(2-p)\). The Gamma and inverse Gaussian expressions require positive responses. In the Tweedie model with \(1<p<2\), responses are nonnegative and the distribution can have both a point mass at zero and positive continuous values.
Why Pearson Residuals Account for Changing Variance
The response-scale residual is useful for describing errors in the units of the response, but its expected spread depends on the fitted mean. Pearson residuals divide by the standard deviation assumed at that mean. This does not make every set of residuals look exactly alike: finite samples, discrete outcomes, estimated parameters, and unusual observations can all matter. It does provide a scale on which large deviations are more comparable across fitted means.
This identity is a diagnostic reference, not a guarantee that residuals are normal or independent after fitting. A Poisson residual is also affected by discreteness, while a Tweedie residual may reflect the mixture of zero and positive outcomes. A family-appropriate plot is therefore read for systematic patterns and unusual departures, not against an expectation of perfect visual uniformity.
Worked Calculations by Response Family
Worked Example: Negative Binomial Residuals at a Higher Fitted Mean
A hypothetical claim-count model uses the NB2 distribution, with conditional variance \(\mu+\alpha\mu^2\). For one policy, the observed claim count is \(y=5\), the fitted mean is \(\mu=4\), and \(\alpha=0.25\). Calculate the Pearson and deviance residuals. Interpret their signs and identify the scale mistake that could occur if the model were treated as Poisson.
Method and assumptions. Use the NB2 variance and likelihood deviance, with \(1/\alpha=4\). The fitted mean and dispersion parameter are taken as given for this observation.
Pearson residual. The conditional variance is \[ \mu+\alpha\mu^2=4+0.25(4^2)=4+4=8. \] The observed-minus-fitted difference is \(5-4=1\), so \[ r_P=\frac{1}{\sqrt{8}}=0.3536. \]
Deviance residual. The NB2 contribution is \[ d=2\left[y\log(y/\mu)-(y+1/\alpha)\log\left(\frac{1+\alpha y}{1+\alpha\mu}\right)\right]. \] Substituting each value gives \[ \begin{aligned} d &=2\left[5\log(5/4)-9\log\left(\frac{1+0.25(5)}{1+0.25(4)}\right)\right]\\ &=2\left[5\log(1.25)-9\log(2.25/2)\right]\\ &=2[1.1157178-1.0600473]\\ &=0.1113409. \end{aligned} \] Thus \(r_D=+\sqrt{0.1113409}=+0.3337\). Both residuals are positive because the observed count exceeds the fitted mean. The positive sign does not, by itself, show that the model is wrong.
Check and trap avoided. The logarithm is \(\log(2.25/2)=\log(1.125)\approx0.1177830\), so \(9\log(1.125)\approx1.0600473\). Using an incorrect logarithm changes the deviance and its residual. Treating this observation as Poisson would also use variance \(4\), rather than the NB2 variance \(8\), and would give the wrong Pearson scale. The reported residuals are rounded to four decimals.
Worked Example: Gamma Residuals Across Two Fitted Means
A hypothetical severity model assumes positive Gamma responses with \(\operatorname{Var}(Y\mid\mathbf{x})=\phi\mu^2\), where \(\phi=0.25\). Two claims have fitted means of 500 and 1,000 dollars, and their observed severities are respectively 600 and 1,200 dollars. Calculate the response-scale, Pearson, and deviance residuals for both claims, and explain the difference in their response-scale spread.
Method and assumptions. The Gamma distribution is assumed for both positive responses, with the same dispersion parameter. For each claim, the observed severity is 1.2 times its fitted mean.
Claim 1, with \(\mu=500\) and \(y=600\). The response-scale residual is \(600-500=100\) dollars. The variance is \[ \phi\mu^2=0.25(500^2)=62{,}500, \] so the standard deviation is \(250\) dollars and \(r_P=100/250=0.4000\).
The Gamma unit deviance depends on the ratio \(y/\mu=1.2\): \[ d=2[(1.2-1)-\log(1.2)] =2[0.2-0.1823216] =0.0353568. \] The scaled deviance contribution is \(d/\phi=0.0353568/0.25=0.1414272\), so \(r_D=+\sqrt{0.1414272}=+0.3761\).
Claim 2, with \(\mu=1{,}000\) and \(y=1{,}200\). The response-scale residual is \(1{,}200-1{,}000=200\) dollars. The variance is \(0.25(1{,}000^2)=250{,}000\), giving a standard deviation of \(500\) dollars and \(r_P=200/500=0.4000\). Since \(y/\mu=1.2\) again, the unit deviance is \(0.0353568\), the scaled contribution is \(0.1414272\), and the deviance residual is \(+0.3761\).
Interpretation and check. The response-scale residual doubled from 100 to 200 dollars, while the Pearson and deviance residuals stayed the same. Under the Gamma variance assumption, standard deviation is proportional to \(\mu\), so equal proportional departures have equal residual scales. A plot of raw residuals may fan out with fitted mean for this reason alone. All residuals are rounded to four decimals.
Worked Example: Inverse Gaussian Residuals for a Positive Severity
A hypothetical specialty-repair severity model uses an inverse Gaussian response, with variance \(\phi\mu^3\). Amounts are measured in thousands of dollars. For one repair, \(y=3\), \(\mu=2\), and \(\phi=0.10\). Calculate the response-scale, Pearson, and deviance residuals, and explain which variance relationship is being used.
Method and assumptions. The response is positive, and the inverse Gaussian variance and unit deviance in the table apply. The dispersion parameter is 0.10.
The response-scale residual is \(3-2=1\) thousand dollars. The variance is \[ \phi\mu^3=0.10(2^3)=0.80, \] so the standard deviation is \(\sqrt{0.80}=0.8944\) thousand dollars. Therefore \[ r_P=\frac{1}{\sqrt{0.80}}=1.1180. \]
The inverse Gaussian unit deviance is \[ d=\frac{(y-\mu)^2}{y\mu^2} =\frac{(3-2)^2}{3(2^2)} =\frac{1}{12} =0.0833333. \] The scaled deviance contribution is \(d/\phi=0.0833333/0.10=0.8333333\). Since \(y>\mu\), the deviance residual is positive: \[ r_D=+\sqrt{0.8333333}=+0.9129. \]
Check and interpretation. Both residuals are positive, as required by the positive observed-minus-fitted difference. The variance used is proportional to the cube of the mean, not its square. The example’s Pearson residual is not required to equal its deviance residual: they are different transformations, even when both use the same response distribution. Values are rounded to four decimals.
Worked Example: Tweedie Residuals for Zero and Positive Claims
A hypothetical aggregate-claim model uses a Tweedie response with \(1<p<2\), \(p=1.5\), \(\phi=0.40\), and fitted mean \(\mu=4\). This parameter range permits both zero outcomes and positive continuous outcomes. Calculate Pearson and deviance residuals for one observation with \(y=0\) and another with \(y=9\).
Method and assumptions. Use \(\operatorname{Var}(Y\mid\mathbf{x})=\phi\mu^p\) and the Tweedie unit deviance, with the zero-response limit for \(y=0\). The displayed fitted mean, power, and dispersion are assumed for each observation.
For both observations, the variance is \[ 0.40(4^{1.5})=0.40(8)=3.2, \] so the standard deviation is \(\sqrt{3.2}=1.7889\).
For \(y=0\), the response-scale difference is \(-4\), giving \(r_P=-4/\sqrt{3.2}=-2.2361\). At \(p=1.5\), the zero-response unit deviance is \[ d=2\mu^{2-p}/(2-p)=2(4^{0.5})/0.5=2(2)/0.5=8. \] The scaled contribution is \(8/0.40=20\), so \(r_D=-\sqrt{20}=-4.4721\). The sign is negative because \(0<4\).
For \(y=9\), the response-scale difference is \(9-4=5\), giving \(r_P=5/\sqrt{3.2}=2.7951\). The Tweedie unit deviance at \(p=1.5\) simplifies to \[ d=2[-4\sqrt{y}+2y/\sqrt{\mu}+2\sqrt{\mu}]. \] Substitution gives \(d=2[-4(3)+2(9)/2+2(2)]=2[-12+9+4]=2\). The scaled contribution is \(2/0.40=5\), so \(r_D=+\sqrt{5}=+2.2361\).
Check and interpretation. The variance denominator is the same for both observations because their fitted means are the same. The zero and positive outcomes nevertheless have different deviance residuals because the Tweedie deviance reflects the full response distribution, not just the variance. Values are rounded to four decimals.
Reading Residual Plots Across Families
A residual-versus-fitted plot should be interpreted in light of the response’s variance function. Under a Poisson model, the standard deviation increases as \(\sqrt{\mu}\). Under NB2, it increases as \(\sqrt{\mu+\alpha\mu^2}\), which grows roughly in proportion to \(\mu\) when the quadratic term dominates. Gamma variability also grows in proportion to \(\mu\), while inverse Gaussian variability grows in proportion to \(\mu^{3/2}\). For Tweedie, the standard deviation grows in proportion to \(\mu^{p/2}\). These differences can make raw residual plots look quite different even when the respective assumptions are reasonable.
A family-aware residual plot uses Pearson or deviance residuals, often against fitted values or a rating variable. Ask whether residuals are broadly centered around zero and whether their scale is reasonably stable after the assumed variance has been taken into account. A trend or persistent imbalance can indicate that the model is not capturing some aspect of the data, but a residual plot alone does not identify the cause. In particular, do not interpret every widening of response-scale residuals as evidence of a defective model.
Identify whether the response is modeled as Poisson, NB2, Gamma, inverse Gaussian, or Tweedie. Check that the response values are compatible with that distribution.
Calculate or recognize the conditional variance at each fitted mean. Do not use a Poisson variance merely because the response is a count if the fitted model is NB2.
Use Pearson or deviance residuals to compare deviations after accounting for the modeled variance. Preserve the sign: positive means observed above fitted, and negative means observed below fitted.
Look for repeated structure or systematic imbalance rather than labeling one isolated large residual as proof of misfit. Consider sample size, dispersion estimation, and the discreteness or skewness of the response.
A frequent exam trap is to compare raw residual magnitudes across fitted means, or even across two different response families, as though they had a common natural scale. The correction is to use the variance assumption belonging to the fitted family, then interpret the resulting pattern with appropriate caution. A standardized scale improves comparability; it does not erase distributional features or make every residual plot have a perfect horizontal band.
Check Your Understanding
For each problem, use the stated family and dispersion convention. Round residuals to four decimals.
- A hypothetical Poisson frequency model has \(y=6\) and \(\mu=4\). Calculate the Pearson and deviance residuals. (Answer: \(r_P=1.0000,\ r_D=+0.9304\).)
- An NB2 model has \(y=5\), \(\mu=4\), and \(\alpha=0.25\). Calculate the Pearson and deviance residuals. (Answer: \(r_P=0.3536,\ r_D=+0.3337\).)
- A Gamma model has \(\phi=0.25\), \(y=1{,}200\), and \(\mu=1{,}000\) dollars. Calculate the Pearson and deviance residuals. (Answer: \(r_P=0.4000,\ r_D=+0.3761\).)
- An inverse Gaussian model, with response measured in thousands of dollars, has \(\phi=0.05\), \(y=1\), and \(\mu=2\). Calculate both residuals and state whether each is positive or negative. (Answer: \(r_P=-1.5811,\ r_D=-2.2361\).)
- A Tweedie model has \(p=1.5\), \(\phi=0.40\), \(\mu=4\), and \(y=9\). Calculate the Pearson and deviance residuals, and explain why the positive signs are expected. (Answer: \(r_P=+2.7951,\ r_D=+2.2361\); both are positive because \(y>\mu\).)