Why the Data Centroid Lies on the Fitted Line
A fitted regression line summarizes the relationship between observed predictor values \(x_1,\ldots,x_n\) and response values \(y_1,\ldots,y_n\). One useful check on a least-squares calculation is that, when the line includes a freely estimated intercept, it passes through the point of sample means, \((\bar{x},\bar{y})\). This point is called the data centroid.
The result follows directly from the equation used to estimate the intercept. It is not an extra assumption about the data, nor does it require the observations to lie close to a straight line. The key qualification is that the fitted line is obtained by minimizing squared errors while allowing its intercept to vary.
The Intercept Normal Equation
For a fixed set of observed pairs, define the sum of squared errors for a candidate intercept \(a\) and slope \(b\) by
The least-squares estimates \((\hat{\beta}_0,\hat{\beta}_1)\) are values of \(a\) and \(b\) that minimize \(Q(a,b)\). The line includes an intercept, and both coefficients are estimated without constraints. Assume there is variation in the predictor, so at least two \(x_i\) values differ. Under this condition the least-squares slope and intercept are uniquely determined.
To obtain the equation for the intercept, hold \(b\) fixed and differentiate \(Q(a,b)\) with respect to \(a\). At a minimum, this partial derivative must be zero:
Substitute the minimizing values \(\hat{\beta}_0\) and \(\hat{\beta}_1\), then divide by \(-2\). The result is the intercept normal equation:
Expanding the sum gives \(\sum y_i-n\hat{\beta}_0-\hat{\beta}_1\sum x_i=0\). Divide by \(n\), and use the definitions of the sample means:
The fitted value at \(x=\bar{x}\) is therefore
Thus the least-squares line passes through \((\bar{x},\bar{y})\). This derivation uses only the intercept normal equation; it does not depend on a particular formula for calculating the slope.
Write the objective as \(Q(a,b)=\sum(y_i-a-bx_i)^2\) for a line with a freely estimated intercept.
Set the derivative with respect to \(a\) equal to zero, which gives \(\sum(y_i-\hat{\beta}_0-\hat{\beta}_1x_i)=0\).
Divide by \(n\) and rearrange to get \(\hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x}\).
Substituting \(\bar{x}\) into the fitted line gives \(\hat{y}(\bar{x})=\bar{y}\), so the line contains the centroid.
Worked Applications
Worked Example: Finding the Centroid From Raw Data
A hypothetical analyst relates a facility’s weekly maintenance hours \(x\) to its weekly operating cost \(y\), measured in hundreds of dollars. The four observed pairs are \((1,3)\), \((2,5)\), \((4,6)\), and \((5,10)\). Find the least-squares line and verify that it passes through the centroid. Use the ordinary least-squares line with a freely estimated intercept; no probability distribution is needed for this calculation.
Step 1: Calculate the sample means. The predictor total is \(1+2+4+5=12\), so \(\bar{x}=12/4=3\). The response total is \(3+5+6+10=24\), so \(\bar{y}=24/4=6\). The centroid is \((3,6)\).
Step 2: Calculate the slope. For these observations, the least-squares slope is the sum of the products of deviations divided by the sum of squared predictor deviations. The deviations are \(x_i-\bar{x}=(-2,-1,1,2)\) and \(y_i-\bar{y}=(-3,-1,0,4)\). Thus the numerator is \((-2)(-3)+(-1)(-1)+(1)(0)+(2)(4)=6+1+0+8=15\). The denominator is \((-2)^2+(-1)^2+1^2+2^2=4+1+1+4=10\). Therefore, \(\hat{\beta}_1=15/10=1.5\).
Step 3: Calculate the intercept. The intercept normal equation gives \(\hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x}=6-(1.5)(3)=6-4.5=1.5\). The fitted line is \(\hat{y}=1.5+1.5x\).
Step 4: Check the centroid. At \(x=3\), the fitted value is \(1.5+(1.5)(3)=1.5+4.5=6\), which equals \(\bar{y}\). The line passes through \((3,6)\). This check also confirms the intercept calculation.
Method and trap avoided. The slope was calculated from centered deviations and the intercept from the intercept normal equation. A common error is to report \(\hat{\beta}_0=6+4.5=10.5\); the correct rearrangement subtracts the slope contribution, giving \(6-4.5=1.5\).
Worked Example: Verifying the Property From Summary Statistics
A hypothetical portfolio team summarizes a sample of five service locations with \(\sum x_i=30\), \(\sum y_i=47\), \(\sum x_i^2=220\), and \(\sum x_iy_i=320\). Calculate the fitted line and check its value at the average predictor. Assume an ordinary least-squares fit with intercept and nonconstant predictor values.
Step 1: Find the means. With \(n=5\), \(\bar{x}=30/5=6\) and \(\bar{y}=47/5=9.4\).
Step 2: Find the centered sums. The sum of squared predictor deviations is \(S_{xx}=\sum x_i^2-(\sum x_i)^2/n=220-30^2/5=220-180=40\). The sum of cross-deviations is \(S_{xy}=\sum x_iy_i-(\sum x_i)(\sum y_i)/n=320-(30)(47)/5=320-282=38\).
Step 3: Find the slope and intercept. The least-squares slope is \(\hat{\beta}_1=S_{xy}/S_{xx}=38/40=0.95\). The intercept is \(\hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x}=9.4-(0.95)(6)=9.4-5.7=3.7\). The fitted line is \(\hat{y}=3.7+0.95x\).
Step 4: Check the fitted value at \(\bar{x}\). The line gives \(\hat{y}(6)=3.7+(0.95)(6)=3.7+5.7=9.4=\bar{y}\). Therefore, it passes through the centroid \((6,9.4)\).
Method and trap avoided. The slope uses centered sums, so the cross-deviation calculation subtracts \((\sum x_i)(\sum y_i)/n=282\) from 320. Omitting that correction would produce an incorrect slope and an intercept inconsistent with the centroid check.
Worked Example: Rescaling the Predictor Without Losing the Centroid Check
A hypothetical analyst has already fitted the line \(\hat{y}=5+2.5x\), where \(x\) is measured in units of ten operating hours and \(y\) is a response measured in stated units. The sample mean of the original predictor is \(\bar{x}=20\), and the sample response mean is \(\bar{y}=55\). The analyst now defines a rescaled predictor \(x'=x/10\). Find the line in terms of \(x'\), and verify the centroid property. Assume the original line is an ordinary least-squares fit with an intercept.
Step 1: Check the original line. At the sample mean \(x=20\), the fitted value is \(5+(2.5)(20)=5+50=55\), equal to \(\bar{y}\). The original centroid is \((20,55)\).
Step 2: Express the line using the new predictor. Since \(x'=x/10\), the original predictor is \(x=10x'\). Substitute this into the line: \(\hat{y}=5+2.5(10x')=5+25x'\). The new slope is 25, not 2.5, because one unit of \(x'\) represents ten units of \(x\).
Step 3: Transform the centroid and check the fitted value. The rescaled sample mean is \(\bar{x}'=20/10=2\). At \(x'=2\), the transformed line gives \(5+25(2)=5+50=55=\bar{y}\). It passes through the transformed centroid \((2,55)\).
Method and trap avoided. Replace \(x\) by \(10x'\) in the original equation; do not merely divide the slope by ten. The correct transformed slope is \(2.5\times10=25\), and the fitted value at the mean remains 55.
When the Result Applies—and What It Does Not Say
The centroid property is a consequence of fitting a line by least squares with an unrestricted intercept. It is an exact algebraic identity for the observed sample, even if the data are scattered widely around the line. It does not say that every observation lies on the line, that the relationship is causal, or that the fitted value at each observed \(x_i\) equals its observed \(y_i\).
The condition about the intercept matters. If a fitting procedure fixes the intercept in advance rather than estimating it, the derivative with respect to the intercept is not part of the optimization. The intercept normal equation used above then does not follow, so the centroid conclusion cannot be assumed. Likewise, if all predictor values are identical, there is no unique slope: the unique-line condition fails, and the ordinary formula for the slope based on \(S_{xx}\) has a zero denominator. The standard centroid result is stated for a uniquely determined least-squares line with an intercept.
The result is useful in practice because it provides a quick audit. After calculating the slope, find the intercept from \(\hat{\beta}_0=\bar{y}-\hat{\beta}_1\bar{x}\). Then substitute \(\bar{x}\) into the line. If the resulting fitted value differs from \(\bar{y}\), check the arithmetic, the sign in the intercept formula, and whether the calculation actually used a freely estimated intercept.
Check Your Understanding
For each problem, use the stated least-squares setup and check the fitted value at the sample mean of the predictor.
- A sample has \(n=4\), \(\sum x_i=12\), \(\sum y_i=20\), \(\sum x_i^2=44\), and \(\sum x_iy_i=70\). For a least-squares line with an intercept, find the slope and intercept and verify the centroid. (Answer: \(\bar{x}=3\), \(\bar{y}=5\), \(\hat{\beta}_1=1.25\), \(\hat{\beta}_0=1.25\), and \(\hat{y}(3)=5\).)
- A fitted line has slope \(-0.8\), and the sample means are \(\bar{x}=4\) and \(\bar{y}=12\). Find the intercept and fitted value at \(\bar{x}\). (Answer: \(\hat{\beta}_0=15.2\), and \(\hat{y}(4)=12\).)
- A line fitted with an intercept has slope \(0.3\), \(\bar{x}=40\), and \(\bar{y}=18\). Define \(z=x/20\). Find the transformed slope, the transformed sample mean, and the fitted value there. (Answer: the transformed line is \(\hat{y}=6+6z\), \(\bar{z}=2\), and \(\hat{y}(2)=18\).)
- For the three observations \((0,4)\), \((2,5)\), and \((3,10)\), calculate the least-squares line with an intercept and verify the centroid. (Answer: \(\bar{x}=5/3\), \(\bar{y}=19/3\), \(\hat{\beta}_1=25/14\), \(\hat{\beta}_0=47/14\), and \(\hat{y}(5/3)=19/3\).)
- A data set has \(n=5\), \(\bar{x}=8\), \(\bar{y}=14\), \(S_{xx}=25\), and \(S_{xy}=-15\), where \(S_{xx}=\sum(x_i-\bar{x})^2\) and \(S_{xy}=\sum(x_i-\bar{x})(y_i-\bar{y})\). Find the least-squares line and its fitted value at \(\bar{x}\). (Answer: \(\hat{\beta}_1=-0.6\), \(\hat{\beta}_0=18.8\), and \(\hat{y}(8)=14\).)