Tutorials › Regression Analysis (Undergraduate) › Binned Residual Means as a Calibration Check

Specification Checks and Residual Patterns · Tutorial 576 of 991

Binned Residual Means as a Calibration Check

Use binned residual means to check whether a regression model’s errors balance around zero across low, middle, and high fitted values.

Advanced 10 min read

What You'll Learn

  • Define a binned residual mean and relate it to observed and fitted values.
  • Choose fitted-value ranges and calculate their mean residuals.
  • Interpret positive and negative means as underprediction and overprediction.
  • Explain why an overall residual mean of zero does not guarantee calibration across ranges.
  • Recognize how bin size and boundary choices affect this descriptive check.
  • Distinguish a diagnostic pattern from a formal test or proof of model adequacy.

Why Check Residual Means Across Fitted Values?

A regression model can have residuals that average to zero overall and still systematically miss in parts of its fitted-value range. For example, it might tend to underpredict for cases with low fitted values and overpredict for cases with high fitted values. Looking at residuals one by one can make such a pattern hard to see. Grouping fitted values into ranges and averaging the residuals within each range gives a compact check of whether the model’s errors balance across the scale of its predictions.

This is a descriptive calibration check for a continuous response. Here, calibration across fitted values means that, within ranges of fitted values, observed responses do not show a consistent average departure from the model’s fitted values. It does not mean that every individual prediction is accurate. Nor does a pattern in the check, by itself, identify the cause of a model’s shortcomings.

Definition and Interpretation

Suppose a regression model is fitted to \(n\) observations. For observation \(i\), let \(y_i\) be the observed response, \(\hat{y}_i\) its fitted value, and \(e_i=y_i-\hat{y}_i\) its residual. The residual is in the response’s units: it is positive when the observed response exceeds the fitted value, and negative when the observed response is below it.

Definition: A binned residual mean is the arithmetic mean of the residuals for observations whose fitted values fall within a specified range. If bin \(j\) contains \(n_j\) observations, its mean residual is \(\bar{e}_j=\frac{1}{n_j}\sum_{i\in j}e_i\). Since \(e_i=y_i-\hat{y}_i\), a positive \(\bar{e}_j\) indicates average underprediction in that bin, while a negative \(\bar{e}_j\) indicates average overprediction.

The binning variable is the fitted value, not necessarily an individual predictor. A bin can contain observations with different predictor values and different fitted values, so its mean residual summarizes the average discrepancy for that portion of the model’s fitted-value scale. It is useful to report the range, the number of observations, and the mean residual for every bin.

The standard regression model for a continuous response can be written \(Y_i=m(X_i)+\varepsilon_i\), where \(m(X_i)\) is the conditional mean response at the predictors \(X_i\), and \(\varepsilon_i\) is the error. For a linear regression model, the proposed mean structure is linear in the included predictors. The calibration check is most informative when the recorded responses and predictors are valid, the fitted model is the one intended for the analysis, and its fitted values meaningfully summarize the proposed mean structure. A residual pattern can then provide evidence that the fitted mean structure does not capture the response equally well across its fitted-value range. The check is exploratory: it does not establish that the model assumptions hold or fail.

Worked Example: Finding a Curved Calibration Pattern

Hypothetical data. A model predicts a continuous laboratory measurement in units. For simplicity, the table gives three fitted-value ranges, with four observations in each. Calculate each bin’s mean residual and interpret it.

Fitted-value range (units)Residuals in the range (units)Residual sum (units)Mean residual (units)
8 to less than 121.5, 1.5, 1.5, 1.561.5
18 to less than 22-3, -3, -3, -3-12-3
28 to less than 321.5, 1.5, 1.5, 1.561.5

For the first bin, the calculation is

$$ \bar{e}_1=\frac{1.5+1.5+1.5+1.5}{4} =\frac{6}{4}=1.5\text{ units}. $$

The second and third bin means are \((-12)/4=-3\) units and \(6/4=1.5\) units, respectively. Thus, the residual means are positive in the low and high fitted-value ranges but negative in the middle range. On average, the model underpredicts in the low and high ranges and overpredicts in the middle range. This alternating pattern could suggest that the mean response does not follow the shape represented by the fitted model.

The residuals sum to \(6-12+6=0\), so their overall mean is zero. That fact does not erase the differences among the three bins. The pattern is the point of the check: opposite-signed departures can cancel in an overall average.

Choosing Bins and Reading the Results

Bins should make the pattern across fitted values visible without leaving too few observations in each range. One option is to use ranges of equal width on the fitted-value scale. Another is to sort observations by fitted value and divide them into groups with roughly equal counts. Equal-width bins make the scale of the ranges easy to compare; roughly equal-count bins avoid very small groups when fitted values are concentrated in some parts of the scale. Neither choice is automatically best.

Before interpreting the pattern, check how many observations are in each bin and whether the bin boundaries have created an empty or especially small group. A mean from a small group can be strongly affected by one residual. Also check the units: the mean residual has the same units as the response, so the size of the departure can be judged in context. The direction alone does not say whether the departure is practically important.

Worked Example: Comparing Unequal-Sized Fitted-Value Groups

Hypothetical data. A model predicts a continuous response in units. Suppose the low, middle, and high fitted-value bins contain 4, 8, and 4 observations, with residual sums of 4, -8, and 4 units. Compute the bin means and check the overall average.

