Educerie

Educerie · AP · Statistics

AP Statistics 5.3

Linear Regression Models

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 a linear regression model uses the explanatory variable x to predict the response, and that the predicted value is written y-hat
  • Know the form y-hat = a + bx and what a, b, x and y-hat stand for
  • Understand the difference between interpolation and extrapolation and why extrapolation is less reliable
  • Know that a line should only be fitted when the scatterplot shows a linear trend

You must be able to

  1. Calculate a predicted response by substituting a value of x, showing the working and the units
  2. State whether a prediction is interpolation or extrapolation
  3. Explain why an extrapolated prediction should be treated with caution
  4. Define the symbols in a regression equation in context
  5. Use the word predicted or on average when stating a result
  6. Spot an impossible predicted value as a sign that the model has been pushed too far

In the exam. Section I gives a fitted equation (and sometimes rr and r2r^{2}) and asks for a predicted value, often as the second or third question of the regression set of three, or asks which prediction is an extrapolation. In Section II the same equation appears in a free-response question: you substitute a value, write the answer with its units, and say whether the prediction can be trusted.

1The model

A model is a simple description of how a variable behaves, used to predict. The linear regression model is the equation

y^=a+bx\hat{y} = a + bx
  • xx is the value of the explanatory variable.
  • y^\hat{y} is the predicted value of the response variable for that xx. It is not an observed value.
  • aa is the y-intercept of the line: the value of y^\hat{y} when x=0x = 0.
  • bb is the slope of the line: how much y^\hat{y} changes when xx goes up by 1.

The exam does not ask you to work out aa and bb by hand. Slope, intercept and rr come from technology, which 5.5 explains.

Notice the hat. The symbol yy is a value that was observed. The symbol y^\hat{y} is a value the line gives. They are almost never equal for the same individual, and the gap between them is the subject of 5.4. Writing "y=a+bxy = a + bx" for the line is a common notation error.

Example (invented): an owner records the age of 12 used cars, in years, and the asking price, in thousands of dollars. Figure 1 shows the data, which follow a straight pattern.

Figure 1. Asking price against age for 12 used cars, with the fitted line: the line is the model used to predict price from age, and for a car aged 5 years it predicts a price of about 15.0 thousand dollars 2 4 6 8 10 5 10 20 25 0 Asking price ($ thousands) Age (years) 5 15.0 Fitted line
Figure 1 · Asking price against age for 12 used cars, with the fitted line and the prediction for a car aged 5 years

Technology gives the line

y^=23.34−1.667x\hat{y} = 23.34 - 1.667x

where xx is the age of the car in years and y^\hat{y} is the predicted asking price in thousands of dollars. It is good practice to write what xx and y^\hat{y} mean, in the context, next to any equation.

2Calculating a predicted value

To predict, put the value of xx into the equation. Show the substitution, then the answer with units.

Worked example. Predict the asking price of a car that is 5 years old.

y^=23.34−1.667(5)put x = 5 into the equation=23.34−8.335=15.0the answer is in thousands of dollars\begin{aligned}\hat{y} &= 23.34 - 1.667(5) && \textcolor{#838c91}{\text{put x = 5 into the equation}} \\[6pt] &= 23.34 - 8.335 \\[6pt] &= 15.0 && \textcolor{#838c91}{\text{the answer is in thousands of dollars}}\end{aligned}

The predicted asking price of a 5-year-old car is about 15.015.0 thousand dollars, or about 15,000 dollars. In Figure 1, the point on the line above 5 years is at a height of 15.0.

A second prediction: for a car aged 8 years,

y^=23.34−1.667(8)=10.0\hat{y} = 23.34 - 1.667(8) = 10.0

so the predicted asking price is about 10.010.0 thousand dollars.

Four habits make the mark safe.

  • Substitute into xx, not yy. The value you are given goes in the place of xx. You solve for y^\hat{y}.
  • Show the expression. A bare number may not earn the mark. Write the substituted expression and then the answer.
  • Keep the units. The model's y^\hat{y} is in thousands of dollars here, so say "thousand dollars" or convert.
  • Say "predicted". The model does not say what the price is. It says what the price is predicted to be, on average, for a car of that age.

3A prediction is an average, not a promise

The line is a summary of a pattern with scatter. In Figure 1 there are two 5-year-old cars with asking prices above and below the line. The prediction of 15.0 is where the line lies, and no individual car has to sit on it.

Say "predicted" or "on average". Do not say "the car will sell for 15,000 dollars", or "a 5-year-old car is worth exactly 15.0 thousand". The first is a prediction and the second is a claim about every car.

4Interpolation and extrapolation

Interpolation = predicting yy for an xx inside the range of xx-values the line was built from.

Extrapolation = predicting yy for an xx outside that range.

In the car data, the ages run from 1 to 9 years. A prediction for 5 or 8 years is interpolation. A prediction for 12 or 15 years is extrapolation.

Figure 2. The same fitted line extended past the data: inside the ages 1 to 9 the predictions are interpolation, and beyond them extrapolation; by age 15 the line predicts a negative price, which is impossible 0 2 4 6 8 10 12 14 16 −4 0 5 10 15 20 25 Asking price ($ thousands) Age (years) 15 interpolation extrapolation
Figure 2 · The fitted line extended beyond the data; by age 15 it predicts a negative price

Figure 2 shows the line extended in both directions. The shaded band is the range of the data. The dashed parts are extrapolation.

Why extrapolation is less reliable. The line was built from cars aged 1 to 9. The data say nothing about what happens outside that range, and the pattern may not continue. The further out you go, the less you can trust the prediction.

Worked example. The model predicts for a 15-year-old car:

y^=23.34−1.667(15)=−1.7a predicted price below zero\hat{y} = 23.34 - 1.667(15) = -1.7 \qquad \textcolor{#838c91}{\text{a predicted price below zero}}

A negative price is impossible. The model fits the cars aged 1 to 9, and it breaks down when pushed to age 15. Old cars do not become worth less than nothing: their price levels off or the pattern changes.

A model can also fail within its range of xx, if the pattern is not linear. That is why the scatterplot comes first, and why 5.4 teaches the residual plot.

Use the line only for xx-values within the range of the data, and treat a prediction beyond that range with caution.

5Is a line sensible at all?

The linear model should only be fitted to the data if the scatterplot shows a linear trend. If the dots follow a curve, a line gives poor predictions even when rr is high (5.2, Figure 2(c)). Checks, in order:

  1. Look at the scatterplot. Does it follow a straight band?
  2. Look at rr. Is the linear association strong enough to predict from?
  3. After fitting, look at the residual plot (5.4). A random scatter supports a line, and a curve in it does not.

Practice questions

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