DESCRIPTIVE DATA CHECKS

Checking a fitted line at the mean predictor value

A least-squares line with an intercept always passes through the point made of the mean of x and the mean of y. This guide verifies that for three points and a four-point example.

Locating the mean point

The data are x = 0, 1, 2 and y = 0, 2, 1. The mean of x is 1 and the mean of y is 1, so the mean point is (1, 1). The regression calculator fits y = 0.5 + 0.5x, with slope 0.5 and intercept 0.5. Substituting x = 1 gives 0.5 + 0.5 × 1 = 1, which equals the mean of y. The line passes through the mean point. It does not pass through the data points themselves: at x = 0 it predicts 0.5 against an observed 0, at x = 2 it predicts 1.5 against an observed 1, and only the middle point, which happens to coincide with the mean, is on the line.

Why it must pass through the means

The least-squares slope is b = sum((x - x̄)(y - ȳ)) / sum((x - x̄)²), and the intercept is chosen as a = ȳ - b × x̄. Rearranging, a + b × x̄ = ȳ, which says that the line evaluated at the mean of x gives the mean of y. This is not an extra assumption. It follows from minimizing the squared residuals with respect to the intercept, which forces the residuals to sum to zero, and a zero residual sum means the average predicted value equals the average observed value. Both the formula and the derivation lead to the same fact, which is why the page lists the two means next to the fitted coefficients.

A four-point example

Take x = 1, 2, 3, 4 and y = 2, 4, 5, 9. The means are 2.5 and 5. The deviations of x are -1.5, -0.5, 0.5, 1.5 and of y are -3, -1, 0, 4. The products add up to 4.5 + 0.5 + 0 + 6 = 11, and the squared x deviations add up to 5. The slope is 11/5 = 2.2 and the intercept is 5 - 2.2 × 2.5 = -0.5. The line is y = -0.5 + 2.2x. At x = 2.5 it predicts -0.5 + 5.5 = 5, the mean of y. The fitted intercept is negative here, and a line through the mean point can easily cross the vertical axis well below the observed data.

Reading the intercept correctly

The intercept is the predicted value at x = 0, which is often outside the range of observed x. In the four-point example the data span x from 1 to 4, and the intercept at 0 is an extrapolation. If x measures years since 2000 or a temperature in degrees Celsius, the zero point may be meaningless. For interpretation, the mean point is often the safest anchor: the line says that when x is at its average, y is predicted at its average, and the slope says how y changes per unit of x around that point. In the three-point example that means each extra unit of x goes with half a unit more y, starting from the average of 1. Centering x by subtracting its mean before fitting makes the intercept equal the mean of y.

Leverage of the mean point

Because the line is pinned at the mean point, changing the slope rotates it around that point, and predictions near the mean of x are less sensitive to slope errors than predictions far from it. This is why confidence bands around a fitted line are narrowest at the mean of x and widen toward both ends. For the three-point example, a slope error of 0.1 shifts the prediction at x = 1 by nothing and the prediction at x = 0 or 2 by 0.1. Extrapolating far beyond the observed x values multiplies the slope uncertainty by the distance from the mean.

What changes without an intercept

The property depends on the model including an intercept. A line forced through the origin, y = bx, uses b = sum(xy) / sum(x²). For the three-point data that is 4/5 = 0.8, and at x = 1 the line gives 0.8, not the mean of y. Zero-intercept fits are sometimes the right physical model, such as distance traveled at constant speed starting from zero, but they are a different calculation and lack the mean-point property. Spreadsheet trendline options let you set the intercept to zero, so check whether that box was ticked before you apply the mean-point check to someone else's fit.

Centering and the mean point

Subtracting the mean of x from every x value before fitting moves the mean point onto the vertical axis. For the four-point example, the centered x values are -1.5, -0.5, 0.5 and 1.5. The slope stays 2.2, and the intercept becomes 5, the mean of y. In this form the intercept needs no extrapolation and has a direct meaning: it is the predicted y at the average x. Centering also removes the correlation between the estimates of slope and intercept, which simplifies uncertainty calculations, and it avoids numerical trouble when x values are large, for example years such as 2021, 2022 and 2023, where the raw intercept sits far from the data and loses digits.

Using the property as a check

The property gives a quick test of a computed regression. Compute the mean of x and the mean of y, then evaluate the fitted line at the mean of x. If the result differs from the mean of y by more than rounding, the coefficients are wrong, or the fit was not a standard least-squares line with an intercept. The page does this with two extra calls to the average calculator, one for x and one for y. Legendre published the least-squares method in 1805, and Gauss later claimed earlier use, but the mean-point property has been a standard consistency check ever since.

What the property does not tell you

Passing through the means says nothing about how close the line comes to the individual points. In the three-point example the residuals are -0.5, 1 and -0.5, and the fit is mediocre. A line through the mean point can be a very poor description of the data if the relationship is curved or if outliers pull the slope. The property is a feature of the calculation, not a measure of quality, and the page selects no threshold for accepting a fit. To judge quality, look at the residuals and a magnitude summary, such as the root-mean-square residual, and plot the data with the line. Two different data sets can have the same mean point and the same fitted line while looking nothing alike.

Reproduce the checks

Fitted coefficients

Open the Linear Regression Calculator and enter:

X observations
0,1,2
Y observations
0,2,1

Expected output:

Slope

0.5

Intercept

0.5

The intercept centers the fitted line at the paired means.

Predictor mean

Open the Average calculator and enter:

Values
0,1,2

Expected output:

Arithmetic mean

1

This supplies the mean x coordinate.

Response mean

Open the Average calculator and enter:

Values
0,2,1

Expected output:

Arithmetic mean

1

The fitted line passes through this mean response.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Sources

Related tasks