AP Statistics · Lesson 2

Least-squares regression

Know Know it

A regression line y^=a+bx\hat{y} = a + bx gives a predicted value y^\hat{y} for each x. The hat says it is a prediction, not an observed value.

The least-squares regression line is the line that makes the sum of the squared residuals as small as possible. Its slope is b=rsysxb = r \frac{s_y}{s_x}, and it always passes through the point (xˉ,yˉ)(\bar{x}, \bar{y}), so a=yˉ−bxˉa = \bar{y} - b\bar{x}.

Slope: for each 1-unit increase in x, the predicted y changes by b. Intercept: the predicted y when x = 0, which only makes sense if x = 0 is reasonable and close to the data.

Computer output: the row labeled Constant gives a, and the row named for the explanatory variable gives b. S and R-sq describe how well the line fits (next lesson).

Regression output for free-throw percentage (y) on weekly practice hours (x), 10 players
PredictorCoef
Constant50.33
Practice hours2.830

Calculator On the exam

A graphing calculator with statistical capabilities is expected on both sections of the exam, and one is built into the testing app. The exam also gives a reference booklet of formulas, including the slope and intercept of the least-squares line.

Enter the data in two lists and run a linear regression to get a, b, r and r-squared. On free-response questions, also write the equation with the variable names in context.

Trap Do not predict far outside the data

A line fit to x-values from 3 to 10 says nothing reliable about x = 30. The pattern may bend or stop outside the data. This is extrapolation, and it often gives silly answers, such as a negative count or an impossible height.

Worked example Easy

A regression of free-throw percentage on weekly practice hours (x) gives y^=50.33+2.830x\hat{y} = 50.33 + 2.830x. What is the predicted free-throw percentage for a player who practices 6 hours a week?

  1. 16.98
  2. 53.16
  3. 56.33
  4. 67.31Answer

How to solve it

  1. Read a = 50.33 from the Constant row and b = 2.830 from the Practice hours row.
  2. Substitute x = 6: 50.33+2.830×650.33 + 2.830 \times 6.
  3. 2.830×6=16.982.830 \times 6 = 16.98, so y^=67.31\hat{y} = 67.31 percent.

Why each choice is right or wrong

  • A. Incorrect. 16.98 is only 2.830×62.830 \times 6; it leaves out the intercept 50.33.
  • B. Incorrect. 53.16 adds the slope once, 50.33 + 2.830, as if the player practiced 1 hour, not 6.
  • C. Incorrect. 56.33 adds 6 to the intercept, but x must be multiplied by the slope before adding.
  • D. Correct. y^=50.33+2.830(6)=50.33+16.98=67.31\hat{y} = 50.33 + 2.830(6) = 50.33 + 16.98 = 67.31 percent.

Explain Explain it

Task verbs: interpret, calculate

Interpret the slope with the word predicted and both variables: for each additional hour of weekly practice, the predicted free-throw percentage increases by about 2.83 percentage points.

Interpret the intercept the same way: a player who practices 0 hours has a predicted free-throw percentage of 50.33. Then ask whether x = 0 is in or near the data; if not, say the intercept has no useful meaning here.

Calculate the slope from summaries with b=rsysxb = r \frac{s_y}{s_x}, then the intercept with a=yˉ−bxˉa = \bar{y} - b\bar{x}.

Worked example Medium

For a set of data, r = 0.6, the standard deviation of x is 4 and the standard deviation of y is 10. What is the slope of the least-squares line for predicting y from x?

  1. 0.24
  2. 1.5Answer
  3. 2.5
  4. 6

How to solve it

  1. The slope formula is b=rsysxb = r \frac{s_y}{s_x}.
  2. sysx=104=2.5\frac{s_y}{s_x} = \frac{10}{4} = 2.5.
  3. b=0.6×2.5=1.5b = 0.6 \times 2.5 = 1.5.

Why each choice is right or wrong

  • A. Incorrect. 0.24 uses rsxsyr \frac{s_x}{s_y}, which is the slope for predicting x from y, not y from x.
  • B. Correct. b=rsysx=0.6×104=1.5b = r \frac{s_y}{s_x} = 0.6 \times \frac{10}{4} = 1.5.
  • C. Incorrect. 2.5 is sysx\frac{s_y}{s_x} alone; the ratio still has to be multiplied by r = 0.6.
  • D. Incorrect. 6 multiplies r by sys_y but never divides by sx=4s_x = 4.

Interpret Your turn

A fictional bike-share program fits predicted daily rentals = 210 + 14.5(high temperature in degrees Celsius), using days with highs from 8 to 32 degrees Celsius. Interpret the slope and the intercept in context, and say whether the intercept is useful here.

Write it, then compare. Nothing you type here is saved or graded.

Compare with a model answer

A full answer does this

  • Interprets the slope: for each 1-degree increase in high temperature, predicted daily rentals increase by 14.5
  • Interprets the intercept: 210 is the predicted number of daily rentals on a day with a high of 0 degrees Celsius
  • Says the intercept is not useful because 0 degrees is outside the 8 to 32 degree range of the data

Model answer

Slope: for each 1-degree Celsius increase in the daily high temperature, the predicted number of daily rentals increases by 14.5. Intercept: on a day with a high of 0 degrees Celsius, the line predicts 210 rentals. That value is not useful here, because the data only cover highs from 8 to 32 degrees, so using the line at 0 degrees is extrapolation.

Apply Apply it

Practice this topic. AP Practice questions on exactly what this lesson covers, with an explanation for every answer.