AP Statistics · Unit 5 · Regression Analysis
5.5 Least-squares regression
Describe how the least-squares line is chosen, explain what least-squares means, and find the line from formulas or technology.
1/5A rule is needed to choose the best-fitting line
- A rule is needed to choose the best-fitting line
- The least-squares line minimizes the sum of squared residuals
- The slope and intercept follow from summary statistics
- Technology finds the line faster than hand calculation
- The line passes through the means and balances residuals
- Check your recall
- Practice: 10 questions
Part 1 of 5: A rule is needed to choose the best-fitting line
Residuals show how far a line misses each point. Two different lines through the same scatterplot give two different sets of residuals. We need one rule that picks a single best line.
Simply adding the residuals does not work, because positive and negative values cancel. A poor line can still have residuals that sum to zero. A flat line at the mean of does exactly that.
A better rule must treat misses above and below the line alike. It should also work for any data set.
Part 2 of 5: The least-squares line minimizes the sum of squared residuals
Squaring each residual solves the cancellation problem. Every squared value is positive, and larger misses count for much more. Adding the squares gives the sum of squared residuals, written .
Among all straight lines, one gives the smallest total. We call it the least-squares regression line. Here least refers to that total, not to any single residual.
Squaring also means one large miss costs more than several small ones. The line therefore works hard to avoid big residuals. This is why the method is named after squares.
Worked example
Compare two lines
- Line A predictions: 2.8, 3.4, 4.0, 4.6, 5.2. Residuals: .
- Line A total: .
- Line B predictions: 2.7, 3.4, 4.1, 4.8, 5.5. Residuals: .
- Line B total: .
Answer: Line A has the smaller total, against , so it fits better by the least-squares rule.
Key terms · tap one for its definition
sum of squared residuals
The sum of squared residuals is the total found by squaring every residual and adding the results.
least-squares regression line
The least-squares regression line is the unique line that makes the sum of squared residuals as small as possible for the data.

Quick check
One question on the part you just read
Easy
Show answer and explanation
Answer: A · Worked explanation
Part 3 of 5: The slope and intercept follow from summary statistics
You do not have to test every possible line. The slope is . Here is the correlation, a measure of linear association. The values and are the sample standard deviations of and . Slope has units of per unit of , which is why the ratio appears.
The intercept is , where and are the means. This forces the line through the point .
Worked example
Find the line from summary statistics
- Slope: .
- Calculate: , so .
- Intercept: .
- Write the line: .
Answer: The line is , with in hours studied and the predicted quiz score in points.
Part 4 of 5: Technology finds the line faster than hand calculation
In practice, a calculator or statistical software does the arithmetic. Your job is to enter the data correctly and read the output.
- Enter the values in one list and the values in another.
- Run the linear regression command, often labeled LinReg(a+bx) on a graphing calculator.
- Read and from the output.
- Write and define both variables in context.
Computer output often shows a table of coefficients. The intercept appears in the row labeled Constant. The slope appears in the row named for the explanatory variable.

Quick check
One question on the part you just read
Easy
Show answer and explanation
Answer: A · Worked explanation
Part 5 of 5: The line passes through the means and balances residuals
Now that the line is defined, some useful properties follow. The least-squares line always passes through . Its residuals always sum to zero.
The figure shows the study-time data with its line. Each vertical segment is a residual. The positive residuals add to 1.6, and the negative residuals add to -1.6.
The squares also make the line sensitive to unusual points. A point far from the pattern has a large residual, and squaring magnifies it. Such a point can pull the line toward itself. Check unusual points before trusting the equation.
Check your recall[12 marks]
5 written questions. Answer each one in your head or on paper, then open the mark scheme.
- 1.Describe[2 marks]
Describe how the least-squares regression line is chosen from all possible lines.
Show mark schemeHide mark scheme
Model answer
Each residual is squared and the squares are added. The chosen line is the one with the smallest sum of squared residuals.
- 1 mark for stating that residuals are squared and added
- 1 mark for stating that the line with the smallest sum of squared residuals is chosen
- 2.Explain[2 marks]
Explain why residuals are squared before they are added when choosing a line.
Show mark schemeHide mark scheme
Model answer
Positive and negative residuals would cancel if simply added. Squaring makes every value positive, so misses above and below the line both count, and large misses count more.
- 1 mark for stating that positive and negative residuals would cancel
- 1 mark for explaining that squaring makes all values positive (and gives large misses more weight)
- 3.Calculate[3 marks]
Data have , , , , and . Calculate the least-squares line.
Show mark schemeHide mark scheme
Model answer
. . The line is .
- 1 mark for calculating the slope
- 1 mark for calculating the intercept using the means
- 1 mark for writing the equation
- 4.Describe[2 marks]
Describe the steps for finding a least-squares regression line with technology.
Show mark schemeHide mark scheme
Model answer
Enter the values and the values into lists, run the linear regression command, and read the intercept and slope to write .
- 1 mark for entering the and data into lists
- 1 mark for running the regression command and reading and
- 5.Justify[3 marks]
For the same data, line A has a sum of squared residuals of 18.4 and line B has 21.7. Justify which line fits better, and say whether line A must be the least-squares line.
Show mark schemeHide mark scheme
Model answer
Line A fits better because its sum of squared residuals is smaller. Line A need not be the least-squares line, because another line might give an even smaller total.
- 1 mark for stating that line A has the smaller sum of squared residuals
- 1 mark for concluding that line A fits better by the least-squares rule
- 1 mark for stating that another untested line could have a smaller total, so line A is not necessarily the least-squares line

Practice this topic
10 quick-fire multiple-choice questions, easy to hard. Tap an answer to see if you're right and the worked explanation. (The written questions with mark schemes are under “Check your recall” above.)
0 right0 of 10 answered
Includes the 2 quick checks in the note above.
EasyIdentify[1 mark]
Show answer and explanation
Answer: A · Worked explanation
MediumCalculate[2 marks]
Show answer and explanation
Answer: A · Worked explanation
MediumCalculate[2 marks]
Show answer and explanation
Answer: A · Worked explanation
MediumDetermine[2 marks]
Show answer and explanation
Answer: A · Worked explanation
MediumIdentify[2 marks]
Show answer and explanation
Answer: A · Worked explanation
HardDetermine[2 marks]
Show answer and explanation
Answer: A · Worked explanation
HardExplain[2 marks]
Show answer and explanation
Answer: A · Worked explanation
HardPredict[2 marks]
Show answer and explanation
Answer: A · Worked explanation