For the low bin, \(\bar{e}_1=4/4=1\) unit. For the middle bin, \(\bar{e}_2=-8/8=-1\) unit. For the high bin, \(\bar{e}_3=4/4=1\) unit. The model therefore underpredicts on average in the low and high bins and overpredicts in the middle bin.

The group sizes differ, so the overall residual mean must be computed by weighting each bin mean by its count:

$$ \bar{e} =\frac{4(1)+8(-1)+4(1)}{4+8+4} =\frac{4-8+4}{16} =0\text{ units}. $$

The zero overall mean is consistent with these bin means because the middle group has twice as many observations as either outer group. It would be incorrect to average the three bin means equally and call that the overall residual mean: \((1-1+1)/3=0.333\) units gives each bin the same weight, not each observation. When bin sizes differ, report the bin means separately and use the observation counts when calculating any combined mean.

A Useful Identity and Its Limitation

The relation between binned and overall residual means follows directly from the definition. If the bins partition all observations, each residual appears in exactly one bin. Therefore, adding the bin residual sums recovers the total residual sum:

$$ \sum_j n_j\bar{e}_j =\sum_j\sum_{i\in j}e_i =\sum_{i=1}^{n}e_i. $$

Dividing by \(n=\sum_j n_j\) gives the overall mean residual as a weighted average of the bin means:

$$ \bar{e} =\frac{1}{n}\sum_j n_j\bar{e}_j. $$

For ordinary least squares with an intercept, the residuals sum to zero, so \(\bar{e}=0\). The identity then says only that the bin means balance to zero after weighting by their group sizes. It does not require every bin mean to equal zero. This is why a zero overall residual mean is not evidence that the model is calibrated in every part of the fitted-value scale.

Worked Example: How Different Bin Boundaries Change the Summary

Hypothetical data. Suppose 16 observations are grouped into four equally sized fitted-value ranges. The bin centers are 10, 20, 30, and 40 units; each bin has four residuals, with values 0.25, -0.75, 0.75, and -0.25 units, respectively. The corresponding residual sums are 1, -3, 3, and -1 units, so the four bin means are 0.25, -0.75, 0.75, and -0.25 units.

If the first two ranges are combined, their residual sum is \(1+(-3)=-2\) units across \(4+4=8\) observations. Their combined mean is \((-2)/8=-0.25\) units. Combining the last two gives residual sum \(3+(-1)=2\) units across 8 observations, for a mean of \(2/8=0.25\) units. With these broader boundaries, the summary is negative at the lower end and positive at the upper end; with four narrower ranges, the means alternate in sign.

The total residual sum is \(1-3+3-1=0\) units under either grouping. The different summaries show why a striking pattern in one choice of bins should be checked against reasonable alternatives. Binning is a way to summarize the data, not a procedure that produces a unique answer independent of boundary choices.

What the Check Can and Cannot Establish

A sustained positive mean over a fitted-value region is evidence of average underprediction there; a sustained negative mean is evidence of average overprediction. If the means remain near zero across a sensible set of bins, there is no obvious mean discrepancy at that level of grouping. But near-zero binned means do not prove that every individual prediction is accurate, that the model is correctly specified, or that other assumptions are satisfied. A pattern might also be hidden by wide bins that combine regions with opposite-signed departures.

Binned means are descriptive summaries, not a formal test with an automatic significance threshold. Their values alone do not provide a p-value or quantify the uncertainty in each mean. A small difference might be unimportant in context, while a larger difference may merit investigation. The residual-versus-fitted plot can show the individual points alongside bin summaries, helping distinguish a broad mean pattern from a result driven by only a few observations.

This check is useful because it condenses many residuals into a scale-ordered view of average prediction error. It can flag where the model’s fitted values tend to sit above or below observed responses, guiding a careful review of the model and data. It does not, by itself, tell the analyst which change should be made.

Common Mistakes

  • Claiming that a zero overall mean proves calibration everywhere. Opposite-signed bin means can cancel. Check the weighted mean within each fitted-value range.
  • Reversing the interpretation of the sign. Since \(e_i=y_i-\hat{y}_i\), a positive mean means observed responses exceed fitted values on average: the model underpredicts. A negative mean means overprediction.
  • Averaging bin means without regard to bin size. When sizes differ, the overall mean weights each bin by its number of observations, not equally across bins.
  • Treating one binning choice as conclusive. Boundaries affect the summaries. Check whether the pattern is reasonably stable under sensible alternative groupings.
  • Calling the check a proof or a formal test. Binned means are a descriptive diagnostic. They can reveal a pattern but cannot, alone, establish model adequacy or explain the pattern’s cause.
Key takeaway: Calculate the mean residual in each fitted-value range and interpret its sign in the response’s units. A positive mean indicates average underprediction; a negative mean indicates average overprediction. Overall residuals can average to zero while the bins reveal important differences.

Check Your Understanding

Answer each question using the residual convention \(e_i=y_i-\hat{y}_i\).

  1. A fitted-value bin has residuals of 2, -1, 1, and 2 units. Calculate its mean residual and state the direction of average prediction error.
  2. Why does a zero overall residual mean not guarantee that every fitted-value bin has a mean residual of zero?
  3. Two bins have means of 3 and -1 units, with 5 and 15 observations, respectively. What is the combined mean residual?
  4. What does a negative binned residual mean indicate about fitted and observed responses in that range?
  5. Why should an analyst check the bin sizes and consider reasonable alternative boundaries before drawing conclusions?