4.4 · SLPaper 1Paper 2

Correlation and regression (y on x)

In a minute

Pairs of measurements, such as a car's age and its price, are . You learn to describe the link between them, measure a straight-line link with Pearson's rr, and predict with the of yy on xx. You also learn when a prediction can't be trusted.

You'll be able to

  • Describe the on a : positive, negative or zero; strong, weak or none.
  • Draw a scatter diagram and a by eye through the .
  • Find Pearson's rr with your GDC, compare it with a , and know it only measures straight-line links.
  • Explain why correlation does not prove causation.
  • Find the regression line y=ax+by = ax + b with your GDC, predict with it, and interpret aa and bb in context.
  • Spot unreliable predictions: , and using a yy on xx line to predict xx.
Before you start3 quick questions on what this builds on
Check yourself
Write down the gradient of the line y=12−1.5xy = 12 - 1.5x.
Check yourself
For the line y=0.4x+15y = 0.4x + 15, find yy when x=30x = 30.
Check yourself
Find the mean of 1414, 99, 2121 and 1616.

Revise first: 2.1 Straight-line equations, 4.2 Data presentation and 4.3 Central tendency and dispersion

Scatter diagrams and lines of best fit

Does a town's altitude affect its summer temperature? To find out, you need two measurements from each town, kept in pairs. Data like this is .

Put the variable that might explain the other on the horizontal axis, as xx, and the one you want to predict on the vertical axis, as yy.

Describe it with two words. Direction: positive if yy tends to rise as xx rises, negative if it tends to fall, zero if there is no trend. Strength: strong if the points lie close to a line, weak if loosely spread around one, none if there is no pattern.

Six scatter diagrams: strong positive, weak positive, no correlation, weak negative, strong negative, and points on a curve with r near zero strong positive weak positive no correlation weak negative strong negative curved: r near 0
The last panel has a clear pattern, but not a straight-line one.
Worked exampleEight weather stations on a mountain record their altitude xx, in hundreds of metres, and their mean July temperature yy, in °C. xx: 2,5,8,11,14,17,20,242, 5, 8, 11, 14, 17, 20, 24. yy: 24.1,22.6,20.2,18.9,16.4,15.1,12.3,10.224.1, 22.6, 20.2, 18.9, 16.4, 15.1, 12.3, 10.2. Draw a scatter diagram and describe the correlation.

Try it first, then reveal one step at a time.

  1. Altitude might explain temperature, so it goes on the xx-axis. Plot the eight points.
Check yourself
As a used car gets older, its price tends to fall. What correlation would a scatter diagram of age xx against price yy show?

A straight line through the middle of the points sums up a strong trend. You can draw it by eye, but it must pass through one special point.

To draw a by eye, plot the mean point first. Rule a line through it that follows the trend, with about as many points above as below.

Scatter diagram of six points with the mean point at 12, 42 marked by a ring and a line of best fit drawn through it 0 4 8 12 16 20 24 0 10 20 30 40 50 60 70 pages xtime y (s)mean point (12, 42)
The line passes through the mean point (12,42)(12, 42).

To find the equation of your line, read a second point off it. Then use these booklet formulas from 2.1.

In the formula booklet
m=y2−y1x2−x1m = \frac{y_{2} - y_{1}}{x_{2} - x_{1}}
In the formula booklet
y−y1=m(x−x1)y - y_{1} = m(x - x_{1})
Worked exampleA printer takes yy seconds to print a job of xx pages. For six jobs, xx: 3,7,10,14,18,203, 7, 10, 14, 18, 20 and yy: 21,30,36,47,55,6321, 30, 36, 47, 55, 63. (a) Find the mean point. (b) A line of best fit drawn through the mean point also passes through (2,18)(2, 18). Find its equation.

Try it first, then reveal one step at a time.

  1. (a) xˉ=3+7+10+14+18+206=726=12\bar{x} = \frac{3 + 7 + 10 + 14 + 18 + 20}{6} = \frac{72}{6} = 12 and yˉ=21+30+36+47+55+636=2526=42\bar{y} = \frac{21 + 30 + 36 + 47 + 55 + 63}{6} = \frac{252}{6} = 42. So the mean point is (12,42)(12, 42).

Pearson's correlation coefficient

Strong and weak are judgements. Pearson's rr puts a number on the correlation, so everyone agrees.

Learn this
−1≤r≤1-1 \le r \le 1

The sign gives the direction. r=±1r = \pm 1 means every point lies exactly on a line; r=0r = 0 means no linear correlation. As a rough guide, ∣r∣\lvert r\rvert above about 0.750.75 is strong, 0.250.25 to 0.750.75 is weak, and below 0.250.25 there is little or none.

Your GDC finds rr along with the regression line (keystrokes in the regression section). By hand, which exams don't ask for, it is:

