MathemagiciansLibraryExplorationsDeep Dives
← Mathematics · Upper Secondary
MathematicsUpper Secondary

Pearson's correlation coefficient

U4 — Statistics Advancing › U4.3 — Correlation and RegressionLecture 3 of 4~2960 words

Two people, one graph, two different words

Priya and Tomás look at the same scatter graph: the twelve students from the last two lectures, with their hours of revision and their exam scores. Priya says the correlation is strong. Tomás says it is very strong.

Which of them is right? Neither can prove the other wrong. "Strong", "moderate" and "weak" are judgements made by eye. Two careful people can look at the same points and choose different words.

Now a harder question. A school has two scatter graphs: revision against scores in Mathematics, and revision against scores in History. Both look strong. Which link is closer? Your eye cannot settle that reliably, and an argument between two eyes cannot settle it at all.

The last lecture promised a number for how closely the points follow a line. Here it is. It is called Pearson's correlation coefficient, and it is written . This lecture shows what the number means, how it is built from the points, and the three things it cannot see.

One number, from −1 to +1

Every value of lies between −1 and +1. The sign of gives the direction of the correlation. The size of , meaning its distance from 0, gives the strength.

r = −1 r ≈ −0.6 r = 0 r ≈ 0.6 r = 1 −1 −0.5 0 0.5 1 falls exactlyno straight linerises exactly
Five scatter sketches placed on the scale of . The closer is to −1 or +1, the more closely the points lie to a straight line. At , no straight line describes the points.

Between these, the closer is to −1 or +1, the more closely the points hug a line. So and are equally strong. They point in opposite directions.

Notice the careful words for : no straight-line pattern. That is not the same as no pattern. A later section shows a very clear pattern with exactly.

Pearson's correlation coefficient

measures how closely the points of a scatter graph lie to a straight line.

. The sign gives the direction. The distance from 0 gives the strength.

Some books give its full name, the product-moment correlation coefficient. The next section shows where the word "product" comes from.

Building the number from the points

A calculator finds in a few key presses. But a number you cannot explain is a number you cannot judge. So build it yourself. This is the hard part of the lecture. Spend time here.

Start with the mean point from the last lecture. For the revision data it is . Draw a vertical line through and a horizontal line through . The two lines cut the graph into four quarters.

0 20 40 60 80 100 0 2 4 6 8 10 12 14 16 18 Hours of revision Exam score (%) + + − − (8, 58.7)
Dashed lines through the mean point (8, 58.7) cut the graph into four quarters. In the shaded quarters, both gaps have the same sign, so their product is positive. Every student lies in a shaded quarter or on a dashed line.

Each point now has two gaps. The first is : how far the point is to the right of the mean number of hours. The second is : how far it is above the mean score. Gaps to the left or below are negative. Multiply the two gaps together.

Now add up the products for every point. With a positive correlation, most points sit in the two positive quarters, so the total is large and positive. With a negative correlation, most points sit in the two negative quarters, so the total is large and negative. With no straight-line pattern, the points spread over all four quarters, the products cancel, and the total is close to 0.

For the revision data, the student who revised for 16 hours and scored 84% has gaps 8 and about 25.3, with product about 202.7. The student who revised for 2 hours and scored 38% has gaps −6 and about −20.7, with product about 124. All twelve products are positive or zero. Their total is 687.

So the total of the products already gives the direction. It does not yet give the strength, and there are two reasons.

First, units. Measure revision in minutes instead of hours. Every gap in becomes 60 times bigger, so the total becomes . The points are exactly as close to a line as before, but the number is 60 times bigger. Second, size. A study with 100 students adds up 100 products, so its total tends to be bigger than a study with 12, even when the pattern is no closer.

The fix is to divide by a number built in the same way from each variable on its own. Square every gap in and add them. Do the same for . Multiply the two totals and take the square root. The symbol (the Greek capital sigma) means "add up, for every point".

The formula

Now change hours to minutes again. The top is multiplied by 60. Inside the square root, the first total is multiplied by , and the square root turns that back into 60. So the top and the bottom are both multiplied by 60, and does not change. The units cancel.

For the revision data, the three totals are 687, 212 and about 2326.7.

