Mathwords logoMathwords

Sum of Squares of the Residuals — Definition, Formula & Example

The sum of squares of the residuals (SSE) is a single number that measures how far a line misses the data overall. You square each residual and add the results. A smaller SSE means the line fits the points more closely.

For nn data points (xi,yi)(x_i, y_i) and a fitted line y^=a+bx\hat{y} = a + bx, the residual sum of squares is SSE=∑i=1n(yi−y^i)2\text{SSE} = \sum_{i=1}^{n} (y_i - \hat{y}_i)^2. The least-squares regression line is the unique line that minimizes this quantity over all choices of aa and bb.

Key Formula

SSE=∑i=1n(yi−y^i)2\text{SSE} = \sum_{i=1}^{n} \left(y_i - \hat{y}_i\right)^2
Where:
  • yiy_i = the actual (observed) response value for the i-th data point
  • y^i\hat{y}_i = the predicted value from the line at x_i
  • yi−y^iy_i - \hat{y}_i = the residual for the i-th point
  • nn = the number of data points

Worked Example

Problem: The data points are (1, 4), (2, 4), (3, 6), and (4, 10). The least-squares regression line for these data is y^=2x+1\hat{y} = 2x + 1. Find the SSE.
Step 1: Substitute each x-value into the line to get the predicted values.
y^1=3,y^2=5,y^3=7,y^4=9\hat{y}_1 = 3,\quad \hat{y}_2 = 5,\quad \hat{y}_3 = 7,\quad \hat{y}_4 = 9
Step 2: Find each residual as actual minus predicted.
4−3=1,4−5=−1,6−7=−1,10−9=14-3=1,\quad 4-5=-1,\quad 6-7=-1,\quad 10-9=1
Step 3: Square each residual and add the squares.
SSE=12+(−1)2+(−1)2+12=4\text{SSE} = 1^2 + (-1)^2 + (-1)^2 + 1^2 = 4
Answer: SSE = 4. This line is the least-squares line for these data, so no other line gives an SSE smaller than 4.

Why It Matters

In AP Statistics, SSE feeds directly into two numbers you report for every regression. The coefficient of determination is r2=1−SSE/SSTr^2 = 1 - \text{SSE}/\text{SST}, where SST is the total sum of squares ∑(yi−yˉ)2\sum (y_i - \bar{y})^2. The standard deviation of the residuals is s=SSE/(n−2)s = \sqrt{\text{SSE}/(n-2)}.

Common Mistakes

Mistake: Adding the residuals without squaring them and getting 0, then concluding the line fits perfectly.
Correction: For a least-squares line, the residuals always sum to 0, because positive and negative errors cancel. Squaring makes every term nonnegative, so SSE equals 0 only when every point lies exactly on the line.

Related Terms