Tutorials › Generalized Linear Models › Deviance-Based Dispersion Estimates

Quasi-Binomial and Quasi-Poisson · Tutorial 702 of 981

Deviance-Based Dispersion Estimates

Calculate and interpret the deviance-based dispersion estimate, and see how it differs from the Pearson estimate in quasi-binomial and quasi-Poisson fits.

Intermediate 11 min read

What You'll Learn

  • Define residual deviance and the deviance-based dispersion estimate
  • Calculate Poisson and grouped-binomial deviance contributions
  • Compare deviance-based and Pearson-based dispersion estimates
  • Understand when deviance is locally close to the Pearson statistic
  • Recognize why residual deviance divided by residual degrees of freedom is an estimate, not an exact identity

Why Use Deviance to Estimate Dispersion?

In a quasi-binomial or quasi-Poisson model, the conditional variance is allowed to be a dispersion parameter \(\phi\) times a specified variance function. A common estimate of \(\phi\) uses the Pearson statistic divided by residual degrees of freedom. Another option uses the model's residual deviance in the same way. The two estimates often tell a similar story, but their numerators measure lack of fit differently, so they need not agree.

This tutorial defines the deviance-based estimate, works through both count and grouped-binomial examples, and explains why deviance and Pearson residuals are closely related when fitted residuals are small. In quasi-likelihood, deviance is a useful measure derived from the variance function; it should not be mistaken for a likelihood-ratio test.

Residual Deviance and Its Scale Estimate

Definition: For observations \(y_1,\ldots,y_n\) and fitted means \(\hat{\mu}_1,\ldots,\hat{\mu}_n\), the residual deviance is $$ D_{\mathrm{res}}=\sum_{i=1}^n d(y_i,\hat{\mu}_i), $$ where \(d(y_i,\hat{\mu}_i)\) is the observation's unit deviance. The deviance-based dispersion estimate is $$ \hat{\phi}_D=\frac{D_{\mathrm{res}}}{\nu}, $$ where \(\nu\) is the residual degrees of freedom. In the usual unweighted GLM with \(n\) rows and a full-rank design matrix with \(p\) fitted regression coefficients, \(\nu=n-p\).

For grouped binomial data, a row is a group of trials and its unit deviance uses that group's success count and trial total. Thus \(n\) counts the modeled rows, not the individual Bernoulli trials within those rows. A saturated fit has zero residual deviance; if \(\nu=0\), the ratio defining \(\hat{\phi}_D\) is unavailable.

For the Poisson and grouped-binomial variance functions, the unit deviances are as follows. When a count is zero, the convention \(0\log 0=0\) is understood; endpoint terms in the binomial expression are interpreted by continuity.

$$ d_{\mathrm{Pois}}(y,\mu)=2\left[y\log\left(\frac{y}{\mu}\right)-(y-\mu)\right], \qquad d_{\mathrm{Bin}}(y,\mu)=2\left[ y\log\left(\frac{y}{\mu}\right) +(m-y)\log\left(\frac{m-y}{m-\mu}\right) \right], $$

In the binomial expression, \(y\) is the number of successes, \(m\) is the number of trials, and \(\mu=mp\) is the fitted mean number of successes. These formulas also arise as ordinary likelihood deviances for the corresponding binomial and Poisson models. In a quasi-likelihood analysis, however, a scaled deviance is not automatically a likelihood-ratio test.

Deriving the Unit Deviance and Its Local Approximation

For these variance functions, the unit deviance has an integral representation. This representation explains both its nonnegativity and its relationship to the Pearson statistic. For a Poisson observation, let \(V(\mu)=\mu\); for a binomial count with \(m\) trials, let \(V(\mu)=\mu(1-\mu/m)\). In either case, for an interior mean and an observed value in the allowable range, define

$$ d(y,\mu)=2\int_{\mu}^{y}\frac{y-t}{V(t)}\,dt. $$