Why can never be bigger than 1? Look at the boundary case. Suppose every point lies exactly on a line with gradient . Then every gap in is exactly times the gap in . The top of the fraction becomes . The bottom becomes , which is the size of times the same total. Everything cancels except the sign of . So a perfect rising line gives exactly 1, and a perfect falling line gives exactly −1.

Look at what happened to the gradient. It cancelled. A perfect line gives whether it is steep or shallow. When points scatter away from the line, the agreement between the gaps weakens and moves towards 0. The proof that every set of points gives a value between −1 and +1 needs more algebra, and it comes in later courses.

That is it. That is the whole idea. measures how consistently the gap in and the gap in share the same sign, and by how much, with the units and the steepness divided away.

Now see how one point can change it.

Explore — move one student and watch the correlation

Choose a student. Then move that student's score with the slider or the − / + buttons. Watch the dashed lines through the mean point, the student's product, and the value of r.

Student:

Score: 84%

The table shows what happens to for the revision data when one student's score is changed and the other eleven stay the same.

Student movedNew score (%)Description
none—0.98very strong positive
16 hours620.86strong positive
16 hours200.23weak positive
16 hours00.02little or none
8 hours200.78strong positive
8 hours00.64moderate positive
2 hours840.58moderate positive

One student out of twelve dragged from 0.98 to about 0.23. The 8-hour student is different: that student sits on the vertical dashed line, so the gap in is 0 and the product is always 0. Moving that student still lowered , because the scores became more spread out and the bottom of the fraction grew. But the effect was much smaller. Points far from the mean point carry the most weight in . This is why an outlier far out at one end can make or break a correlation.

Reading a value of

Once you have , describe it in words. These boundaries are guidelines, not laws. Different books draw them in slightly different places.

Size of (ignoring the sign)Description
0.9 to 1very strong
0.7 to 0.9strong
0.5 to 0.7moderate
0.1 to 0.5weak
below about 0.1little or no linear correlation

Add "positive" or "negative" from the sign. Then finish, as in the lecture on scatter graphs, with a sentence in context using "tends to". For the revision data: , a very strong positive correlation. Students who revised for longer tended to score higher.

So Tomás's word matches the guideline. More importantly, Priya and Tomás now share one number. If a second class gives , everyone can see that its link is a little less close, whatever words they prefer.

Stop and think

The lecture on scatter graphs compared Graph A (steep, with points zigzagging well above and below the trend) and Graph B (shallow, with points almost exactly on a line). Which has the bigger ?

Show the answer

Graph B. Its points give . Graph A gives , strong but clearly less. Graph A is steeper, but the gradient cancels in the formula. measures closeness to a line, not steepness. Your eye answered this question in that lecture, and now the number agrees.

Two more facts follow from the formula. Swap and , and nothing in the formula changes, so stays the same. Add a fixed amount to every or every , and no gap changes, so stays the same.

Three things cannot see

The first is a curve. The lecture on scatter graphs showed a theatre that tried nine ticket prices, from $2 to $18 (invented data). Income rose and then fell in a perfect arch.

Predict, then reveal — the correlation of a perfect arch

The theatre's income at nine prices from $2 to $18 rose and then fell in a perfect, symmetrical arch. What is r? Choose before you read on.

0 1000 2000 3000 4000 5000 6000 0 4 8 12 16 20 Ticket price ($) Income ($) + + − −
The theatre's nine prices and incomes, cut into four quarters through the mean point ($10, about $3667). The points sit in all four quarters, in mirror pairs.

The arch gives exactly. Each point on the left has a mirror-image point on the right with the same gap in and the opposite gap in , so their products cancel.

The arch is perfectly predictable, yet exactly. The points pair up as mirror images. The $2 point (bottom left) and the $18 point (bottom right) have equal and opposite products, and the same is true for every pair. So the total is 0.

The opposite mistake happens too. The five points (1, 1), (2, 4), (3, 9), (4, 16), (5, 25) lie exactly on the curve , and they give . A high does not prove that the pattern is a straight line. asks only one question: how well would a straight line do? It never asks whether something else would do better.

