Why Exposure Changes a Residual Check
In a count model, an observation with a longer observation period or larger population at risk will generally have more opportunities to accumulate events. A count of 12 may be unexpectedly high over one hour but entirely plausible over a much longer period. Comparing counts without accounting for exposure can therefore make a model look inadequate for the wrong reason—or conceal a mismatch in event rates.
For count GLMMs, exposure is commonly included as an offset. This makes the fitted mean increase in proportion to exposure while allowing the model to describe how the underlying event rate changes with predictors and cluster effects. Residual checks should then compare each observed count with its fitted, exposure-adjusted mean, and look for systematic residual patterns across exposure levels.
What the Offset Assumes
The offset encodes a substantive assumption: holding the modeled rate predictors and random effects fixed, doubling exposure doubles the expected count. It is appropriate when exposure represents the scale on which events accumulate and the rate is constant over that exposure, after accounting for modeled predictors. Person-time is a common example, but exposure may also be an area, number of devices, or population at risk.
This assumption is not guaranteed by having an exposure variable in the data. The exposure must be measured on a meaningful scale, strictly positive for the log offset, and aligned with the period and population to which the outcome count refers. If the rate changes with duration, or exposure is measured inaccurately, the offset alone does not repair the mismatch. A systematic residual pattern can be a clue to such problems, but it does not identify their cause by itself.
For a residual check within observed clusters, the fitted mean is often computed using estimates of the cluster effects. That is a conditional fitted mean. Predictions for new clusters instead need to account for the random-effects distribution rather than insert an estimated effect for a cluster that has not been observed. These are different prediction targets; exposure comparisons should not mix them.
Residuals on the Exposure-Adjusted Scale
For a Poisson model, the conditional variance equals the conditional mean: \(\operatorname{Var}(Y_{ij}\mid b_i)=\mu_{ij}\). A basic check uses the Pearson residual, which divides the observed-minus-fitted count difference by the square root of the fitted mean:
The denominator matters: a difference of 2 events is not equally surprising when the fitted mean is 1 as when it is 100. Under a correctly specified Poisson model with known parameters, the conditional Pearson residual has mean 0 and variance 1. In an actual GLMM, parameters and random effects are estimated, so these residuals are not exactly independent standard normal values. In particular, sparse counts can produce asymmetric and discrete residual distributions.
A useful check plots Pearson residuals against exposure, often on a logarithmic horizontal axis, and also compares observed counts with fitted means or examines observed rates \(Y_{ij}/E_{ij}\). Look for a trend, changing spread beyond what the fitted model and its simulations predict, or a set of large residuals concentrated at one end of the exposure range. Binned summaries can help reveal a trend, but bins conceal individual observations and depend on how the cut points are chosen.
Worked Example: Residuals Across Five Exposure Levels
Suppose a hypothetical Poisson GLMM gives an estimated conditional event rate of 0.5 events per exposure unit for five observations. The exposures are 1, 2, 4, 8, and 16 units, so the fitted means are \(0.5, 1, 2, 4,\) and \(8\). The observed counts are \(0, 1, 4, 12,\) and \(30\), respectively. Calculate the Pearson residuals and describe the pattern.
For exposure 1, the fitted mean is \(0.5\), and $$ \frac{0-0.5}{\sqrt{0.5}}=-0.7071. $$ For exposure 2, the fitted mean is 1, and $$ \frac{1-1}{\sqrt{1}}=0. $$ For exposure 4, the fitted mean is 2, and $$ \frac{4-2}{\sqrt{2}}=1.414. $$ For exposure 8, the fitted mean is 4, and $$ \frac{12-4}{\sqrt{4}}=4.00. $$ For exposure 16, the fitted mean is 8, and $$ \frac{30-8}{\sqrt{8}}=\frac{22}{2.8284}\approx 7.778. $$
The residuals increase as exposure increases, and the two largest are strongly positive. This is a warning that the model may underpredict counts at larger exposures. It is not, by itself, proof of a specific defect: the pattern could reflect an incorrectly specified rate relationship, an influential observation, a data issue, or variation not captured by the model. The counts increase with exposure as expected; the diagnostic concern is that they increase much faster than their fitted means in this hypothetical set.
A Short Justification for Standardization
The Pearson residual adjusts the count difference for its expected conditional scale. If the model parameters and \(b_i\) were known, then under the Poisson model
Dividing by \(\sqrt{\mu_{ij}}\) therefore gives a quantity with conditional mean 0 and variance 1:
This explains why Pearson residuals are more comparable across different fitted means than raw differences \(Y_{ij}-\widehat{\mu}_{ij}\). It does not imply that fitted residuals from a GLMM must look normally distributed or independent. Estimating parameters and cluster effects changes their behavior, and a Poisson distribution with a small mean is highly discrete.
Worked Example: Comparing Exposure Strata
Consider a second hypothetical check under a fitted rate of 0.2 events per exposure unit. Four exposure strata have total exposures of 10, 20, 40, and 80 units, with observed totals of 2, 7, 14, and 36 events. For a simple conditional Poisson calculation with independent counts and a common fitted rate, the expected totals are 2, 4, 8, and 16. Calculate the rates and stratum-level standardized differences.
The observed rates are \(2/10=0.20\), \(7/20=0.35\), \(14/40=0.35\), and \(36/80=0.45\) events per exposure unit. The corresponding aggregate Pearson residuals are: $$ \frac{2-2}{\sqrt{2}}=0,\quad \frac{7-4}{\sqrt{4}}=1.50,\quad \frac{14-8}{\sqrt{8}}\approx2.121,\quad \frac{36-16}{\sqrt{16}}=5.00. $$
Both the observed rates and the standardized differences rise across strata, suggesting underprediction at higher exposures in this hypothetical illustration. The aggregate calculation relies on the stated simple Poisson setup. In a GLMM, observations within a cluster can be associated through their shared random effect; totals across strata may also combine clusters. Thus, the displayed residuals are useful descriptive summaries, but their values should not be treated as exact independent standard normal test statistics. For inference about whether a pattern is unusual, compare it with replications or predictive checks that preserve the fitted model's clustering and exposure structure.
Make the Check Match the Model and Data
Before interpreting a pattern, verify that fitted means were calculated with the correct exposure for each observation. A common data error is to use exposure from a different time interval or denominator than the count. Another is to enter exposure as an ordinary predictor while omitting the offset, which estimates rather than fixes the exposure coefficient at 1. The latter may be justified when proportionality is not appropriate, but it is a different model and should be motivated rather than introduced accidentally.
Check that observations with very different exposures are not being compared as if they had the same expected count. Also examine the range of exposures: if all large exposures occur in one cluster or one predictor group, an apparent exposure trend may actually reflect that group or cluster. Residual plots against exposure should be considered alongside checks against fitted rate predictors and cluster membership. A sparse region of the exposure range provides little evidence about the shape of a trend.
For a GLMM, a simulation-based check is often more informative than comparing residuals with an idealized reference curve. Simulate counts under the fitted model with the observed exposures and the appropriate treatment of random effects, then compare the observed residual-versus-exposure pattern with patterns from the replications. Conditional replications address fit within the observed clusters; unconditional replications also reflect variation in newly drawn cluster effects. The choice should match the diagnostic question. This uses the predictive-check principle without treating an estimated residual as though its reference distribution were known exactly.
Worked Example: Checking Whether the Offset Is Being Applied Correctly
A hypothetical clinic dataset records event counts over exposures of 2, 5, and 10 person-time units. A fitted model has an estimated conditional rate of 0.4 events per unit for these observations, giving fitted means \(0.8, 2,\) and \(4\). The observed counts are \(0, 3,\) and \(9\). Calculate the fitted means, observed rates, and Pearson residuals, then state what the pattern can and cannot establish.
The fitted means follow \(\widehat{\mu}=0.4E\): for the three exposures they are \(0.4(2)=0.8\), \(0.4(5)=2\), and \(0.4(10)=4\). The observed rates are \(0/2=0\), \(3/5=0.60\), and \(9/10=0.90\) events per person-time unit.
The Pearson residuals are $$ \frac{0-0.8}{\sqrt{0.8}}\approx-0.8944,\quad \frac{3-2}{\sqrt{2}}\approx0.7071,\quad \frac{9-4}{\sqrt{4}}=2.50. $$
The rates and residuals both rise with exposure in these three observations, which merits investigation. The pattern does not prove that exposure itself changes the rate: exposure may be associated with another predictor, cluster effects may matter, and three observations are too few to characterize a general trend. First confirm that the exposure values and count periods match, then inspect the wider data and use a model-appropriate predictive comparison.
Alternatives, Limitations, and Common Mistakes
| Check | What it highlights | Important limitation |
|---|---|---|
| Raw count versus fitted count | Whether observations are above or below their exposure-adjusted means | Raw differences naturally grow in scale as fitted means grow |
| Pearson residual versus exposure | Standardized discrepancies and possible trends across exposure levels | Residuals are discrete or skewed at small means and are affected by estimation |
| Observed rate versus exposure | Whether event rates appear to change over exposure | Rates from small exposures are especially variable; the plot alone does not account for clustering |
| Simulation-based pattern check | Whether the observed pattern is unusual under the fitted GLMM structure | Conclusions depend on the fitted model and the replication scheme |
Deviance residuals and randomized quantile residuals are other possible residual summaries. They can be useful for count data, but none removes the need to respect exposure and clustering. In sparse data, individual residuals can be noisy; summarize patterns cautiously and examine replicated data under the fitted model where appropriate.
- Mistake: comparing raw counts across exposure levels. A larger count at larger exposure may be exactly what the model predicts. Compare with the exposure-adjusted fitted mean and inspect residuals or rates.
- Mistake: treating a Pearson residual of 2 as an automatic significance test. Estimated GLMM residuals are not generally independent standard normal values. Assess the pattern in context and use model-appropriate replication for a calibrated comparison.
- Mistake: concluding that an exposure trend proves a bad offset. An apparent pattern can arise from confounding with predictors or clusters, data errors, or chance. Verify alignment and examine alternative explanations before changing the model.
- Mistake: assuming the offset tests proportionality. Fixing its coefficient at 1 imposes proportionality; it does not test that assumption. A different exposure relationship requires explicit model comparison and substantive justification.
The central limitation is that a residual pattern is diagnostic evidence, not a unique explanation. Its value is to direct attention to whether the exposure definition, rate structure, predictor specification, or random-effects structure warrants closer examination.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- A count model uses a log link and exposure \(E_{ij}\). What coefficient is assigned to \(\log(E_{ij})\) when exposure is an offset, and what assumption does that encode?
- An observation has fitted mean 9 and observed count 15. Calculate its Pearson residual.
- Why can a plot of raw count against exposure show an increasing pattern even when the fitted exposure relationship is correct?
- Suppose large positive residuals occur mostly at the largest exposures. Name two checks to make before concluding that the rate model is inadequate.
Solutions. (1) Its coefficient is fixed at 1. Holding the rate predictors and random effects fixed, expected count is proportional to exposure. (2) \(r^{(P)}=(15-9)/\sqrt{9}=6/3=2.00\). This is a standardized discrepancy, not automatically a p-value or a formal test. (3) The expected count increases with exposure under the offset model, so raw counts can rise even when the rate is constant; counts also have larger variance when their means are larger. (4) Confirm that exposure matches the count's time period and denominator, and check whether large exposures coincide with particular predictors or clusters. Then assess the pattern using replications that preserve the relevant GLMM structure.