Lurking variables · Statistics & Data Science Class 9–10 | StemPy Lab
Course 5.3·Lesson 1 of 3
Lurking variables
Two variables can move together because a third variable drives both of them. This lesson shows such a lurking variable at work in a made-up seaside town, explains why only a randomised experiment can show a cause, and lists the other reasons for a correlation.
about 30 min1 simulation1 practice question1 Python program6 questions to check yourself
This lesson is free to read. Enroll free to keep your place and take the tests.
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
explain what a lurking variable is, and find a likely one behind a correlation;
list the reasons, other than cause, why two variables can be correlated;
say why a randomised experiment can show a cause and an observational study usually cannot.
Ice cream and sunburn
A made-up seaside town keeps three numbers for eight summer weeks: the hours of sunshine a day, the ice creams sold (in hundreds) and the sunburn cases at the clinic.
Sunshine (hours a day)
Ice creams (hundreds)
Sunburn cases
4
12
3
5
15
5
6
19
5
7
21
9
8
27
10
9
29
12
10
35
15
11
37
17
The correlation between ice creams and sunburn is r=0.983. Very strong. Does eating ice cream burn the skin? Of course not. Look at the first column. Sunny weeks bring both more ice cream and more sunburn: r=0.995 for sunshine and ice cream, and r=0.989 for sunshine and sunburn.
Three small scatter plots of a made-up seaside town over eight weeks. The first shows sunburn cases against ice creams sold, the second ice creams against hours of sunshine, the third sunburn cases against hours of sunshine. All three show dots rising to the right.
Sunshine is a lurking variable: a variable that is not in the original comparison, but that affects both variables in it. Many books call it a confounding variable. When we take the sunshine out, the link between ice cream and sunburn almost disappears. The program below shows this.
Why two variables move together
A strong correlation between x and y can have several causes.
x causes y. More practice really does raise typing speed.
y causes x. Cities with more crime may hire more police. The police do not cause the crime.
A lurking variable drives both. Sunshine drives ice cream and sunburn.
Groups have been mixed. In a primary school, children with larger shoes read better. Age is the lurking variable: older children have larger feet and more years of reading.
Chance or time. Two things that both grow year after year will be correlated, even if they have nothing to do with each other. Think of the cafes in a city and its kilometres of cycle lane.
How can we show a cause?
In an observational study we only watch and record. We cannot rule out every lurking variable, because we may not even know about some of them. In a randomised experiment we assign the treatment by chance, for example by tossing a coin for each person. Then the lurking variables, known or unknown, tend to be spread evenly over the groups. A difference in the response can then be put down to the treatment. Chapter 1 of this collection, on sampling and study design, explains this in detail.
Sometimes an experiment is impossible or unfair, such as making people smoke. Then a cause is accepted only when the evidence builds up. Many studies agree, and the link is strong. The cause comes before the effect, more of the cause gives more of the effect, and there is a sensible mechanism.
Your turn: new numbers
Try it in Python
The program works out the three correlations of the seaside town. Then it removes the effect of sunshine from both variables, by keeping only the residuals of their lines on sunshine, and correlates what is left.
The usual mistakes
Reading cause into a correlation. "Linked to" is not "causes".
Forgetting the direction. Even a real cause may run the other way, from y to x.
Ignoring time. Two quantities that grow every year are correlated for that reason alone.
Trusting an observational study too far. Only random assignment balances the lurking variables we do not know about.
Remember these
A lurking (confounding) variable affects both variables and can create a correlation.
Correlation can come from cause, reverse cause, a lurking variable, mixed groups, time or chance.
A randomised experiment is the strongest evidence of a cause.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Across many made-up towns, the number of churches and the number of shops are strongly correlated. Name a likely lurking variable.
In a made-up study, people who use more sunscreen get sunburnt more often. Does sunscreen cause sunburn?
Why does random assignment protect against lurking variables that nobody has thought of?
Cities with more police officers have more crime. Give a reason that is not "police cause crime".
Two quantities have both grown every year for ten years, and r=0.97. What would you check before believing they are connected?
References
OpenStax, Introductory Statistics, Chapter 1, the section on experimental design and ethics.
Enroll free in Correlation and Cause
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.