The integral is nonnegative whether \(y\) is above or below \(\mu\): when \(y<\mu\), both the direction of integration and the sign of \(y-t\) reverse. To verify that this gives the stated formulas, differentiate with respect to \(y\). For Poisson, the derivative of half the integral representation is \(\int_\mu^y dt/t=\log(y/\mu)\). For binomial, \(\int_\mu^y dt/[t(1-t/m)] = \log(y/\mu)-\log((m-y)/(m-\mu))\). These are the derivatives with respect to \(y\) of the respective half-deviances. Both expressions vanish at \(y=\mu\), so integration establishes the formulas, including endpoints by continuity. This proves the integral representation. \(\square\)

The representation also gives a precise local comparison with Pearson's statistic. If \(V\) is positive and continuously differentiable on an interval containing \(y\) and \(\mu\), and \(1/V\) has derivative bounded in absolute value by \(M\) there, then

$$ \left|d(y,\mu)-\frac{(y-\mu)^2}{V(\mu)}\right| \leq \frac{M}{3}|y-\mu|^3. $$

To prove this bound, write \(g(t)=1/V(t)\) and \(\delta=y-\mu\). The mean value theorem gives \(|g(t)-g(\mu)|\leq M|t-\mu|\). Subtracting \(2g(\mu)\int_\mu^y(y-t)\,dt=g(\mu)\delta^2\) from the integral for \(d\), and taking absolute values, bounds the difference by

$$ 2M\int_0^{|\delta|}(|\delta|-s)s\,ds =\frac{M}{3}|\delta|^3. $$

Thus deviance agrees with the Pearson squared residual to second order when the residual is small relative to the local scale of the variance function. This is a local approximation, not an identity for arbitrary observations.

Worked Examples

Worked Example: Poisson Intercept-Only Fit

Suppose four independent Poisson counts are \(1,2,3,6\), and an intercept-only model is fitted. Its common fitted mean is the sample mean: \(\hat{\mu}=(1+2+3+6)/4=3\). There is one fitted coefficient, so \(\nu=4-1=3\).

The individual Poisson deviance contributions are

$$ \begin{aligned} d(1,3)&=2[\log(1/3)+2]\approx1.802776,\\ d(2,3)&=2[2\log(2/3)+1]\approx0.378140,\\ d(3,3)&=0,\\ d(6,3)&=2[6\log 2-3]\approx2.317766. \end{aligned} $$

Adding them gives \(D_{\mathrm{res}}\approx4.498682\), and therefore \(\hat{\phi}_D=4.498682/3\approx1.499561\). For comparison, the Pearson statistic is

$$ X_P^2=\sum_{i=1}^4\frac{(y_i-\hat{\mu})^2}{\hat{\mu}} =\frac{4+1+0+9}{3}=\frac{14}{3}\approx4.666667, \qquad \hat{\phi}_P=\frac{X_P^2}{3}\approx1.555556. $$

Both estimates are above one, but they are not equal: the largest count's deviance contribution is \(2.317766\), whereas its Pearson contribution is \(9/3=3\). Deviance and Pearson residuals weight departures differently away from the fitted mean.

Worked Example: Grouped Binomial Model With a Common Success Probability

Two groups each have \(m=10\) trials, with observed success counts \(2\) and \(8\). Fit a common success probability. The estimated probability is \(\hat{p}=(2+8)/20=0.5\), so each fitted success count is \(\hat{\mu}=10(0.5)=5\). There are two rows and one fitted coefficient, hence \(\nu=1\).

For the first group, the deviance contribution is

$$ \begin{aligned} d(2,5) &=2\left[2\log(2/5)+8\log(8/5)\right]\\ &=2\left[2(-0.916290732)+8(0.470003629)\right]\\ &\approx3.854895. \end{aligned} $$

The second group gives the same contribution, with successes and failures interchanged. Therefore \(D_{\mathrm{res}}\approx7.709790\) and \(\hat{\phi}_D=7.709790/1\approx7.709790\). For the Pearson calculation, each group has fitted variance \(m\hat{p}(1-\hat{p})=10(0.5)(0.5)=2.5\). Each observed count differs from its fitted count by \(3\), so

$$ X_P^2=\frac{(2-5)^2}{2.5}+\frac{(8-5)^2}{2.5} =3.6+3.6=7.2, \qquad \hat{\phi}_P=\frac{7.2}{1}=7.2. $$

