Tutorials › Generalized Linear Models › Sparse Data and Boundary Fits

Detecting Overdispersion · Tutorial 669 of 981

Sparse Data and Boundary Fits

Learn how sparse observations and boundary fitted values affect Pearson and deviance contributions, and when their usual comparison is trustworthy.

Intermediate 9 min read

What You'll Learn

  • Compute Pearson and deviance contributions for Poisson counts and grouped binomial data
  • Recognize why small expected counts weaken routine chi-square calibration
  • Compare the two diagnostics when binomial fitted proportions are extreme
  • Identify zero-denominator and divergent-contribution problems at fitted boundaries
  • Use local approximations and simulation checks to judge diagnostic reliability

Why Sparse Data Need Extra Care

Pearson and deviance dispersion diagnostics summarize discrepancies between observed responses and fitted means. Their familiar chi-square interpretation, however, is an approximation. When expected counts are small, binomial proportions are near zero or one, or fitted means approach a boundary, a few discrete observations can dominate the summary. In these settings, the numerical diagnostics remain useful descriptions of residual discrepancy, but their usual reference distribution and simple interpretation may be unreliable.

The issue is not that a small expected count automatically proves overdispersion. Rather, sparse data can make the sampling distribution of a diagnostic quite different from its large-sample approximation. It can also make Pearson and deviance contributions differ substantially. The fitted mean, observed response, and variance under the model must therefore be examined together.

Contributions to the Two Diagnostics

For independent Poisson responses \(Y_i\) with fitted means \(\hat{\mu}_i\), the Pearson contribution is the squared residual divided by its fitted variance. The Poisson deviance contribution compares the fitted model with the saturated model, which assigns each observation its own fitted mean.

$$ X^2=\sum_i \frac{(y_i-\hat{\mu}_i)^2}{\hat{\mu}_i}, \qquad D=\sum_i 2\left\{y_i\log\left(\frac{y_i}{\hat{\mu}_i}\right)-(y_i-\hat{\mu}_i)\right\}. $$

When \(y_i=0\), the term \(y_i\log(y_i/\hat{\mu}_i)\) is defined by its limit as zero. For grouped binomial data, let \(Y_i\) be the number of successes among \(m_i\) trials and let \(\hat{p}_i\) be the fitted success probability. The fitted mean is \(m_i\hat{p}_i\), and the fitted variance is \(m_i\hat{p}_i(1-\hat{p}_i)\).

$$ X^2=\sum_i \frac{(y_i-m_i\hat{p}_i)^2}{m_i\hat{p}_i(1-\hat{p}_i)}, $$
$$ D=2\sum_i\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\}. $$

Terms of the form \(0\log 0\) are interpreted by continuity as zero. These formulas apply directly when fitted probabilities are strictly between zero and one and fitted Poisson means are positive. At a boundary, a contribution may have to be interpreted as a limit; a formula with a zero denominator is not automatically a well-defined statistic.

Definition: A sparse fitted cell is one for which the model assigns a small expected count, such as \(\hat{\mu}_i\) for a Poisson response, or a small expected count in one of the two binomial categories, \(m_i\hat{p}_i\) or \(m_i(1-\hat{p}_i)\). Sparsity concerns the expected counts under the fitted model, not just whether the observed count happens to be zero.

In regular, adequately populated settings, a residual deviance or Pearson statistic is often compared with a chi-square distribution having residual degrees of freedom; dividing by those degrees of freedom gives a dispersion ratio. This is an approximation, not a definition of the statistic. Sparse cells, extreme probabilities, and boundary fits can undermine the approximation even when the arithmetic calculation is correct.

Worked Sparse-Count and Extreme-Proportion Examples

Worked Example: Sparse Poisson Counts

Suppose four Poisson observations are \(y=(0,0,1,3)\), with fitted means \(\hat{\mu}=(0.2,0.2,1,2)\). Calculate both diagnostics and compare their contributions.

For the Pearson statistic, the four contributions are \((0-0.2)^2/0.2=0.2\), \((0-0.2)^2/0.2=0.2\), \((1-1)^2/1=0\), and \((3-2)^2/2=0.5\). Thus \(X^2=0.2+0.2+0+0.5=0.9\).

For the deviance, the first two contributions are each \(2\{0\log(0/0.2)-(0-0.2)\}=0.4\), and the third is zero. The last is \(2\{3\log(3/2)-(3-2)\} =2\{3(0.405465)-1\}\approx0.4328\). Therefore \(D\approx0.4+0.4+0+0.4328=1.2328\).