The second is a cause. For the revision data, . That does not show that revision caused the scores. A third variable, such as interest in the subject, could raise both. The lecture on scatter graphs gave four explanations for any correlation, and cannot choose between them. It measures the pattern, not the reason for it.

The third is the data behind it. The explorer showed one point dragging from 0.98 to 0.23. A small sample has a similar danger. With only five points, a fairly high can happen by chance. Later courses test whether a value of is large enough to take seriously for the number of points.

A habit to keep

Plot the data first, then calculate . The number answers one question about the graph. The graph answers the rest.

Worked examples

Worked Example 1 — Calculating the coefficient by hand

Five learners recorded how many hours they practised a piece of music () and how many bars they then played without a mistake (). Find .

-gap-gapProduct-gap²-gap²
13−2−3649
26−10010
350−1001
4812214
5822444
Total121018

The hours add to 15, so . The bars add to 30, so . In the table, the -gap is and the -gap is . Fill in the gaps, their products and their squares.

Answer: , a strong positive correlation. Learners who practised for longer tended to play more bars without a mistake.

Check: every product is positive or zero, so must be positive. The gaps in add to 0, and so do the gaps in , as they must around a mean. A calculator in statistics mode also gives 0.894.

Worked Example 2 — Interpreting the coefficient

A researcher records the daily screen time and the hours of sleep of 50 teenagers (invented study). She finds . (a) Interpret this value. (b) Does it show that screen time reduces sleep? (c) What should she check before reporting it?

(a) The sign is negative and the size, 0.73, is between 0.7 and 0.9. So there is a strong negative correlation. Teenagers with more screen time tended to sleep less.

(b) No. The pattern is real, but cannot give its reason. A third variable could drive both: a teenager with a lot of homework or worry may stay up later, which means more screen time and less sleep. To test a cause, she would need an experiment, for example asking a randomly chosen group to stop using screens an hour before bed.

(c) She should look at the scatter graph. Is the pattern straight, or does it curve? Is being pulled by one or two extreme teenagers? With 50 people, a value of −0.73 is very unlikely to be chance alone, but the graph must still agree with the number.

Worked Example 3 — Changing the units

For the café data from the last lecture, temperature in °C and ice creams sold give , and the line of best fit has gradient 11 ice creams per °C. A visitor converts every temperature to °F, using . What happens to and to the gradient?

Adding 32 to every temperature moves every point to the right by the same amount. The mean moves by 32 too, so no gap changes. Multiplying by 1.8 makes every gap in 1.8 times bigger. The top of the formula is multiplied by 1.8. The bottom is multiplied by . So is still about 0.994.

The gradient does change. One degree Fahrenheit is a smaller step than one degree Celsius, so each step adds fewer ice creams: ice creams per °F.

Answer: , unchanged; the gradient becomes about 6.1 ice creams per °F.

Check: calculating from the ten °F temperatures (51.8 to 89.6) gives 0.994 again. The same points, drawn on a stretched axis, are no closer to a line and no further from it.

Trap 1 — Reading a value near 0 as "no relationship"

near 0 means no straight-line relationship. The theatre's arch has and a perfect pattern. Always look at the scatter graph before you write "no relationship".

Trap 2 — Reading a high value as a cause

measures a very close pattern. It says nothing about why the pattern exists. Write "tends to" or "is associated with", never "causes".

Trap 3 — Reading the coefficient as the gradient

A steeper graph does not have a bigger . The gradient cancels in the formula, and changing units changes the gradient but not . also does not mean that 90% of the points lie on the line.

Try it yourself

