From a Grouped-Binomial Fit to Residuals
A residual is a way to describe how an observation differs from its fitted value. For grouped-binomial data, the observation is a count of successes out of a specified number of trials. That denominator matters: a discrepancy of two successes has a different scale in a group of five trials than in a group of five hundred. A useful diagnosis therefore begins by stating whether residuals are calculated for counts or proportions, and by keeping the group sizes visible.
The calculations below use an intercept-only logistic model, so every group has the same fitted success probability. This makes it possible to compare several residual definitions directly. In a model with covariates, the same calculations are performed group by group using that group’s fitted probability.
Worked Example: Fitting the Model and Calculating Four Residuals
Worked Example: Fitting the Model and Calculating Four Residuals
Four independent groups each contain 10 trials. Their success counts are \(2,4,7,7\). Fit an intercept-only binomial model, then calculate the count response residual, Pearson residual, signed deviance residual, and working residual for each group.
Fit. If the common success probability is \(p\), the log-likelihood, apart from terms not involving \(p\), is \(20\log(p)+20\log(1-p)\). Its derivative is \(20/p-20/(1-p)\), which is zero at \(\hat p=1/2\). The second derivative is negative for \(0<p<1\), so this is the maximum. Equivalently, the fitted probability is the pooled proportion \(20/40=0.5\). Each group has fitted count \(10(0.5)=5\).
Response residuals. Subtract 5 from each observed count: \(2-5=-3\), \(4-5=-1\), \(7-5=2\), and \(7-5=2\). On the proportion scale, the same discrepancies are \(-0.3,-0.1,0.2,0.2\).
Pearson residuals. Under a binomial model, the fitted count variance is \(m_i\hat p_i(1-\hat p_i)\). Here its square root is \(\sqrt{10(0.5)(0.5)}=\sqrt{2.5}\), approximately \(1.5811\). Dividing each count response residual by this standard deviation gives approximately \(-1.897,-0.632,1.265,1.265\).
Signed deviance residuals. For an observed count \(y_i\), the binomial deviance contribution is \(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))]\}\). The signed deviance residual is the square root of this contribution, with the sign of \(y_i-m_i\hat p_i\). For \(y=2\), the contribution is \(2\{2\log(2/5)+8\log(8/5)\}\approx3.8549\), giving \(-\sqrt{3.8549}\approx-1.963\). For \(y=4\), it is \(2\{4\log(4/5)+6\log(6/5)\}\approx0.4027\), giving \(-0.635\). For either group with \(y=7\), it is \(2\{7\log(7/5)+3\log(3/5)\}\approx1.6457\), giving \(+1.283\). A term of the form \(0\log(0/a)\) is defined to be zero when a count is at a boundary.
Working residuals. For the logit link, \(\eta_i=\log[p_i/(1-p_i)]\), and \(d p_i/d\eta_i=p_i(1-p_i)\). The working residual on the linear-predictor scale is therefore \((y_i/m_i-\hat p_i)/[\hat p_i(1-\hat p_i)]\). Here the denominator is \(0.25\), so the working residuals are \(-1.2,-0.4,0.8,0.8\).
All four residuals are negative for the first two groups and positive for the last two: the fitted model predicts too many successes in the first two and too few in the last two. The numerical sizes differ because each residual definition uses a different scale.
How the Residual Scales Relate
For a grouped binomial, the Pearson residual is naturally standardized as a count discrepancy. The working residual is naturally expressed on the linear-predictor scale. Multiplying the latter by the square root of the fitted working weight puts it on the Pearson scale.
To verify it, write the Pearson residual as a count discrepancy divided by its fitted standard deviation:
Multiplying the working residual by the square root of the fitted working weight gives
For the example, the multiplier is \(\sqrt{2.5}\). Thus \(-1.2\sqrt{2.5}\approx-1.897\), \(-0.4\sqrt{2.5}\approx-0.632\), and \(0.8\sqrt{2.5}\approx1.265\), matching the Pearson residuals. The unweighted working residual should not be read as a Pearson residual: its unit is a change on the logit scale, not a standardized count discrepancy. \(\square\)
Deviance and Pearson Residuals Near the Fitted Probability
The Pearson residual uses a local variance approximation. The deviance residual instead records the signed square root of the likelihood-based discrepancy from the saturated fit. For grouped binomial data, the two scales are often similar when the observed proportion is close to the fitted probability, but they are not identical.
To derive the approximation, define \(h(r)=r\log(r/p)+(1-r)\log[(1-r)/(1-p)]\), with endpoint terms interpreted by continuity. The deviance contribution is \(2mh(r)\). In an open interval around \(p\), \(h\) is three times continuously differentiable. Direct differentiation gives \(h(p)=0\), \(h'(p)=0\), and \(h''(p)=1/[p(1-p)]\). Taylor’s theorem, with the third derivative bounded on a sufficiently small closed interval around \(p\), therefore gives
The leading term is exactly the squared Pearson residual, since \(r^{(P)}=\sqrt{m}(r-p)/\sqrt{p(1-p)}\). This proves the stated local relationship. It also explains why deviance and Pearson residuals can differ more for observations far from the fitted probability or close to the binomial boundaries. \(\square\)
Worked Example: Comparing Pearson and Deviance Scales
For the group with \(y=2\) in the first example, the count response is \(-3\), the fitted count variance is \(2.5\), and the Pearson residual is \(-3/\sqrt{2.5}\approx-1.897\). Its square is \(9/2.5=3.6\). The deviance contribution is approximately \(3.8549\), so the signed deviance residual is approximately \(-1.963\). The signs agree, but the magnitudes differ: the observation is not close enough to the fitted proportion \(0.5\) for the local approximation to make the squared values identical.
For the group with \(y=4\), the Pearson residual is about \(-0.632\), while the signed deviance residual is about \(-0.635\). This closer agreement is consistent with the smaller discrepancy between the observed proportion \(0.4\) and the fitted probability \(0.5\).
Neither comparison proves that the model is adequate or inadequate by itself. A residual is a diagnostic summary, and its interpretation depends on the model, the group size, and the pattern across observations.
Randomized Quantile Residuals for Binomial Counts
Pearson and deviance residuals can be useful, but a discrete response has a discrete fitted distribution. A randomized quantile residual uses the fitted cumulative distribution to place each observed count within the probability interval assigned to that count, then transforms the result to a normal scale.
The randomization has an exact reference property when the distribution is fully specified and observations are independent. For one discrete random variable \(Y\) with probability mass function \(f\), the intervals \((F(k-1),F(k)]\), over its possible values \(k\), partition \((0,1]\) and have lengths \(f(k)\). Conditional on \(Y=k\), the randomized \(U\) is uniform on that interval. Its unconditional probability in any subinterval is therefore the length of that subinterval: complete CDF intervals contribute their full lengths, and the one interval containing a given point contributes the corresponding partial length. Hence \(U\) is uniform on \((0,1)\). Applying \(\Phi^{-1}\) gives a standard normal variable. For independent observations with correctly specified, known distributions, the resulting residuals are independent standard normal variables. When fitted parameters are estimated from the same data, this exact finite-sample conclusion does not generally hold; the normal distribution is then a reference for diagnosis, not a guarantee. \(\square\)
Worked Example: Randomized Quantile Residuals for the Four Groups
Continue with \(Y_i\sim\operatorname{Binomial}(10,0.5)\). The probability of count \(k\) is \(\binom{10}{k}/1024\). For \(y=2\), \(F(1)=11/1024=0.010742\) and \(F(2)=56/1024=0.054688\). Using the midpoint of this interval gives \(U=0.032715\), so \(r^{(q)}=\Phi^{-1}(0.032715)\approx-1.84\).
For \(y=4\), \(F(3)=176/1024=0.171875\) and \(F(4)=386/1024=0.376953\). The midpoint is \(U=0.274414\), giving \(r^{(q)}\approx-0.60\).
For \(y=7\), \(F(6)=848/1024=0.828125\) and \(F(7)=968/1024=0.945313\). The interval has width \(120/1024=0.117188\). If the random draw falls at one-quarter of the interval, \(U=0.857422\) and the residual is approximately \(1.07\). At three-quarters of the interval, \(U=0.916016\) and the residual is approximately \(1.38\). Thus the two groups with the same observed count can have different randomized quantile residuals. The difference is due to the randomization, not a difference in their observed counts or fitted probabilities.
These are illustrative random draws, not unique residual values for the data. Repeating the randomization can change them. In practice, the random seed and the chosen randomization should be handled consistently when comparing diagnostic plots.
Reading the Residuals and Their Plots
A negative response, Pearson, or deviance residual indicates fewer successes than fitted; a positive value indicates more. For a logit model, the working residual has the same sign because \(p(1-p)>0\). Sign agreement makes it easier to identify the direction of discrepancy, but magnitude comparisons require attention to scale.
For the four-group fit, every fitted probability is \(0.5\). A plot of residual against fitted probability therefore places all observations at the same horizontal coordinate. Such a plot cannot reveal a trend across fitted values; it is a vertical stack, not evidence that no pattern exists. Plotting residuals against a relevant covariate, or against group order when order has meaning, may expose structure hidden by the identical fitted values. A plot should also retain group size or otherwise make clear how much information each group contains.
With small groups, the binomial response has only a few possible counts, so residual plots may show bands or clusters rather than a smooth cloud. A randomized quantile residual spreads discrete outcomes over their fitted probability intervals, but randomization can itself affect the plotted appearance. Read the pattern together with the underlying counts, group sizes, and fitted probabilities; do not treat one unusual point as a formal conclusion about model failure.
Common Mistake
Wrong reasoning: “The raw response residual is \(+2\), so it is a two-standard-deviation discrepancy.” A response residual is a difference in counts, not a standardized quantity. In the example, the same \(+2\) count discrepancy corresponds to a Pearson residual of \(2/\sqrt{2.5}\approx1.265\), not 2. In a group with a different size or fitted probability, its standardized value would change again.
Correction: State which residual is being reported and use its definition. Use the response residual to describe the count or proportion difference, the Pearson residual for a variance-standardized discrepancy, the deviance residual for a signed likelihood-based discrepancy, the working residual for a discrepancy on the linear-predictor scale, and the randomized quantile residual for a transformed fitted-distribution scale.
Check Your Understanding
Use the definitions and calculations above to answer these questions.
- A group has \(m=20\), \(y=12\), and fitted probability \(\hat p=0.5\). What are its count response residual and proportion response residual?
- Why does multiplying a logit working residual by \(\sqrt{m\hat p(1-\hat p)}\) produce the Pearson residual?
- What does a positive signed deviance residual say about the observed count relative to the fitted count?
- Why can deviance and Pearson residuals be similar near the fitted probability but differ farther away?
- Why can a residual-versus-fitted-probability plot be uninformative for an intercept-only model?