The estimates differ even though the example is symmetric. The deviance-based estimate is about \(7.709790\), while the Pearson-based estimate is \(7.2\); the difference reflects the distinct measures of residual size, not a different fitted probability.

Worked Example: A Zero Count in a Poisson Fit

Consider counts \(0,2,4\) in an intercept-only Poisson model. The fitted mean is \(\hat{\mu}=(0+2+4)/3=2\), and the residual degrees of freedom are \(3-1=2\). For the zero count, use the convention \(0\log(0/2)=0\):

$$ d(0,2)=2[0-(0-2)]=4. $$

For the other observations,

$$ d(2,2)=0,\qquad d(4,2)=2[4\log 2-(4-2)] =2[2.772589-2]\approx1.545177. $$

Consequently, \(D_{\mathrm{res}}\approx4+0+1.545177=5.545177\), giving \(\hat{\phi}_D=5.545177/2\approx2.772589\). The Pearson statistic and its estimate are

$$ X_P^2=\frac{(0-2)^2+(2-2)^2+(4-2)^2}{2} =\frac{4+0+4}{2}=4, \qquad \hat{\phi}_P=\frac{4}{2}=2. $$

The zero observation contributes \(4\) to the deviance and \(2\) to the Pearson statistic. The zero-count convention makes the deviance finite and straightforward to calculate; it does not make the two residual measures interchangeable.

How to Interpret the Estimate

The ratio \(\hat{\phi}_D=D_{\mathrm{res}}/\nu\) is used as a scale estimate because, in a well-fitting model, residual deviance is often on the order of the residual degrees of freedom when the scale is near one. If the variance is inflated by \(\phi\), this motivates looking for residual deviance on the order of \(\phi\nu\). The local approximation above explains why that reasoning resembles the Pearson-based approach when individual residuals are modest.

It does not imply that \(D_{\mathrm{res}}/\nu\) is exactly unbiased for \(\phi\), or that it must equal the Pearson estimate in a finite sample. The fitted means are estimated, the deviance is not generally a sum of independent squared standard normal variables, and larger residuals make the higher-order differences relevant. A substantial discrepancy between \(\hat{\phi}_D\) and \(\hat{\phi}_P\) is a reason to inspect the fitted values and residual contributions, not a reason to choose whichever estimate is more convenient.

The two estimates share the same denominator when the same fit and residual degrees of freedom are used. Their comparison is therefore especially transparent: it is the difference between the residual deviance and Pearson statistic that drives the difference in the scale estimates. The deviance-based estimate is a practical alternative, not a replacement for checking whether the mean and variance structure are scientifically sensible.

Common Mistakes

  • Calling deviance divided by degrees of freedom an exact identity. It is an estimate motivated by residual behavior, not a theorem that the ratio equals the true dispersion.
  • Using the number of individual trials for grouped data's residual degrees of freedom. In grouped-binomial GLMs, count the fitted rows and subtract the number of fitted regression coefficients under the usual full-rank setup.
  • Substituting the Pearson statistic for deviance. They are related locally, but their contributions differ for finite residuals; calculate the requested statistic from its own formula.
  • Treating a quasi-model's scaled deviance as a likelihood-ratio test. A quasi-likelihood model does not in general provide a full probability likelihood from which that interpretation follows.
Key takeaway: Calculate each unit deviance from the appropriate variance-function model, sum the contributions, and divide by residual degrees of freedom. Compare the result with the Pearson estimate while remembering that the two statistics agree only approximately in suitable local conditions.

Check Your Understanding

Use the definitions and examples above to answer these questions.

  1. For a grouped-binomial model with four rows and two fitted regression coefficients, what residual degrees of freedom are used under the usual full-rank setup?
  2. Why does a zero observed Poisson count have a finite deviance contribution?
  3. In what sense are a unit deviance and the corresponding Pearson squared residual close when the fitted residual is small?
  4. For the counts \(0,2,4\) in the worked intercept-only example, state the deviance-based and Pearson-based dispersion estimates and explain why they differ.
  5. Why should a scaled deviance from a quasi-likelihood fit not automatically be called a likelihood-ratio test?
Clinical Biostats