Tutorials › Generalized Linear Models › Residuals Versus Fitted Means

Detecting Overdispersion · Tutorial 663 of 981

Residuals Versus Fitted Means

Use Pearson and deviance residual plots against fitted means to distinguish ordinary discreteness from patterns that may indicate extra variation or a poorly calibrated mean.

Intermediate 11 min read

What You'll Learn

  • Define Pearson and signed deviance residuals for Poisson and binomial observations.
  • Interpret the center and vertical spread of residuals against fitted means.
  • Recognize curvature, clusters, and isolated residual patterns without treating them as automatic evidence.
  • Compare Pearson and deviance residuals when fitted means are small.
  • Account for unequal exposure and grouped binomial denominators when reading a plot.

Why Plot Residuals Against Fitted Means?

A dispersion ratio compresses many residuals into one number. A residual-versus-fitted-mean plot retains the observation-level detail: it can show whether departures from the fitted model are concentrated at particular mean levels, whether the residual center drifts, and whether a few observations dominate the pattern. For binomial and Poisson GLMs, this is useful because their prescribed variance changes with the mean.

For observation \(i\), let \(Y_i\) be the response and \(\hat{\mu}_i\) its fitted mean. In a Poisson model, \(\hat{\mu}_i\) is the fitted expected count. For grouped binomial data with \(m_i\) trials, it is the fitted expected number of successes, \(m_i\hat{p}_i\). The horizontal coordinate should be the fitted mean on the response scale, not the linear predictor or, when exposure varies, the fitted rate alone.

Residuals for Binomial and Poisson Fits

A Pearson residual measures the response's deviation from its fitted mean in units of the model's assumed standard deviation. For a Poisson observation, the variance is \(\mu_i\); for a grouped binomial observation, the variance is \(m_i p_i(1-p_i)\). The formulas below use fitted means and probabilities in the residuals.

Definition: For a Poisson response \(Y_i=y_i\) with fitted mean \(\hat{\mu}_i\), the Pearson residual is \(r_{P,i}=(y_i-\hat{\mu}_i)/\sqrt{\hat{\mu}_i}\). For grouped binomial data \(Y_i=y_i\) out of \(m_i\) trials, with fitted probability \(\hat{p}_i\) and fitted mean \(\hat{\mu}_i=m_i\hat{p}_i\), it is \(r_{P,i}=(y_i-\hat{\mu}_i)/\sqrt{m_i\hat{p}_i(1-\hat{p}_i)}\).

The signed deviance residual expresses the same departure using the observation's contribution to the residual deviance. Its sign is the sign of \(y_i-\hat{\mu}_i\). For zero counts or zero failures, terms of the form \(0\log(0/a)\) are defined as zero.

Definition: The Poisson deviance residual is \(r_{D,i}=\operatorname{sign}(y_i-\hat{\mu}_i)\sqrt{2\{y_i\log(y_i/\hat{\mu}_i)-(y_i-\hat{\mu}_i)\}}\). For grouped binomial data, it is \(r_{D,i}=\operatorname{sign}(y_i-m_i\hat{p}_i)\sqrt{2\{y_i\log[y_i/(m_i\hat{p}_i)]+(m_i-y_i)\log[(m_i-y_i)/(m_i(1-\hat{p}_i))]\}}\).

In either case, the square of a deviance residual is that observation's contribution to the residual deviance, and the sum of the squared residuals is the residual deviance. The Pearson residuals similarly satisfy \(\sum_i r_{P,i}^2=X^2\), the Pearson chi-square statistic. These identities explain why plotting individual residuals complements, rather than replaces, the aggregate dispersion checks.

Worked Example: Two Poisson Deviations

Suppose two Poisson observations have fitted means 2 and 4, and observed counts 0 and 2. Calculate both residual types for each point before considering their positions on the plot.

For \(y=0\), \(\hat{\mu}=2\), the Pearson residual is \(r_P=(0-2)/\sqrt{2}=-1.414\). The deviance residual has squared magnitude \(2\{0\log(0/2)-(0-2)\}=4\), so \(r_D=-\sqrt{4}=-2\).

For \(y=2\), \(\hat{\mu}=4\), the Pearson residual is \(r_P=(2-4)/\sqrt{4}=-1\). The squared deviance residual is \(2\{2\log(2/4)-(2-4)\}=2\{-1.3863+2\}=1.2274\), so \(r_D=-\sqrt{1.2274}\approx-1.108\).

The plotted coordinates are therefore \((2,-1.414)\) and \((4,-1)\) for Pearson residuals, or \((2,-2)\) and \((4,-1.108)\) for deviance residuals. The first observation looks more extreme on the deviance scale. With only two points, however, these calculations do not establish a systematic pattern.