Learn this
r=SxySxx Syy,Sxy=∑(x−xˉ)(y−yˉ),Sxx=∑(x−xˉ)2,Syy=∑(y−yˉ)2r = \frac{S_{xy}}{\sqrt{S_{xx}\,S_{yy}}}, \quad S_{xy} = \sum (x - \bar{x})(y - \bar{y}), \quad S_{xx} = \sum (x - \bar{x})^{2}, \quad S_{yy} = \sum (y - \bar{y})^{2}

rr only measures how close the points are to a straight line. Data can follow a perfect curve and still have rr close to 00.

Seven points lying exactly on an upside-down parabola: the heights of a ball rise from 0 to 45 metres at 3 seconds, then fall back to 0 at 6 seconds 0 1 2 3 4 5 6 0 10 20 30 40 50 time t (s)height h (m)
Worked exampleA ball is thrown straight up. Its height hh metres after tt seconds is: tt: 0,1,2,3,4,5,60, 1, 2, 3, 4, 5, 6; hh: 0,25,40,45,40,25,00, 25, 40, 45, 40, 25, 0. (a) Use SthS_{th} to find Pearson's rr. (b) Comment on your answer.

Try it first, then reveal one step at a time.

  1. Means: tˉ=217=3\bar{t} = \frac{21}{7} = 3 and hˉ=1757=25\bar{h} = \frac{175}{7} = 25.

With few points, a fairly large rr can happen by chance. A , given in the question, says how large ∣r∣\lvert r\rvert must be for nn pairs.

Worked exampleFor 99 trees, trunk diameter and height have r=0.812r = 0.812. The critical value of rr for 99 pairs is 0.6660.666. Determine whether there is significant linear correlation.

Try it first, then reveal one step at a time.

  1. Compare ∣r∣\lvert r\rvert with the critical value: 0.812>0.6660.812 > 0.666.
Check yourself
A data set has r=−0.97r = -0.97. Which statement is correct?
Check yourself
For 1010 pairs, r=−0.58r = -0.58 and the critical value is 0.6320.632. What can you conclude?

Correlation is not causation

Strong correlation shows that two variables move together. It doesn't show that changing one would change the other.

Often a third variable drives both. Sometimes the link is a coincidence, more likely with few data points. So remember: correlation does not imply causation.

Worked exampleAcross 1515 towns, the number of fire stations and the number of house fires per year have r=0.88r = 0.88. The critical value for 1515 pairs is 0.5140.514. (a) Describe the correlation. (b) A councillor says closing fire stations would reduce fires. Comment.

Try it first, then reveal one step at a time.

  1. (a) rr is positive and close to 11, and 0.88>0.5140.88 > 0.514: strong, significant positive correlation.
Worked exampleFor 1212 students, the minutes per week spent on a revision app and the test score have r=0.41r = 0.41. The critical value for 1212 pairs is 0.5760.576. A teacher says the app raises scores. Comment.

Try it first, then reveal one step at a time.

  1. Test the correlation first: ∣r∣=0.41<0.576\lvert r\rvert = 0.41 < 0.576, so it is not significant: it could be chance.
Check yourself
For children aged 55 to 1111, shoe size and reading score have strong positive correlation. Which is the best explanation?
Check yourself
For 1414 districts, the number of public libraries and the number of road accidents per year have r=0.83r = 0.83. The critical value for 1414 pairs is 0.5320.532. A newspaper says libraries cause road accidents. Which comment is best?

The regression line of y on x

Lines drawn by eye vary from person to person. The regression line is fixed by a rule.

Six points with the regression line of y on x drawn through them, and a short vertical dashed segment from each point to the line xyvertical distances
The squares of these vertical distances add up to as little as possible.

Here aa is the and bb is the : watch the letters. Your GDC finds both.

Worked exampleA cyclist records the distance xx km and time yy minutes of seven rides. xx: 12,18,25,30,34,41,4712, 18, 25, 30, 34, 41, 47. yy: 38,55,71,88,95,118,13138, 55, 71, 88, 95, 118, 131. (a) Use your calculator to find the regression line of yy on xx. (b) Write down the value of rr. (c) Estimate the time for a 2828 km ride. Give your answers to 3 s.f.

Try it first, then reveal one step at a time.

  1. (a) Enter xx in the first list and yy in the second. Run linear regression (ax+bax + b): a=2.6821…a = 2.6821\ldots, b=5.8284…b = 5.8284\ldots.

Say what aa and bb mean using the question's variables and units. bb only has a real meaning if x=0x = 0 makes sense and is near the data.

Worked exampleFor a sample of taxi trips, the regression line of fare yy dollars on distance xx km is y=1.85x+3.20y = 1.85x + 3.20. (a) Interpret 1.851.85 and 3.203.20. (b) Find how much more the model predicts for a trip 66 km longer.

