Two-Variable Statistics
Senior 6 · Basic Mathematics
Two-Variable Statistics
Lesson 3 of 4
25 min
The kiosk owner from the last lesson wants to plan her stock. The weather forecast says tomorrow will reach 26 °C: how many bottles should she expect to sell? Pearson's says a straight line fits her data very well. This lesson finds that line and uses it.
The line with gradient through the point is
For example, the line with gradient 3 through is , that is .
Definition
The regression line of on is the straight line that makes the sum of the squared vertical distances from the points to the line as small as possible (the least-squares line). It passes through the mean point with gradient :
The regression line of on minimises the squared horizontal distances:
and are the regression coefficients. Example: if and , then .
The two lines are different unless . They always cross at . The closer is to 1, the smaller the angle between them; when they are perpendicular, one horizontal () and one vertical ().
Multiplying the two regression coefficients gives
So , with the sign of the regression coefficients (both are positive or both negative, like the covariance).
Worked example
Worked example 1. For the water data, , , , . Find the line of on and predict the sales at 26 °C.
At : . She should expect about 52 bottles.
Worked example
Worked example 2. On one day she sold 60 bottles but lost the temperature record. Estimate it. (.)
We know and want , so we need the line of on :
At : . The temperature was about 28.4 °C.
Check: , and . ✓
Worked example
Worked example 3. The two regression lines of a data set are ( on ) and ( on ). Find , and .
Both lines pass through , so solve them together. Substitute the first into the second:
Then . So and .
is positive because both coefficients are positive.
Khan Academy finds the least-squares line of y on x from the means, the standard deviations and r. Its slope formula, r times the ratio of the standard deviations, equals cov(x, y) divided by the variance of x used in this lesson.
Warning
Do not rearrange one line to get the other. Making the subject of gives , which is not the line of on (). The two lines minimise different distances. Use on to find , and on to find .
Tip
The variable you are predicting is the one that comes first: " on " predicts . And the regression coefficient for it divides by the variance of the other variable.
Practice
Important
Both regression lines pass through . Use on to predict , on to predict . And .
Sources and credits
Text, data, diagram, worked examples and exercises: Written by Ganzaa. All data are illustrative.
Video: Calculating the equation of a regression line, Khan Academy, embedded from YouTube.