Work each one on paper first. Open a hint only when you are stuck.

  1. Match each scatter graph to one of the values 0.92, −0.85, −0.31 and 0.07. Graph P: the points rise and lie close to a line. Graph Q: the points drift downwards, loosely. Graph R: the points form a cloud with no trend. Graph S: the points fall and lie close to a line. Then explain why a steep graph and a shallow graph could both have .

    Hint 1

    Use the sign for direction first. That splits the four values into two pairs.

    Hint 2

    Inside each pair, the value further from 0 belongs to the graph whose points lie closer to a line.

    Full answer

    P: 0.92 (positive, close to a line). R: 0.07 (almost no linear correlation). S: −0.85 (negative, close to a line). Q: −0.31 (negative, loose). Steepness does not enter : if every gap in is doubled, the top and the bottom of the formula are both doubled, so is unchanged. A steep graph and a shallow graph whose points are equally close to their lines have the same . Check: each value was used once, and the two negative values went to the two falling graphs.

  2. A bicycle shop recorded the age of five second-hand bicycles (in years) and their price (in tens of dollars): (2, 9), (4, 8), (6, 6), (8, 3), (10, 4). Calculate by hand and describe the correlation.

    Hint 1

    Find and first. Then make a table of gaps, products and squares, as in Worked Example 1.

    Hint 2

    and . The gaps in are −4, −2, 0, 2 and 4.

    Full answer

    The gaps in are 3, 2, 0, −3 and −2. The products are −12, −4, 0, −6 and −8, with total −30. The squares of the -gaps add to 40, and the squares of the -gaps add to 9 + 4 + 0 + 9 + 4 = 26. So . This is a very strong negative correlation: older bicycles tended to sell for less. Check: every product is negative or zero, so must be negative.

  3. For a group of adults, height in cm and mass in kg give . What is in each case? (a) Height is changed to metres and mass to grams. (b) Every person's mass is recorded 2 kg too high by a faulty scale. (c) Mass is put on the horizontal axis and height on the vertical axis.

    Hint 1

    In each case, ask what happens to the gaps from the mean.

    Hint 2

    Multiplying every value by the same positive number multiplies every gap by that number, on the top and on the bottom of the formula.

    Full answer

    All three are 0.62. (a) Every height gap is divided by 100 and every mass gap is multiplied by 1000. Both changes appear on the top and on the bottom, so they cancel. (b) Adding 2 kg to everyone also adds 2 kg to the mean, so no gap changes. (c) The formula treats and in the same way, so swapping them changes nothing. Check: none of these changes moves a single point closer to a line or further from it.

  4. Calculate for each set of five points. Set P: (1, 1), (2, 4), (3, 9), (4, 16), (5, 25). Set Q: (−2, 4), (−1, 1), (0, 0), (1, 1), (2, 4). Both sets lie exactly on the curve . What do the two answers show about ?

    Hint 1

    For P, and . For Q, and .

    Hint 2

    For Q, look at the products before you square anything. Pair the point at −2 with the point at 2.

    Full answer

    P: the -gaps are −2, −1, 0, 1, 2 and the -gaps are −10, −7, −2, 5, 14. The products are 20, 7, 0, 5, 28, with total 60. The squares add to 10 and to 100 + 49 + 4 + 25 + 196 = 374. So . Q: the -gaps are −2, −1, 0, 1, 2 and the -gaps are 2, −1, −2, −1, 2. The products are −4, 1, 0, −1, 4, with total 0. So . The same curve gives a very strong on one stretch and on another. only measures how well a straight line would fit those points. It cannot tell you that the true pattern is a curve: only the graph can. Check: in Q, the points at −2 and 2 have products −4 and 4, which cancel, as do the points at −1 and 1.

The bigger idea

On 20 December 1888, a paper by Francis Galton on "co-relations" was read to the Royal Society in London. He had noticed that people with long arms usually have long legs, and he wanted a single number for how close such a link is. Galton found his measure from graphs. In 1896, Karl Pearson published the formula built from products of gaps, the one in this lecture, which is why it carries his name. Pearson had first credited an earlier French writer, Auguste Bravais, who used the same products in 1846 but never treated them as a measure of strength. In 1920, Pearson changed his mind and gave Galton the credit. The letter is usually traced to Galton's earlier work on what he called regression.

In 1973, the statistician Francis Anscombe published four small data sets of 11 points each. All four have the same means, the same line of best fit and the same , about 0.816. Plotted, they look nothing alike: one is a loose straight line, one a smooth curve, one a perfect line with a single outlier, and one a vertical stack of points with one point far to the right. He made them to show that graphs are not rough sketches beside exact numbers. The graph and the number are both needed.

So is a starting point. A high value tells you there is a close straight-line pattern worth explaining. The next lecture uses the same gaps from the mean point to calculate the line of best fit exactly, instead of judging it by eye.

Key concepts in this lesson