What a Well-Calibrated Plot Looks Like

If the mean and variance specifications are appropriate, residuals should generally fluctuate on both sides of zero without a smooth trend in their center as fitted means change. Pearson residuals are divided by the standard deviation specified by the model. Thus, under the model, their scale is intended to be roughly comparable across fitted means. A persistent increase in their vertical spread can be a clue that the assumed variance is too small in some region; persistently narrow spread can suggest the reverse.

“Roughly” matters. Residuals use estimated parameters, so they are not independent observations with exactly the same distribution. The fitting process can also constrain or correlate residuals. Further, responses are discrete: at small Poisson means, for example, there are only a few possible counts, and a residual plot can look uneven even when the model is adequate. The plot is diagnostic evidence, not a formal test by itself.

Deviance and Pearson residual plots usually tell a similar broad story, but their individual values need not agree. At fitted means where observed values are close to expected values, their magnitudes are approximately equal. For more substantial departures, or near probability boundaries in binomial data, the scales can differ. Plotting both can help identify whether a visual conclusion depends heavily on the residual definition.

Result: At the true mean, a Pearson residual has expectation zero and variance one under a unit-dispersion Poisson or binomial model. If the true variance is \(\phi\) times the model variance, its variance is \(\phi\), provided the mean is correct.

Proof. First consider the residual with the true mean and probability, rather than fitted estimates. For Poisson data let \(R=(Y-\mu)/\sqrt{\mu}\). Since \(E[Y]=\operatorname{Var}(Y)=\mu\),

$$ E[R]=\frac{E[Y]-\mu}{\sqrt{\mu}}=0, \qquad \operatorname{Var}(R)=\frac{\operatorname{Var}(Y)}{\mu}=1. $$

For a binomial response with \(m\) trials and success probability \(p\), let \(R=(Y-mp)/\sqrt{mp(1-p)}\). The binomial mean and variance give

$$ E[R]=0, \qquad \operatorname{Var}(R)=\frac{mp(1-p)}{mp(1-p)}=1. $$

If the true variance in either case is \(\phi\) times the specified variance while the mean remains correct, the same calculation gives \(\operatorname{Var}(R)=\phi\). This is a statement about a residual standardized using the true mean. It does not say that residuals using estimated fitted means are exactly centered, independent, or unit variance. \(\square\)

Worked Example: A Grouped Binomial Point

A group has \(m=20\) trials, fitted success probability \(\hat{p}=0.20\), and observed successes \(y=8\). The fitted mean is \(\hat{\mu}=20(0.20)=4\), and the fitted variance is \(20(0.20)(0.80)=3.2\).

The Pearson residual is \(r_P=(8-4)/\sqrt{3.2}=4/1.7889\approx2.236\). For the deviance residual, the success and failure contributions give

$$ r_D^2 =2\left\{8\log(8/4)+12\log(12/16)\right\} =40\left\{0.4\log(2)+0.6\log(0.75)\right\} \approx4.186. $$

Because \(8-4\) is positive, \(r_D\approx+\sqrt{4.186}=2.046\). The point is plotted at fitted mean 4, above zero on both scales. Its sizable positive residual says that this group had more successes than expected under the fitted probability. It does not, on its own, say why.

Reading Shapes and Unusual Points

Read the plot by asking separate questions about its center, spread, and individual observations. A smooth curve in the residual center means that residuals tend to be positive at some fitted means and negative at others, or the reverse. That is a systematic pattern in the response scale that the fitted mean has not captured. The plot identifies the pattern; it does not by itself identify its cause.

Changing vertical spread is different from a shift in the center. A widening cloud of Pearson residuals as fitted means increase can suggest that the variance grows faster than the specified binomial or Poisson variance in that region. A narrowing cloud can suggest that it grows more slowly. Check whether the feature is supported by multiple observations: one large residual is not evidence of a general change in variance.

Clusters may appear as several points concentrated in a similar part of the plot, perhaps with similar signs or magnitudes. A cluster can be worth investigating, but a plot against fitted means alone does not reveal whether it corresponds to a particular predictor value or group. An isolated large residual may identify an observation whose response is poorly predicted; it may also arise from ordinary chance, especially with sparse or discrete data. Do not remove it solely because it looks unusual.

There is no universal residual cutoff that turns a visual feature into a diagnosis. Lines at plus or minus two can be used as rough visual reference points, not as guaranteed significance thresholds: the distribution of a residual depends on the family, fitted mean, and estimation. At small fitted means, asymmetry and discreteness deserve particular attention. Pearson residuals can be large in magnitude for a low-probability count, while deviance residuals can represent that departure differently.

