All AP Courses AP StatisticsAP Stats

Unit 5 · Topic 5.5 · about 25 minutes

AP Statistics 5.5: Least-Squares Regression

Get the least-squares regression line from technology and interpret its slope, y-intercept and coefficient of determination in context.

Unit 5: 10 to 20% of the multiple-choice section

What you'll be able to do

  • Calculate the slope and y-intercept of the least-squares regression line.
  • Interpret the slope and y-intercept of the least-squares regression line in context.

Key vocabulary

TermWhat it meansThe exam trap
Least-squares regression lineThe line that makes the sum of the squared residuals as small as possible. It always passes through (x‾,y‾).Passing through data points earns nothing: Jordan's Line A hits two points exactly and still loses, with a sum of squares of 3.875 against 3.60.
Slope bThe predicted increase or decrease in the response variable for each one-unit increase in the explanatory variable.On a TI-84, LinReg(ax+b) reports the slope as a, which is how the slope ends up reported as the intercept.
Y-intercept aThe predicted value of the response variable when the explanatory variable equals 0.A size of 0 square feet is far outside apartments of 450 to 1,400 square feet, so the rent model's intercept of 462.14 dollars has no reasonable meaning.
Coefficient of determination r2The proportion of the variation in the response variable that is explained by the linear relationship with the explanatory variable.Taking the square root of r2 gives only the size of r. Its sign comes from the slope.
ConstantThe row of regression output that holds the y-intercept a. The slope is in the row named for the explanatory variable.The S and R-Sq values printed under the table are not coefficients, and using either one as the slope gives a wrong prediction.

Predict first

Three students each draw a line through the same scatterplot, and each claims to have the best one. Which rule do statisticians use to settle the argument?

What least squares means

Every line drawn through a scatterplot leaves residuals. Squaring them does two jobs. Every miss counts as positive, so misses above the line cannot cancel misses below it. And a big miss counts far more than a small one. Out of all possible lines, exactly one makes the sum of the squared residuals as small as it can be. That line is the least-squares regression line, often shortened to LSRL.

Jordan recorded the most pull-ups he could do in each of his first five weeks of training: 2, 5, 4, 7 and 9. Line A connects his first week to his fifth. Line B is the least-squares line.

Line A: y^=0.25+1.75x. Line B: y^=0.6+1.6x.
Week, xPull-ups, yLine A residualLine A squaredLine B residualLine B squared
1200−0.20.04
251.251.56251.21.44
34−1.52.25−1.41.96
47−0.250.062500
59000.40.16
Sum of squares3.8753.60

Line A hits two of the points exactly and still loses, 3.875 to 3.60. No line through these five points does better than 3.60. That is what the least-squares line guarantees.

You will not find the least-squares line by trying lines one at a time, or by hand at all. A calculator or software computes the slope b, the y-intercept a and the correlation r from the data.

One fact about the line is worth knowing without technology: it always passes through the point (x‾,y‾). Jordan's averages are x‾=3 weeks and y‾=5.4 pull-ups, and Line B gives 0.6+1.6(3)=5.4 exactly.

Jordan's five weeks with the least-squares line

2468Most pull-ups in one set12345Week of training

The line passes through (3,5.4), the point of averages, even though no week landed there.

Reading regression output

Software prints the least-squares line as a small table. This output comes from 15 apartments in one city, with floor area in square feet used to predict monthly rent in dollars.

Regression output: monthly rent against size for 15 apartments
PredictorCoef
Constant462.14
Size1.2148

Under the table, the output adds S = 174.61 and R-Sq = 80.8%.

  • The Constant row holds the y-intercept, a=462.14.
  • The row named for the explanatory variable holds the slope, b=1.2148.
  • R-Sq is r2, the coefficient of determination, written as a percent. It is the proportion of the variation in the response variable that is explained by the linear relationship with the explanatory variable.

So the model is rent^=462.14+1.2148(size). Output usually prints more than you need. S is not part of this course, so find the two coefficients and R-Sq and leave the rest.

