Why Summarize Along a Quantitative Predictor?
A scatterplot places one point at each observed pair of predictor and response values. When there are many observations, points can overlap; when individual responses vary considerably, the point cloud can also make a broad pattern difficult to see. One way to make the display easier to read is to group nearby predictor values into intervals and calculate a response summary for each group.
The result is a binned summary plot: each plotted point represents a whole interval of predictor values, rather than one observation. The vertical coordinate might be the mean or median response in that interval. This can reveal broad changes across the predictor range, but it necessarily hides the individual observations and the differences among them within each bin.
Suppose the data consist of paired observations \((x_i,y_i)\), where \(x_i\) is a quantitative predictor and \(y_i\) is a quantitative response. For bin \(j\), the response mean is
The response median for a bin is the median of the \(y_i\) values whose \(x_i\) values fall in that bin. Both summaries describe the responses in the observed bin; neither by itself describes every response at every predictor value inside it.
Defining the Bins and Displaying the Summaries
First decide which predictor intervals to use. With equal-width bins, every interval has the same numerical width. This makes each summary correspond to a similar span of the predictor scale, though the numbers of observations in different bins may vary. With equal-count bins, the boundaries are chosen so that bins contain roughly similar numbers of observations. This can give summaries in sparsely populated parts of the predictor range more observations, but the intervals may have very different widths.
Whatever scheme is used, bin boundaries must be clear and observations must be assigned consistently. A common convention is to include the left endpoint and exclude the right endpoint, as in \([0,2)\) and \([2,4)\). That puts a value exactly equal to 2 in the second interval, not in both. The last interval may include its right endpoint so the largest observation is not lost. State the convention if an endpoint could affect the assignment.
Each summary needs a horizontal plotting position. Two common choices are the bin midpoint and the mean of the observed predictor values in that bin. The midpoint represents the interval itself; the mean predictor value represents the observed \(x_i\) values inside it. Either can be useful, but the choice should be stated and applied consistently. A plotted response mean at a bin midpoint does not mean that an observation was necessarily recorded at that exact predictor value.
The bins should be wide enough to combine observations and make a broad pattern easier to see, but not so wide that important changes are hidden. Narrow bins retain more local detail, but may contain very few observations; a summary based on one or two responses can be highly dependent on those values. Always consider showing or reporting the bin counts \(n_j\) alongside the summaries. Empty bins have no response summary to plot.
Worked Example: Calculating Mean Responses in Equal-Width Bins
A hypothetical set of 16 observations records a predictor \(x\), measured in hours, and a response \(y\), measured in units. The paired data are:
| \(x\) (hours) | \(y\) (units) |
|---|---|
| 0.4, 0.8, 1.3, 1.7 | 4, 5, 3, 6 |
| 2.2, 2.7, 3.1, 3.8 | 5, 8, 7, 8 |
| 4.2, 4.9, 5.3, 5.8 | 8, 9, 10, 9 |
| 6.4, 7.1, 7.6, 7.9 | 11, 10, 13, 12 |
Use the equal-width bins \([0,2)\), \([2,4)\), \([4,6)\), and \([6,8]\). Each has four observations. For the first bin, the response mean is
For the second bin, \(\bar{y}_2=(5+8+7+8)/4=28/4=7\) units. For the third, \(\bar{y}_3=(8+9+10+9)/4=36/4=9\) units. For the fourth, \(\bar{y}_4=(11+10+13+12)/4=46/4=11.5\) units.
If the horizontal coordinate is the mean predictor value in each bin, the first is \((0.4+0.8+1.3+1.7)/4=1.05\) hours. The corresponding values for the other bins are \(2.95\), \(5.05\), and \(7.25\) hours. The plotted summaries are therefore \((1.05,4.5)\), \((2.95,7)\), \((5.05,9)\), and \((7.25,11.5)\), with units of hours and units on their respective axes. This display makes the increase in the bin means easy to see, while not showing how the four individual responses in each interval differ.
Means and Medians Answer Different Descriptive Questions
The mean uses every response value and is sensitive to unusually high or low responses. The median is the middle value when responses are ordered; for an even number of observations, it is the average of the two middle values. A median can be less affected than a mean by an extreme response, but it still summarizes only the observations assigned to its bin. Choose the summary that suits the data and the descriptive purpose, rather than choosing whichever produces a preferred-looking plot.
Worked Example: Plotting Median Responses by Bin
A hypothetical data set records a predictor \(x\), in minutes, and a response \(y\), in points. The observations are \((2,12)\), \((4,16)\), \((7,14)\), \((11,18)\), \((14,22)\), \((18,20)\), \((21,28)\), \((24,24)\), \((27,30)\), and \((29,26)\). Use bins \([0,10)\), \([10,20)\), and \([20,30]\), and plot each median at the bin midpoint.
The first bin contains three responses, 12, 16, and 14. Ordered, they are 12, 14, 16, so the median is 14 points. The second contains 18, 22, and 20; the ordered values are 18, 20, 22, giving a median of 20 points. The last bin contains 28, 24, 30, and 26. The ordered values are 24, 26, 28, 30, so its median is \((26+28)/2=27\) points.
The bin midpoints are 5, 15, and 25 minutes. The plotted points are thus \((5,14)\), \((15,20)\), and \((25,27)\). The bin counts are 3, 3, and 4. In context, each vertical coordinate is the median response among observations whose recorded predictor falls in the corresponding interval. It is not a prediction for every individual at the midpoint.
Why the Bin Counts and Boundaries Matter
A binned plot compresses data, so the display should make its construction understandable. State the predictor units, the bin boundaries or bin-width rule, the response summary, and the horizontal plotting-position rule. Showing \(n_j\) for each bin helps readers distinguish a summary based on many observations from one based on only a few. If the bins are very uneven in count, a sequence of summaries can look equally well supported even though the underlying counts differ substantially.
The response mean across all observations is a weighted average of the bin means, where the weights are the bin counts. This explains why the mean in a small bin should not count as much as the mean in a large bin when recovering the overall response mean. For bins that cover all \(n\) observations without overlap, the identity follows directly:
The first equality groups the original response values by bin. In the second, the sum of responses in bin \(j\) is \(n_j\bar{y}_j\), by the definition of the bin mean. Since the bins partition the data, \(\sum_{j=1}^{k}n_j=n\), and the last expression is the overall mean expressed as a count-weighted average of bin means. A simple unweighted average of the bin means generally does not equal \(\bar{y}\) unless the bin counts are equal or happen to produce the same result.
Worked Example: How an Extreme Response Changes the Bin Summary
Consider 10 hypothetical observations divided into two predictor bins, with five observations in each. In the first bin, \([0,5)\), the responses are 2, 3, 4, 5, and 40 points. In the second, \([5,10]\), they are 7, 8, 9, 10, and 11 points. Use bin midpoints 2.5 and 7.5 as the horizontal coordinates.
For the first bin, the mean is \((2+3+4+5+40)/5=54/5=10.8\) points. The ordered responses are 2, 3, 4, 5, 40, so the median is 4 points. For the second bin, the mean is \((7+8+9+10+11)/5=45/5=9\) points, and the median is 9 points.
The two mean-summary points are \((2.5,10.8)\) and \((7.5,9)\), while the median-summary points are \((2.5,4)\) and \((7.5,9)\). The response of 40 points pulls the first mean above all four other responses in that bin, but does not change its median from 4. These summaries give different views of the same observations. Neither should be selected without considering what it represents; retaining the raw data display or reporting additional context may be important when a bin contains an unusual value.
Common Mistakes and Limits
- Treating a bin summary as an individual observation. A mean of 7 units in the interval \([2,4)\) summarizes all responses in that interval. It does not say that an observation at \(x=3\) had a response of exactly 7.
- Ignoring bin counts. A summary from two observations may appear as a point just like a summary from 200. Include or report the counts so the amount of data represented is visible.
- Leaving endpoints ambiguous. Overlapping intervals can assign one observation twice, while gaps can leave observations out. Specify a consistent boundary convention and check that every observation is assigned once.
- Assuming the choice of bins is neutral. Changing widths or boundaries can change which observations are combined and therefore change the plotted summaries. The plot is a descriptive view of the chosen grouping, not a unique summary dictated by the data.
- Reading within-bin detail from a single summary. A mean or median hides the spread and arrangement of responses in its bin. Use the raw observations or another display when that detail matters.
Binned summaries are descriptive tools; calculating them requires no regression model or distributional assumption. They can make a broad pattern easier to inspect, especially when individual points overlap, but they do not establish that changing the predictor causes a change in the response. Their usefulness depends on clear bin definitions, appropriate summaries, and attention to how many observations each plotted value represents.
Check Your Understanding
Use these questions to check your understanding of binned summaries.
- A bin contains response values 3, 5, 8, and 12. Calculate its mean and median.
- What is one advantage and one limitation of using equal-count bins rather than equal-width bins?
- Why should a plot or its caption state how observations on bin boundaries are assigned?
- A response mean is plotted at the midpoint of its predictor interval. Does that imply an observed response was recorded at that midpoint? Explain.
- Two bins have the same response mean but counts of 4 and 80. Why is it useful to display or report both counts?
- When might the median be more informative than the mean as a bin summary, and what information does the median still leave out?