Worked Example: Unequal Exposure and the Horizontal Axis

Suppose Poisson counts follow a rate model with fitted rate 2 events per unit of exposure. Two observations have exposures \(t_1=1\) and \(t_2=4\), with observed counts \(y_1=4\) and \(y_2=10\). Their fitted count means are \(\hat{\mu}_i=t_i(2)\), so \(\hat{\mu}_1=2\) and \(\hat{\mu}_2=8\).

The Pearson residuals for the counts are \(r_{P,1}=(4-2)/\sqrt{2}\approx1.414\) and \(r_{P,2}=(10-8)/\sqrt{8}\approx0.707\). The fitted means, not the common fitted rate, are the horizontal coordinates: the points are \((2,1.414)\) and \((8,0.707)\).

The observed rates are \(4/1=4\) and \(10/4=2.5\), respectively, but a residual plot for the count response uses expected counts that account for each exposure. Plotting both observations at fitted rate 2 would discard the exposure-related difference in their expected count means. This example also shows why a different horizontal position is not itself evidence of changing variance.

Result: Near the fitted mean, the squared deviance residual is approximately the squared Pearson residual for both Poisson and binomial observations.

Derivation. For a Poisson observation, write \(y=\mu+e\), with \(|e|/\mu\) small. Its squared deviance residual is \(2\{y\log(y/\mu)-(y-\mu)\}\). Treating this expression as a function of \(e\), expand \(\log(1+e/\mu)\) at zero: \(\log(1+e/\mu)=e/\mu-e^2/(2\mu^2)+O(|e|^3/\mu^3)\). Substitution and cancellation of the first-order terms yield

$$ r_D^2=\frac{e^2}{\mu}+O\left(\frac{|e|^3}{\mu^2}\right) =r_P^2+O\left(\frac{|e|^3}{\mu^2}\right). $$

For grouped binomial data, set \(q=y/m\) and \(p=\hat{p}\). The deviance is \(2m\{q\log(q/p)+(1-q)\log[(1-q)/(1-p)]\}\). As a function of \(q\), the quantity in braces is zero and has first derivative zero at \(q=p\); its second derivative there is \(1/[p(1-p)]\). If \(p\) stays away from 0 and 1 and \(q-p\) is small, Taylor expansion therefore gives

$$ r_D^2=\frac{m(q-p)^2}{p(1-p)}+O\{m|q-p|^3\} =\frac{(y-mp)^2}{mp(1-p)}+O\{m|q-p|^3\}. $$

The leading term is \(r_P^2\). This approximation explains why the plots can agree near zero, while not implying that their residuals are interchangeable for large departures or probabilities near the boundaries. \(\square\)

Common Mistakes

  • Reading every widening cloud as overdispersion. A visual change can be driven by a few points or by discreteness at low means. Look for a sustained pattern across observations and compare it with the model's mean-dependent variance.
  • Calling a curved residual center a variance pattern. A positive-to-negative drift concerns the residual center; changing vertical spread concerns variation. These are distinct features.
  • Using rates as the fitted means for unequal-exposure counts. The fitted mean count is exposure times the fitted rate. Use that expected count on the horizontal axis when the response is a count.
  • Treating one extreme residual as a reason to delete an observation. First verify the response, denominator or exposure, and model setup. An unusual point is a prompt for investigation, not an automatic exclusion.
  • Assuming fitted residuals are independent standard normal values. Standardization does not make discrete residuals normally distributed, and estimating model parameters affects their behavior.
Key takeaway: Plot Pearson or deviance residuals against fitted response means, then inspect the residual center, spread, clusters, and isolated points separately. The plot helps localize departures from the binomial or Poisson fit; it does not by itself establish their cause.

Check Your Understanding

Use the definitions and diagnostic distinctions above to answer these questions.

  1. For a Poisson observation with \(y=6\) and fitted mean \(\hat{\mu}=4\), calculate its Pearson residual and state whether it lies above or below zero.
  2. A grouped binomial observation has \(m=10\), fitted probability \(0.30\), and observed successes \(3\). What is its fitted mean and fitted variance?
  3. In a residual-versus-fitted-mean plot, the average residual appears to rise and then fall smoothly. What feature is present, and why is that different from changing vertical spread?
  4. Why should two Poisson counts with different exposures generally be plotted against their fitted expected counts rather than only against a common fitted rate?
  5. What does one large positive Pearson residual establish, and what does it not establish?
Clinical Biostats