Educerie

Educerie · AP · Statistics

AP Statistics 5.5

Least-Squares Regression

How can we describe the relationship between two quantitative variables, and how well can one be used to predict the other?

What you will learn

  • Understand that the least-squares line minimizes the sum of the squared residuals and passes through the point of the two means
  • Know that the slope, intercept, r and r squared come from technology, and that a and b are statistics because they come from a sample
  • Understand how to interpret the slope and the intercept in context, and when the intercept has no sensible meaning
  • Know that r squared is the proportion of variation in the response explained by the linear relationship

You must be able to

  1. Interpret the slope in context with predicted, the direction, the amount, the units and for each additional one unit
  2. Interpret the y-intercept, or explain why it has no sensible meaning
  3. Interpret r squared as the proportion of variation in the response explained by the linear relationship
  4. Find r from r squared and the sign of the slope
  5. Read a, b, r and r squared from technology output
  6. State what makes the line least squares and where it passes

In the exam. Section I gives a fitted equation with r and r2r^{2} and asks which statement is the correct interpretation of the slope, the intercept or r2r^{2}, usually inside the regression set of three. Section II can ask you to read the slope, intercept, r and r2r^{2} off technology output and to interpret them in context, in words that carry the context mark.

1Which line is "best"?

Any scatterplot with a linear pattern allows many lines. The residual tells how far a line misses each dot (5.4). The least-squares line is chosen so that the total of the squared residuals is as small as possible.

Why square them? Residuals above and below the line have opposite signs and would cancel in a plain sum. Squaring makes every one positive, and it counts a big miss as much worse than a small one.

Figure 1 is invented data for 10 runners: the distance each runs per week, and the time each takes for a 10 km race.

Figure 1. 10 km race time against weekly distance for 10 runners, with the least-squares line: the line passes through the point (x-bar, y-bar) = (32.5, 54.32), marked on the line 0 10 20 40 50 60 40 45 50 60 65 70 10 km time (min) Weekly distance (km) 32.5 54.3 Least-squares line (x̄, ȳ)
Figure 1 · 10 km race time against weekly distance for 10 runners, with the least-squares line and the point of the means

Technology fits the line to the data. Figure 2 compares it with a second line.

Figure 2. Two lines through the same 10 points with a square drawn on every residual: the least-squares line on the left has the smaller total area of squares, and no other line gives less (a) Least-squares line: total 19.1 0 20 40 60 40 50 60 70 10 km time (min) Weekly distance (km) Figure 2. Two lines through the same 10 points with a square drawn on every residual: the least-squares line on the left has the smaller total area of squares, and no other line gives less (b) Line through the end dots: total 25.7 0 20 40 60 40 50 60 70 10 km time (min) Weekly distance (km)
Figure 2 · A square on each residual for two lines: the least-squares line has the smaller total

Each square has a side equal to one residual, so its area is that residual squared. The lines in (a) and (b) are drawn on the same 10 dots. The total area of the squares is 19.1 for the least-squares line and 25.7 for the line through the two end dots. The least-squares line has the smaller total, and no other line has a smaller one. That is what "least squares" means.

2The equation, from technology

You use technology to calculate aa, bb, rr and r2r^{2}. The exam does not ask for a hand formula for either. Calculator output is often in this form:

OutputValueName in statistics
a65.79y-intercept
b−0.353-0.353slope
r2r^{2}0.931coefficient of determination
r−0.965-0.965correlation coefficient

The line for the runners is

y^=65.79−0.353x\hat{y} = 65.79 - 0.353x

where xx is the weekly distance in km and y^\hat{y} is the predicted 10 km time in minutes. Technology gives full-precision values. If you use rounded ones, rounding errors can show up in the last digit.

Prediction. For a runner who runs 40 km a week:

y^=65.79−0.353(40)=51.7predicted time in minutes\hat{y} = 65.79 - 0.353(40) = 51.7 \qquad \textcolor{#838c91}{\text{predicted time in minutes}}

Remember 5.3: this is interpolation, because 40 is between the 10 and 55 km in the data.

The line passes through (xˉ,yˉ)(\bar{x}, \bar{y}). The mean weekly distance is xˉ=32.5\bar{x} = 32.5 km and the mean time is yˉ=54.32\bar{y} = 54.32 minutes. Put 32.5 into the line and you get 54.32 back. Figure 1 marks this point on the line.

The slope and intercept are statistics, because they are calculated from a sample of values. A different sample of runners would give a slightly different line.

3Interpreting the slope

The slope bb is the predicted increase or decrease in the response for a one-unit increase in the explanatory variable. A good interpretation has five parts:

  1. "predicted" (or "on average"),
  2. the direction ("increase" or "decrease"),
  3. the amount, with units,
  4. "for each additional" one unit of xx, with its units,
  5. the variables, in context.

Worked example. The slope of the runners' line is −0.353-0.353.

For each additional kilometer a runner runs per week, the predicted 10 km race time decreases by about 0.353 minutes.

Over 10 extra kilometers a week the predicted time drops by about 3.5 minutes. The negative sign appears in the word "decreases", so you do not also write "negative decrease".

Careful.

  • Say "predicted" or "on average". Do not say "runners who run one more kilometer are 0.353 minutes faster", as if every runner followed it.
  • Use the units of both variables: minutes per kilometer run per week.
  • Do not say that running more causes the faster time. The data are observational.

4Interpreting the intercept

The y-intercept aa is the predicted value of the response when the explanatory variable is 0.

For a runner who runs 0 km a week, the predicted 10 km race time is 65.79 minutes.

Always ask whether x=0x = 0 makes sense in context. Two things can make an intercept meaningless.

  • x=0x = 0 is outside the data (extrapolation). The runners ran from 10 to 55 km a week. A weekly distance of 0 is beyond that, so the 65.79 minutes should not be relied on.
  • The value is impossible. Example (invented): the height of a bamboo shoot is modeled by y^=−4.1+2.6x\hat{y} = -4.1 + 2.6x with xx the number of days since it was first measured. At x=0x = 0 the model gives −4.1-4.1 cm, and a height cannot be negative. The intercept has no logical interpretation.

When this happens, say so: "the intercept is the predicted value at x=0x = 0, but this has no sensible meaning in context because ...". That earns the mark. A reasonable intercept (one that is possible and inside the data) is interpreted like the example above.

5Interpreting r2r^{2}

r2r^{2} = the square of the correlation coefficient, called the coefficient of determination.

r2r^{2} is the proportion of the variation in the response that the linear relationship with the explanatory variable accounts for. The exam word is "explained by".

For the runners, r2=0.931r^{2} = 0.931:

About 93.1% of the variation in 10 km race time is explained by the linear relationship with weekly distance.

The other 6.9% is variation the line does not explain: differences between runners with the same weekly distance.

Three things to keep right.

  • It is about the response. Variation in race time, not variation in distance.
  • It is about the linear relationship. Do not say "93.1% of the runners" or "93.1% of the dots are on the line", and do not say that distance "causes" 93.1% of the time.
  • It is not rr. r=−0.965r = -0.965 and r2=0.931r^{2} = 0.931. The sentence "93.1% of the variation" belongs to r2r^{2}, not to rr.

6From r2r^{2} back to r

r2r^{2} is positive whatever the direction, so it cannot tell you the sign of rr. The sign of rr is the sign of the slope, since both say whether the pattern rises or falls.

Worked example. A model has r2=0.64r^{2} = 0.64 and a negative slope. Then r=−0.64=−0.80r = -\sqrt{0.64} = -0.80.

For the runners, 0.931=0.965\sqrt{0.931} = 0.965, and the slope is negative, so r=−0.965r = -0.965. Check it against the table in section 3.

7Putting a full answer together

Here is an invented example of the kind of question that appears on the exam. A bakery records the price of a loaf (xx, in dollars, from 2.00 to 5.00) and the loaves sold in a week (yy). Technology gives y^=412−58x\hat{y} = 412 - 58x, with r2=0.77r^{2} = 0.77.

  • Slope: for each additional dollar of price, the predicted number of loaves sold in a week decreases by about 58.
  • Intercept: the predicted number of loaves sold at a price of 0 dollars is 412, but 0 dollars is outside the prices in the data and no one sells loaves free, so the intercept has no sensible meaning.
  • r2r^{2}: about 77% of the variation in weekly loaves sold is explained by the linear relationship with price.
  • rr: the slope is negative, so r=−0.77≈−0.88r = -\sqrt{0.77} \approx -0.88.
  • Prediction at 3.50 dollars: y^=412−58(3.5)=209\hat{y} = 412 - 58(3.5) = 209 loaves, which is interpolation.

Practice questions

30 questions on this note, from easy to hard. Each one you get right lights a star of this topic's constellation.