Rent and size for 15 apartments, with the least-squares line

100015002000Monthly rent (dollars)600800100012001400Size (square feet)

Sizes run from 450 to 1,400 square feet. A size of 0 is far off the left edge of the data.

Worked exampleInterpreting the rent model

Use the output above. Interpret the slope, the y-intercept and r2 in context, and find the correlation r.

  1. Slope. For each additional square foot of floor area, the predicted monthly rent increases by about 1.21 dollars. A square foot is small, so scaling up can help: 100 more square feet goes with about 121 dollars more in predicted rent.

  2. Y-intercept. An apartment with 0 square feet has a predicted rent of 462.14 dollars. That has no reasonable meaning here. The apartments ranged from 450 to 1,400 square feet, so a size of 0 is far outside the data, and an apartment with no floor area does not exist.

  3. r2. About 80.8% of the variation in monthly rent is explained by the linear relationship with floor area. The other 19.2% is variation the line does not account for, from things like location and the age of the building.

  4. Correlation. r=0.808≈0.899. It is positive because the slope is positive; both describe the same upward direction.

Answer.

Slope: about 1.21 dollars more in predicted rent for each additional square foot. Intercept: no sensible meaning, since 0 square feet is far outside the data. r2=0.808: about 80.8% of the variation in rent is explained by the linear relationship with size. r≈0.899.

Lab

Regression Playground

Set Show to Squared residuals. Each residual becomes a square, and the least-squares line makes their total area as small as possible. Then switch Show to My line vs least squares and drag the ends of your line to try to beat it. You can get close, but you cannot win.

Open the full Regression Playground lab

Check your understanding

1

A model predicts a car's highway gas mileage (miles per gallon) from its weight (thousands of pounds). For this model, r2=0.72. Which is the correct interpretation?

2

The least-squares line for predicting how many minutes a phone's battery lasts from its screen brightness setting (percent) is y^=640−3.8x. Which is the correct interpretation of the slope?

3

For 40 students, the mean number of hours spent studying for a test is 6.2 and the mean test score is 81.5. The least-squares line for predicting score from hours studied has slope 2.4. What score does the line predict for a student who studied 6.2 hours?

4

A teacher used data from 35 students to predict the final course grade (percent) from the number of absences. Computer output for the least-squares regression is shown.

PredictorCoefConstant98.6Absences−2.35S=6.41R-Sq=49.0%

What final grade does the model predict for a student with 6 absences?

5

Each model below was fit to the data described. For which model does the y-intercept have a reasonable interpretation in context?

Exam strategy for this topic

  • Section I, Multiple Choice: 42 questions in 90 minutes.
  • Section II, Free Response: 4 questions in 90 minutes.
  • A graphing calculator with statistical capabilities is expected on both sections.

Questions students ask

Why square the residuals instead of just adding them?

Squaring makes every miss count as positive, so misses above the line cannot cancel misses below it. It also makes a big miss count far more than a small one.

Do I have to compute the slope and intercept by hand?

No. A calculator or software computes a, b and r from the data. On a TI-84, use LinReg(a+bx) so the letters match y^=a+bx.

What is useful about the line passing through (x‾,y‾)?

It gives one prediction for free. If students averaged 6.2 hours of study and a mean score of 81.5, the least-squares line predicts 81.5 for a student who studied 6.2 hours.

How do I get r from r2?

Take the square root and give it the sign of the slope. For the rent model, r=0.808≈0.899, positive because the slope is positive.

Are a and b parameters?

No. They are calculated from one sample, so they are statistics. A different set of 15 apartments from the same city would give a slightly different line.

When does the y-intercept make sense?

When an x-value of 0 is possible and inside the data. A pizza with 0 toppings is a plain cheese pizza, so that model's intercept is a sensible predicted price.

Course alignment, for teachers

AP Statistics topic 5.5, Unit 5: Regression Analysis.

  • Skill 3.B: Calculate summary statistics, relative positions of points within a distribution, and predicted responses.
  • Skill 4.D: Interpret statistical calculations and results to assess meaning or a claim.