Unit 5 · Topic 5.3 Beta

Linear Regression Models

4 min read · freeNot practiced

A scatterplot describes a relationship; a correlation measures how linear it is. The next step is to use the relationship: to predict the response for a given value of the explanatory variable. When the pattern is linear, a straight line does that.

The regression line

A regression line is a line that describes how the response yy changes, on average, as the explanatory variable xx changes. In statistics it is written

y^=a+bx,\hat{y} = a + bx,

where aa is the intercept and bb is the slope, the same kind of equation as y=mx+by = mx + b from algebra. Watch the letters: here bb is the slope (algebra's mm) and aa is the intercept (algebra's bb), written first. The hat on y^\hat{y} ("y-hat") says that the output is a predicted value, not an observed one. Real data points scatter above and below the line; the line gives the typical value for each xx. (This equation, y^=a+bx\hat{y} = a + bx, is on the reference sheet.)

Where does the line come from? Usually from technology, which fits the line to the data. Topic 5.5 explains how the best line is chosen. For now, take the equation as given and learn to use it.

Making a prediction

The sleep and reaction time scatterplot with the regression line, predicted time = 391.1 minus 11.37 times hours; dashed lines go up from 6.8 hours to the line and across to a predicted reaction time of 314 milliseconds.
Figure 1. The regression line for the sleep data and one prediction. LevlPrep original diagram.

Worked example 1. For 14 students, the line for predicting reaction time (milliseconds) from hours of sleep is y^=391.1−11.37x\hat{y} = 391.1 - 11.37x. Predict the reaction time of a student who slept 6.8 hours.

y^\hat{y}=391.1−11.37(6.8)= 391.1 - 11.37(6.8)=391.1−77.3= 391.1 - 77.3=313.8= 313.8 milliseconds.

In words: the line predicts a reaction time of about 314 milliseconds for a student who slept 6.8 hours. The figure shows the same prediction: up from 6.8 to the line, then across.

Interpreting the slope

The slope is the change in the predicted value for each one-unit increase in xx. Its units are units of yy per unit of xx. Use this template, filling in context:

"For each additional [unit of xx], the predicted [yy] increases (decreases) by about |b||b| [units of yy]."

For the sleep line: for each additional hour of sleep, the predicted reaction time decreases by about 11.4 milliseconds. The word "predicted" matters. The slope does not say that every student who sleeps one more hour reacts exactly 11.4 milliseconds faster; it describes the trend of the predictions.

The slope always has the same sign as the correlation: a negative association gives a falling line.

Interpreting the intercept, when it makes sense

The intercept aa is the predicted yy when x=0x = 0. Interpret it only if x=0x = 0 is a sensible value inside, or very near, the data.

Worked example 2. A resale site fits price^\widehat{\text{price}}=620−95(age)= 620 - 95(\text{age}) to listings of one phone model aged 0 to 6 years.

Slope: for each additional year of age, the predicted resale price decreases by about 95 dollars.

Intercept: a new phone (age 0) has a predicted price of 620 dollars. This makes sense, because new phones are in the data.

A prediction: for a 3.5-year-old phone, 620−95(3.5)=287.5620 - 95(3.5) = 287.5, so about 287.50 dollars.

Compare a line for children aged 5 to 12, y^=76+6.2x\hat{y} = 76 + 6.2x for height in centimeters. The intercept would describe a newborn, but no newborns are in the data, and children do not grow at a steady rate from birth. So the intercept has no useful meaning here.

Extrapolation

A line is fit to the xx values in the data. Using it far outside that range is extrapolation, and it is unreliable: nothing in the data says the pattern continues. The phone line predicts 620−95(8)=−140620 - 95(8) = -140 dollars for an 8-year-old phone, an impossible price. The sleep line predicts about 243 milliseconds for 13 hours of sleep, far faster than any student in the data, who all slept 4.5 to 9.5 hours. Both numbers come out of the equation; neither should be trusted.

PartMeaningTemplate
y^\hat{y}predicted value of yy"The predicted [yy] for [xx value] is ..."
bbpredicted change in yy per unit of xx"For each additional ..., the predicted ... increases (decreases) by about ..."
aapredicted yy when x=0x = 0"When [xx] is 0, the predicted [yy] is ...", only if x=0x = 0 makes sense

Spot a mistake on this page?