Try it first, then reveal one step at a time.

  1. (a) a=1.85a = 1.85: each extra kilometre adds about 1.851.85 dollars to the fare, on average.
Check yourself
In the cycling model y=2.68x+5.83y = 2.68x + 5.83 (xx in km, yy in minutes), what does 2.682.68 mean?
Check yourself
The rides were between 1212 and 4747 km. What does b=5.83b = 5.83 represent?

Making reliable predictions

Trust a prediction from the yy on xx line only if three things hold. First, the correlation is strong or significant.

Second, xx is inside the data, because the pattern may stop beyond it. Third, you are predicting yy. The of yy on xx minimises vertical distances, so to predict xx from yy use the line of xx on yy (4.10), never a rearranged one.

Two regression linesDrag the ringed point or use the sliders
12345671234567y on x (solid)x on y (dashed)small ring: (x̄, ȳ)
5.0
6.0

Mean point (x̄, ȳ) = (3.00, 4.00)

y on x: y = 0.9x + 1.3

x on y: x = 0.9y − 0.6

Pearson's r = 0.900 (y on x: y = 0.9x + 1.3; x on y: x = 0.9y − 0.6)

Use the y on x line to predict y from a given x, and the x on y line to predict x from a given y. Both pass through (x̄, ȳ), and they coincide only when r = ±1.

Drag the point off the trend of the other four and watch ∣r∣\lvert r\rvert fall: the two lines spread apart. Drag it back along the trend and they close up. They would match only if r=±1r = \pm 1, with every point on one line.

Worked exampleFor the cyclist's rides (xx from 1212 to 4747 km, r≈0.999r \approx 0.999), the line of yy on xx is y=2.68x+5.83y = 2.68x + 5.83. (a) Estimate the time for a 4040 km ride. (b) Comment on using the line for a 9090 km ride. (c) Explain why solving 100=2.68x+5.83100 = 2.68x + 5.83 is the wrong way to find the distance of a 100100-minute ride.

Try it first, then reveal one step at a time.

  1. (a) y=2.6821…×40+5.8284…=113.11…≈113y = 2.6821\ldots \times 40 + 5.8284\ldots = 113.11\ldots \approx 113 minutes. This is interpolation with rr near 11, so it is reliable.
Worked exampleA model built from children aged 22 to 1010 gives height yy cm in terms of age xx years: y=6.1x+77y = 6.1x + 77. (a) Predict the height of an 88-year-old. (b) Use the model for a 3030-year-old, and comment.

Try it first, then reveal one step at a time.

  1. (a) y=6.1×8+77=48.8+77=125.8y = 6.1 \times 8 + 77 = 48.8 + 77 = 125.8 cm. Age 88 is inside the data, so this is reasonable.
Check yourself
You have the regression line of yy on xx and a value of yy. How should you estimate xx?
Check yourself
Data has xx values from 1010 to 6060 and r=0.94r = 0.94. For which xx is a prediction of yy most reliable?

Common mistakes

  • Swapping the lists on the GDC. For the line of yy on xx, xx goes in the first list.
  • Rearranging the yy on xx line to predict xx from yy. Use the line of xx on yy.
  • Substituting a data point's xx into the line to find its yy. Only the mean point must lie on the line.
  • Interpreting aa as a value, or saying only that yy rises with xx. Say how much yy changes per unit of xx.
  • Substituting x=6x = 6 to find the effect of 66 more units. The change is 6a6a.
  • Claiming causation because rr is near 11. Correlation does not imply causation.

Exam tips

  • Write down rr: read it from your GDC, no working needed, to 3 s.f. with its sign.
  • Interpret, in context: use the question's variables and units, such as about 2.682.68 minutes per extra kilometre.
  • On Paper 2, write the substitution before the answer, using the stored values of aa and bb.
  • Comment on reliability: say whether xx is inside the data range, and how strong the correlation is.

Key takeaways

Learn this−1≤r≤1-1 \le r \le 1
Learn thisDescribe correlation by direction (positive, negative, zero) and strength (strong, weak, none).
Learn thisrr near ±1\pm 1: strong linear correlation; near 00: none, though there may be a curve. ∣r∣\lvert r\rvert above the critical value: significant.
Learn thisA line of best fit by eye, and the regression line, pass through the mean point (xˉ,yˉ)(\bar{x}, \bar{y}).
Learn thisCorrelation does not imply causation: look for a third variable.
Learn thisIn y=ax+by = ax + b, aa is the change in yy per 11 increase in xx; bb is yy when x=0x = 0.
Learn thisUse the yy on xx line only to predict yy, and only inside the range of the data.

Practise this

13 past-paper questions on 4.4 in the AA HL bank, each with a mark scheme and a worked explanation.

Practise 4.4 →