The first two cells have expected counts of only \(0.2\), and the fourth has a nonzero residual despite an expected count of \(2\). The total statistics differ, and neither total alone tells us that a chi-square calibration is accurate. In particular, the zero observations are not evidence of extra variation merely because they are zeros: their contributions must be judged against the small fitted means.

Worked Example: An Extreme Grouped-Binomial Probability

Consider a group with \(m=10\) trials, fitted success probability \(\hat{p}=0.01\), and observed success count \(y=0\). The expected success and failure counts are \(0.1\) and \(9.9\). The Pearson contribution is \((0-0.1)^2/(10(0.01)(0.99))=0.01/0.099\approx0.1010\). The deviance contribution is \(2\{10\log(1/0.99)\}\approx0.2010\).

Now keep \(m\) and \(\hat{p}\) fixed but observe \(y=1\). The Pearson contribution becomes \((1-0.1)^2/0.099=0.81/0.099\approx8.1818\). The deviance contribution is \[ 2\left\{\log(1/0.1)+9\log(9/9.9)\right\} =2\{\log(10)+9\log(10/11)\} \approx2.8896. \]

A change of one success changes both contributions sharply, and the Pearson contribution is much larger in the second case. This is a consequence of the small fitted success count and the discrete response, not a calculation error. A dispersion ratio formed by adding such contributions may be sensitive to a few groups, while the ordinary chi-square approximation can be poor when expected successes are this small.

When Pearson and Deviance Agree Locally

The two contributions are closely related when the observation is near its fitted mean relative to the scale of the mean or variance. This local relationship explains why they often tell a similar story in well-populated data, but it does not guarantee similarity for sparse observations.

Theorem: For a Poisson observation with fitted mean \(\mu>0\) and \(y=\mu+\delta>0\), if \(|\delta|/\mu\) is small, its deviance contribution is its Pearson contribution plus a term of order \(|\delta|^3/\mu^2\). For a grouped binomial observation with \(m\) trials, fitted probability \(p\in(0,1)\), and observed proportion \(q=y/m\), if \(q\) is close to \(p\) while the segment between them stays inside \((0,1)\), the deviance contribution is its Pearson contribution plus a third-order Taylor remainder.

Proof. For Poisson data, put \(y=\mu+\delta\). The deviance contribution is \(2\{(\mu+\delta)\log(1+\delta/\mu)-\delta\}\). For \(|\delta|/\mu<1\), the Taylor expansion \(\log(1+x)=x-x^2/2+x^3/3+O(x^4)\) gives

$$ 2\left\{(\mu+\delta)\log(1+\delta/\mu)-\delta\right\} =\frac{\delta^2}{\mu}-\frac{\delta^3}{3\mu^2} +O\left(\frac{\delta^4}{\mu^3}\right). $$

The leading term \(\delta^2/\mu\) is exactly the Pearson contribution, and the next term has order \(|\delta|^3/\mu^2\).

For the binomial case define \(g(q)=q\log(q/p)+(1-q)\log((1-q)/(1-p))\). The deviance contribution is \(2m g(q)\). Direct differentiation gives \(g(p)=0\), \(g'(p)=0\), \(g''(p)=1/\{p(1-p)\}\), and \(g'''(u)=-1/u^2+1/(1-u)^2\). Taylor's theorem, on a segment contained in \((0,1)\), therefore yields

