Math paradoxes

Glossary / Correlation

Glossary · correlation

Is ice cream dangerous for swimmers?

On days when more ice cream is sold, more people drown. The link is real and shows up in the data. But ice cream has nothing to do with it: the heat pushes both. Correlation can show that two things move together, and cannot tell you why at all.

In plain wordspictures, analogies, small numbers

“In plain words” is hidden on all puzzles.

The ice cream paradox

Each dot is one day: how much ice cream was sold and how many people drowned. The more ice cream, the more drownings, and you can see it with the naked eye. Now keep only days with almost the same heat.

Correlation–
Which days

Rigoroustables, charts, formulas

“Rigorous” is hidden on all puzzles.

One number from −1 to +1

Correlation is written r. It shows how closely points line up along a straight line. The sign gives the direction, the size how tight the link is.

−1a perfect line going down
−0.5clearly "the more of one, the less of the other"
0no straight-line link
+0.5clearly "the more, the more"
+1a perfect line going up

Try it: what r looks like

300 points. Move the slider and see which cloud matches which number. Many are surprised that r = 0.3 already counts as "a link" while the cloud looks almost round, and r = 0.8 is still far from a line.

Correlation of these 300 points–
A new random cloud

Even with the same target correlation, 300 random points give a slightly different r: "Shuffle" shows by how much.

Two more traps

Correlation is a useful number, but it fools people easily. Here are two more ways the data can say one thing and r another.

Correlation–

When to trust a correlation

  • It doesn't say what causes whatIce cream doesn't drown people. Look for a third variable pushing both, or test it with an experiment.
  • It only sees straight linesr ≈ 0 means "no straight-line link", not "no link". The parabola in the traps depends on x completely, and r is almost zero.
  • Look at the points, not just the numberOne far-off point can turn a cloud into a "strong link". A plot saves you from this in a second.
  • r = 0.5 doesn't mean "half the time"It is neither a percentage nor a probability. The share of variation explained by the straight-line link is r², just 25%.
Deepergeneralisations, theory, history

“Deeper” is hidden on all puzzles.

The formula

r = Σ (xᵢ − x̄)(yᵢ − ȳ) / √( Σ (xᵢ − x̄)² · Σ (yᵢ − ȳ)² )

The numerator adds up products of deviations from the means. A point top right or bottom left adds a plus, bottom right or top left a minus. The denominator only scales the sum so that r doesn't depend on units and stays between −1 and +1. This also shows the weak spot: one far-off point gives a huge product and can outweigh all the rest.

Why the parabola has r = 0

cov(x, x²) = E[x³] − E[x] · E[x²] = 0 − 0 · E[x²] = 0

If the x values are spread symmetrically around zero, then E[x] = 0 and E[x³] = 0: every cube on the right has an equal negative one on the left. So the numerator is zero, even though y is completely determined by x. Correlation measures only the straight-line part of a link.

How to "remove" the heat with a formula

rxy·z = (rxy − rxz · ryz) / √( (1 − rxz²)(1 − ryz²) )

This is the partial correlation: the link between ice cream x and drownings y when the temperature z is held fixed. In the first simulation ice cream correlates with temperature at –, drownings with temperature at –. Their product – almost equals the correlation of ice cream with drownings, –. So the temperature explains nearly the whole link, and the partial correlation is –. It is the same result as the "only days at 28–32°" button, without throwing any data away.

Where it shows up

Other terms