$$ 2m g(q)=\frac{m(q-p)^2}{p(1-p)}+R, \qquad |R|\leq \frac{m}{3}\sup_{u\text{ between }p\text{ and }q}|g'''(u)|\,|q-p|^3. $$

Since \(m(q-p)^2/\{p(1-p)\}=(y-mp)^2/\{mp(1-p)\}\), the leading term is the Pearson contribution. The expansion is local; if \(p\) is extreme or \(q\) is far from \(p\), it need not make the two contributions close. \(\square\)

Boundary Fits and Their Limits

A boundary fit can create a more serious issue than a poor approximation: a contribution may be undefined or diverge. The limiting behavior is precise for both families.

Result: For a Poisson observation with fixed \(y\), as its fitted mean \(\mu\) approaches zero, both contributions approach zero if \(y=0\). If \(y>0\), the Pearson contribution diverges at rate proportional to \(1/\mu\), while the deviance contribution diverges at logarithmic rate. For a grouped binomial observation, as \(p\) approaches zero, both contributions approach zero when \(y=0\); for fixed \(y>0\), both diverge. The corresponding statements at \(p\) approaching one follow by exchanging successes and failures.

Justification. For a Poisson zero, the Pearson contribution is \((0-\mu)^2/\mu=\mu\), and the deviance contribution is \(2\mu\). Both tend to zero. For fixed \(y>0\), the Pearson contribution is \((y-\mu)^2/\mu=y^2/\mu-2y+\mu\), which diverges like \(y^2/\mu\). The deviance is \(2\{y\log(y/\mu)-y+\mu\}\); its leading unbounded term is \(2y\log(1/\mu)\), so it also diverges, but more slowly.

For a binomial group with fixed \(m\), fitted probability \(p\), and \(y=0\), the Pearson contribution is \(mp/(1-p)\), and the deviance is \(-2m\log(1-p)\); both tend to zero as \(p\) approaches zero. If \(y>0\), the Pearson numerator tends to \(y^2\) while its denominator \(mp(1-p)\) tends to zero. The first deviance term includes \(2y\log(1/p)\), which diverges; the other term remains finite when \(y<m\), and is zero under the limiting convention when \(y=m\). Thus both diagnostics diverge. If a fitted probability is exactly zero and \(y=0\), the Pearson formula is \(0/0\), not an ordinary ratio; its limiting contribution is zero. If \(p=0\) and \(y>0\), the model assigns zero probability to the observed outcome. Such cases require an explicit boundary interpretation rather than blind substitution into the formulas. \(\square\)

Worked Example: A Binomial Fit Near the Boundary

Suppose \(m=5\), \(y=1\), and the fitted success probability is \(p=0.001\). The expected number of successes is only \(0.005\). The Pearson contribution is \[ \frac{(1-0.005)^2}{5(0.001)(0.999)} =\frac{0.990025}{0.004995} \approx198.20. \]

The deviance contribution is \[ 2\left\{\log(1/0.005)+4\log(4/4.995)\right\} =2\{5.298317+4(-0.222144)\} \approx8.8195. \]

Both contributions are large, but their magnitudes differ greatly. The Pearson contribution is especially sensitive to the small fitted variance in the denominator. At \(p=0\), the observation \(y=1\) is impossible under the fitted model, so the finite-probability diagnostic formulas no longer apply as ordinary finite quantities. The appropriate response is to investigate the fit and the data, not to interpret either number using a routine dispersion threshold.

Practical Interpretation and a Common Pitfall

The diagnostics are still informative in sparse settings, but their role changes: first treat them as summaries of residual discrepancy, then assess how well their reference distribution applies. Inspect fitted expected counts and the individual contributions. For grouped binomial data, check both expected successes and expected failures. A large total driven by one or two sparse cells is not equivalent to broadly distributed extra variation across the data.

When the approximation is doubtful, simulation under the fitted model can provide a more relevant calibration: generate responses under the fitted model, refit as appropriate, and calculate the same diagnostic for each simulated data set. This evaluates the diagnostic’s behavior under the fitted design and response structure. It does not repair a misspecified mean or variance model, and the simulated procedure should reflect the fitting process used for the observed data.

Common mistake: “The Pearson ratio is above one, so the data are overdispersed; a chi-square cutoff settles the question.” This reasoning treats an approximate reference distribution as exact and ignores whether small expected counts or boundary fits make it unreliable. A better assessment checks the fitted means, category-specific expected counts, and contribution pattern, then uses a suitable calibration when the usual approximation is questionable. A large contribution may indicate an unusual observation under the fitted model, but it does not by itself identify the cause.

Key takeaway: Sparse counts and boundary fitted values do not make Pearson and deviance diagnostics meaningless, but they weaken routine chi-square interpretations and can make the two statistics behave quite differently. Inspect contributions and expected counts before interpreting a dispersion ratio.

Check Your Understanding

Use the definitions and boundary results to answer these questions.

  1. Why can a zero Poisson count have a small Pearson contribution when its fitted mean is small?
  2. For a grouped binomial response, which two expected counts should be checked when assessing sparsity?
  3. In the local Poisson expansion, what is the leading term, and how does it relate to the Pearson contribution?
  4. What happens to the Poisson Pearson and deviance contributions as the fitted mean tends to zero when the observed count is positive?
  5. Why should a large dispersion ratio based on sparse cells not automatically be compared with a routine chi-square cutoff?
Clinical Biostats