Module 2 — Data: turning the world into information
Lesson 12 of 13
Correlation and causation
Data allows us to discover relationships.
As temperature rises, electricity demand may change.
People who exercise more may tend to have better health outcomes.
Areas with higher incomes may have higher house prices.
Students with higher attendance may achieve better examination results.
Two variables moving together is often interesting.
It may help us make predictions.
But it does not automatically tell us why they move together.
This leads to one of the most important distinctions in data analysis:
Correlation tells us that variables are related. Causation tells us that changing one variable changes another.
The two are not the same.
And confusing them can lead to very poor decisions.
What is correlation?
Suppose we observe the following relationship:
| Temperature | Ice cream sales |
|---|---|
| 12°C | 100 |
| 16°C | 140 |
| 20°C | 190 |
| 24°C | 250 |
| 28°C | 320 |
As temperature increases, ice cream sales also tend to increase.
The variables are positively correlated.
Conceptually:
TEMPERATURE ↑ → ICE CREAM SALES ↑
But correlation itself does not yet tell us what mechanism is producing the relationship.
Positive correlation
A positive correlation means that larger values of one variable tend to be associated with larger values of another.
Examples might include:
height ↑ → weight tends to ↑
temperature ↑ → cooling demand tends to ↑
house size ↑ → house price tends to ↑
These relationships do not have to be perfect.
They simply show a tendency for the variables to move in the same direction.
Negative correlation
A negative correlation means that larger values of one variable tend to be associated with smaller values of another.
For example:
distance from city centre ↑ → house price may ↓
or:
outside temperature ↑ → heating demand may ↓
Again, the relationship does not need to be exact.
It describes a tendency.
No correlation
Sometimes two variables show little systematic relationship.
For example:
shoe size
and:
daily electricity price
may have essentially no meaningful relationship across individuals.
Knowing one tells us little about the other.
But even this needs care.
A variable can have no simple linear correlation while still having a more complicated relationship.
Correlation measures association
A common measure is the correlation coefficient.
For a linear relationship, it is often represented by:
r
with values between:
-1 and +1
Roughly:
r close to +1 → strong positive linear relationship
r close to 0 → weak linear relationship
r close to -1 → strong negative linear relationship
The important word is:
linear.
Correlation is a summary of a particular kind of association.
It does not reveal every possible relationship between variables.
Correlation can help prediction
Suppose electricity demand is strongly related to temperature.
Then temperature may be a useful feature for predicting demand.
We do not necessarily need to prove every causal mechanism in order to make a useful prediction.
If:
temperature → useful information about demand
then a forecasting model may benefit from knowing temperature.
This gives us an important distinction:
Prediction and causal explanation are different goals.
A variable can be useful for prediction even when we do not fully understand why it is predictive.
Prediction asks "what?"
A prediction problem asks something like:
Given what we know, what outcome should we expect?
For example:
Given temperature, time of day and historical demand, what will electricity demand be this evening?
A model might achieve excellent predictive accuracy without identifying the true causal structure behind every relationship.
That may be perfectly adequate if forecasting is the only objective.
Causation asks "what if?"
Causal questions are different.
Instead of:
What tends to happen when X is high?
we ask:
What would happen if we deliberately changed X?
For example:
Predictive question:
Are people who exercise more generally healthier?
Causal question:
If this person increases their exercise, will their health improve?
The second question is much harder.
It asks about the effect of an intervention.
Observation versus intervention
This distinction can be represented as:
OBSERVATION
When X differs, how does Y tend to differ?
versus:
INTERVENTION
If we deliberately change X while holding relevant things constant, what happens to Y?
Causal reasoning is about interventions.
This will become very important later in the course because decisions are interventions.
An intelligent system does not merely observe the world.
It may act on it.
A classic example
Suppose we observe:
People carrying umbrellas are more likely to be standing in the rain.
Umbrellas and rain are correlated.
Does carrying an umbrella cause rain?
Clearly not.
Instead:
RAIN
causes:
PEOPLE TO CARRY UMBRELLAS
The causal direction is the opposite of one possible naive interpretation.
Correlation does not tell us causal direction.
A third variable can cause both
Return to ice cream sales.
Suppose we observe:
ice cream sales ↑
and:
sunburn cases ↑
Should we conclude:
Eating ice cream causes sunburn?
Probably not.
A third variable explains both:
HOT SUNNY WEATHER
↓
MORE ICE CREAM SALES
and:
HOT SUNNY WEATHER
↓
MORE SUN EXPOSURE
↓
MORE SUNBURN
The correlation between ice cream and sunburn arises because both depend on another variable.
This is called confounding.
Confounding variables
A confounder is a variable related to both:
- the potential cause,
- the outcome.
Suppose we observe:
People who own expensive cars have higher incomes.
Does buying an expensive car cause higher income?
Probably not.
Income itself influences the ability to buy an expensive car.
There may also be other factors such as:
- occupation,
- age,
- wealth.
When analysing observational data, hidden confounders can create relationships that look causal but are not.
Correlation can come from common causes
Conceptually:
Z → X
and:
Z → Y
can create:
X ↔ Y
even if:
X does not cause Y
and:
Y does not cause X.
This is extremely common in real data.
Many variables share common underlying causes.
Reverse causality
Sometimes we identify a relationship but assume the wrong causal direction.
Suppose we observe:
People receiving more medical treatment tend to be less healthy.
Does medical treatment cause poor health?
Sometimes treatments do have side effects.
But a major explanation is likely:
POOR HEALTH → MORE MEDICAL TREATMENT
The outcome influences the supposed cause.
This is reverse causality.
Simultaneous causation
Real systems can be even more complicated.
Suppose price and demand influence each other.
Higher prices may reduce demand.
But higher demand may also increase prices.
So:
PRICE → DEMAND
and:
DEMAND → PRICE
can both exist.
Many economic and social systems contain feedback.
Causal relationships do not always form a simple one-way chain.
Time can help, but not prove causality
Suppose X occurs before Y.
That may support a causal hypothesis.
A cause generally needs to precede its effect.
But:
X happened first
does not prove:
X caused Y.
Perhaps both were driven by another earlier event.
Temporal ordering is useful evidence.
It is not sufficient by itself.
Spurious correlation
With enough variables, some will appear related purely by chance.
Suppose we analyse thousands of unrelated time series.
Some pairs will happen to rise and fall together.
The relationship may look impressive.
But there may be no meaningful connection.
This is sometimes called a spurious correlation.
Large datasets increase the opportunity to discover relationships.
They also increase the opportunity to discover meaningless ones.
Searching enough patterns almost guarantees surprises
Imagine testing:
1,000,000 possible relationships.
Even if none has a genuine underlying connection, random chance will make some appear statistically unusual.
If we report only the most surprising relationship, it can look highly convincing.
This is why good statistical practice considers:
- how many hypotheses were tested,
- whether the relationship was predicted in advance,
- whether it replicates in new data.
Finding a pattern is only the beginning.
Correlation can disappear when we add context
Suppose we observe:
People with umbrellas are more likely to be wet.
Now compare people under the same weather conditions.
Perhaps:
among people exposed to the same rain
those with umbrellas are actually:
less wet.
The aggregate relationship can reverse once we account for another variable.
This shows why correlations should be interpreted within context.
Simpson's paradox
An especially striking version of this phenomenon is Simpson's paradox.
A relationship observed in aggregated data can:
- weaken,
- disappear,
- even reverse
when the data is divided into relevant subgroups.
For example, a treatment might appear better overall while appearing worse within each age group because the groups received treatments at very different rates.
The aggregate data is not necessarily mathematically wrong.
It is hiding structure.
This connects directly to our earlier discussion of aggregation.
Spatial aggregation can create false relationships
Suppose wealthy regions have:
- more hospitals,
- higher recorded disease rates.
We might incorrectly conclude:
Hospitals cause disease.
But wealthy regions may simply have:
- better access to diagnosis,
- better measurement,
- older populations.
The observed relationship reflects several interacting processes.
Spatial data frequently creates these kinds of confounding relationships.
Measurement systems can create correlation
Suppose two variables are measured using the same faulty sensor.
A calibration drift affects both.
They may appear strongly correlated even though the underlying physical quantities are not.
Or suppose a reporting policy changes and simultaneously affects several recorded variables.
The correlation may partly reflect the measurement process.
So when we observe a relationship, we should ask:
Could the data-generating system itself have created this pattern?
Selection can create correlation
Recall the previous lesson.
Suppose we examine only people who were admitted to university.
Within that selected group, variables may appear related in ways that are not present in the wider population.
Selection changes which observations exist in the dataset.
This can create statistical relationships.
A particularly important form of this is sometimes called collider bias.
Selection changes the world we observe
Suppose university admission depends on:
- academic ability,
- sporting achievement.
Among admitted students, someone with lower academic scores may be more likely to have very high sporting achievement.
Within the selected population, academic and sporting ability may appear negatively related.
But that relationship was partly created by the admissions process.
The selection rule produced the observed correlation.
Models are extremely good at finding correlation
Machine learning excels at identifying statistical relationships.
Given enough examples, models can discover complex associations between:
inputs
and:
outputs.
For prediction, this is enormously valuable.
But machine-learning models do not automatically distinguish:
causal relationship
from:
predictive correlation.
If a variable consistently predicts an outcome, the model may use it.
It does not need to understand the causal mechanism.
A model may use the wrong reason
Imagine a computer-vision model distinguishing wolves from dogs.
Suppose:
- most wolf photographs contain snow,
- most dog photographs do not.
The model may learn:
snow → wolf
This may work surprisingly well on the training data.
But snow does not cause an animal to be a wolf.
The model has discovered a predictive correlation created by the dataset.
When shown:
dog standing in snow
it may fail.
This is a generalisation problem.
Shortcut learning
When models exploit easy correlations instead of the relationship we intended, this is sometimes described as shortcut learning.
A medical-image model might appear to identify disease but actually learn:
- which hospital produced the image,
- which scanner was used,
- markings associated with particular patient groups.
If those features correlate with disease in the training data, they may be useful for prediction there.
They may fail somewhere else.
Causality can improve robustness
Why might causal relationships be more useful than superficial correlations?
Because causal mechanisms may remain more stable when the environment changes.
Suppose:
snow background → wolf
works in one dataset.
Move to another country and the relationship disappears.
But biological characteristics distinguishing wolves from dogs remain more stable.
Causal understanding can therefore help models generalise beyond accidental correlations.
Distribution shift exposes fragile correlations
Suppose historical data shows:
Feature X → Outcome Y
The relationship is highly predictive.
Then the environment changes.
Perhaps:
- technology changes,
- policy changes,
- human behaviour changes.
If X was only an accidental historical correlation, the model may fail.
This is one reason distribution shift is such a serious challenge for AI.
The future does not guarantee that every historical correlation will persist.
Predictions can be useful without causality
We should not overcorrect.
Correlation is not bad.
Suppose cloud patterns strongly predict rain.
A weather system does not need to establish that:
this exact cloud causes this exact raindrop
to make useful forecasts.
If a relationship is stable and reliable, it can support prediction.
The key is matching the method to the question.
If the question is predictive, correlation may be enough. If the question is intervention, causation matters.
Decisions require causal thinking
Suppose an AI predicts:
Students who receive tutoring have higher examination scores.
Should a school therefore provide tutoring?
Maybe.
But before allocating resources, we want to know:
Would providing tutoring actually improve outcomes?
Perhaps students receiving tutoring historically also had:
- wealthier families,
- more motivated parents,
- more study time.
Prediction alone cannot answer the intervention question.
Once we move from:
predict
to:
act
causal reasoning becomes much more important.
Prediction versus policy
Imagine a model predicts:
People living in Area A have a higher risk of unemployment.
That may be useful for forecasting.
But suppose a policymaker asks:
What intervention will reduce unemployment?
The predictive model does not automatically provide the answer.
Possible interventions include:
- training,
- transport,
- childcare,
- investment,
- education.
We need to understand the mechanisms causing unemployment, not merely variables correlated with it.
A predictive feature may be a terrible intervention
Suppose postcode strongly predicts someone's income.
Changing someone's postcode in a database will not make them wealthier.
The variable is predictive.
It is not necessarily a causal lever.
This distinction is crucial for intelligent decision systems.
A variable that predicts an outcome is not automatically something we should manipulate to change that outcome.
Causal levers
A useful causal variable is sometimes a lever:
something we can change that affects the outcome we care about.
Examples might include:
- medication dose,
- electricity price,
- training programme,
- speed limit.
But even then, causal effects can depend on context.
Changing something may have:
- direct effects,
- indirect effects,
- side effects,
- feedback effects.
Decision-making requires understanding these consequences.
Controlled experiments
One of the strongest tools for identifying causal effects is the randomised controlled experiment.
Suppose we want to test a new treatment.
Participants are randomly assigned to:
Treatment A
or:
Treatment B.
Random assignment helps make the groups similar in expectation.
So if outcomes differ substantially, we have stronger evidence that the treatment caused the difference.
Conceptually:
RANDOM ASSIGNMENT
↓
DIFFERENT INTERVENTIONS
↓
COMPARE OUTCOMES
Randomisation helps break the relationship between treatment choice and potential confounders.
Why randomisation is powerful
Suppose:
- healthier people,
- wealthier people,
- younger people
are all more likely to choose Treatment A voluntarily.
Then comparing voluntary users of A and B may be misleading.
Random assignment prevents those characteristics from systematically determining which treatment someone receives.
That allows us to isolate the effect of the treatment more cleanly.
A/B testing
Digital services frequently use a similar approach called A/B testing.
Users might be randomly shown:
Version A
or:
Version B.
The service then compares outcomes such as:
- clicks,
- purchases,
- time spent,
- cancellations.
This allows companies to estimate causal effects of design changes.
But remember an important question:
Which outcome are we measuring?
An intervention may increase engagement while reducing wellbeing.
The causal effect depends on the outcome we choose to care about.
Experiments are not always possible
We cannot randomly assign everything.
We cannot ethically randomise people to:
- smoke,
- experience poverty,
- suffer pollution.
We cannot randomly create:
- recessions,
- wars,
- natural disasters.
Sometimes experiments would be:
- unethical,
- impossible,
- too expensive.
So much causal inference relies on observational data.
This requires greater care.
Natural experiments
Sometimes the world creates situations resembling experiments.
Perhaps a policy changes in one region but not another.
Or an eligibility rule creates a threshold.
Researchers can sometimes use these changes to estimate causal effects.
These approaches are often called natural experiments or quasi-experimental methods.
The details can become mathematically sophisticated.
The important principle is that causal analysis tries to identify credible comparisons.
Counterfactuals
At the heart of causation lies a strange idea:
the counterfactual.
Suppose a patient receives Treatment A and recovers.
To know the causal effect of A for that patient, we would ideally compare:
what happened under A
with:
what would have happened to the same patient at the same moment without A.
But we cannot observe both worlds.
Only one occurred.
The other is a counterfactual.
Causal inference tries to estimate these unobserved alternatives.
The fundamental problem of causal inference
For one person:
OUTCOME WITH TREATMENT
and:
OUTCOME WITHOUT TREATMENT
cannot both usually be observed.
One future happens.
The other does not.
This connects directly to the course's philosophical theme.
Causal reasoning is partly reasoning about futures that did not occur.
We use data from other observations and assumptions to estimate those unrealised possibilities.
Possible futures and decisions
Suppose the current state is:
x(t)
We have two possible actions:
Action A
and:
Action B.
A causal model asks:
If A → what future state?
If B → what future state?
Conceptually:
CURRENT STATE
→ ACTION A → FUTURE A
→ ACTION B → FUTURE B
Decision-making requires comparing these possible futures.
This is why causal reasoning connects naturally to planning and optimisation.
Correlation describes the observed world
Correlation asks about patterns in:
the world that happened.
Causation asks about:
how the world would change under intervention.
This distinction is fundamental.
We can summarise it as:
CORRELATION
What tends to occur together?
CAUSATION
What changes if I intervene?
Prediction often starts with the first.
Decision-making increasingly requires the second.
Feedback makes causality harder
Suppose electricity prices rise.
Consumers reduce demand.
Reduced demand lowers prices.
Now:
PRICE → DEMAND
and:
DEMAND → PRICE
form a feedback loop.
Trying to infer causality from observational data becomes difficult because variables influence one another dynamically.
Many real systems have this structure.
Examples include:
- electricity markets,
- financial markets,
- traffic systems,
- social networks.
Reflexive systems
In some systems, predictions themselves become causal interventions.
Suppose an influential model predicts:
Share price will increase.
Traders buy the stock.
Their buying increases the price.
The prediction helped create the outcome.
Or:
Road A will be congested.
Drivers avoid Road A.
The forecast changes traffic.
Or:
This content will generate engagement.
The platform shows it to millions of people.
The prediction changes what people see.
These are reflexive systems.
AI makes causal feedback increasingly important
A passive model may simply report predictions.
An AI agent may:
- predict,
- decide,
- act.
Its actions alter the environment.
The next dataset is therefore generated partly by the AI's previous decisions.
So:
DATA
↓
MODEL
↓
PREDICTION
↓
ACTION
↓
CHANGED WORLD
↓
NEW DATA
Causal effects and feedback become unavoidable.
Recommendation systems illustrate the problem
Suppose a model believes:
User likes political content.
It recommends more political content.
The user clicks some of it.
The model observes:
User clicks political content.
Its confidence increases.
But perhaps the user clicked it because that was mostly what they were shown.
Observed behaviour now reflects:
user preferences
plus:
platform selection.
The system has influenced the data used to understand the user.
Causation and fairness
Suppose a model discovers that postcode predicts loan default.
That may be statistically true in historical data.
But why?
Perhaps postcode reflects:
- income,
- employment opportunities,
- historic discrimination,
- access to services.
If we treat postcode simply as a predictive feature, the model may reproduce historical inequalities.
Causal thinking encourages us to ask:
What process generated this relationship?
That question becomes central to fairness.
Removing a variable does not remove its causes
Suppose we remove:
postcode
from the model.
But keep:
- income,
- school,
- occupation,
- purchasing patterns.
Much of the same underlying social structure may remain encoded.
Causal relationships operate through networks of variables.
Simply removing one column does not necessarily remove the information or mechanisms associated with it.
Causal diagrams
One useful way of thinking about causal systems is with diagrams.
For example:
WEATHER → ICE CREAM SALES
and:
WEATHER → SUNBURN
rather than:
ICE CREAM SALES → SUNBURN
Causal diagrams force us to state our assumptions about:
- direction,
- confounding,
- mediation,
- feedback.
They do not automatically prove the causal structure.
But they help make our reasoning explicit.
Mediators
Sometimes one variable causes another through an intermediate variable.
For example:
HOT WEATHER
↓
AIR-CONDITIONING USE
↓
ELECTRICITY DEMAND
Air-conditioning use is part of the pathway through which temperature affects electricity demand.
This intermediate variable is sometimes called a mediator.
Understanding pathways can help us identify where interventions might work.
Direct and indirect effects
Suppose a transport policy reduces car use.
It may directly reduce:
traffic
and indirectly reduce:
- pollution,
- travel times,
- fuel consumption.
Causal systems can contain chains of consequences.
A decision may therefore affect many outcomes, not just the variable being optimised.
This is particularly important for service design.
Unintended consequences
Suppose a city predicts that congestion can be reduced by expanding one road.
The road becomes faster.
More people choose to drive.
Traffic eventually increases again.
An intervention can change behaviour.
The original causal model may have ignored the feedback response.
This illustrates why interventions can have unintended consequences.
Causation depends on context
A relationship that is causal in one environment may behave differently elsewhere.
Suppose increasing price reduces demand.
The strength of that response may depend on:
- income,
- alternatives,
- urgency,
- time horizon.
There is rarely one universal causal effect that applies identically to everyone.
Effects can be heterogeneous.
Average effects can hide different experiences
Suppose a policy increases average income by:
€500.
Perhaps:
- one group gains €2,000,
- another loses €1,000.
The average effect is positive.
But the distribution of effects is uneven.
This connects causal analysis to fairness.
We should not always ask only:
What is the average effect?
We may also need:
Who benefits and who loses?
Causal models are still models
This is worth emphasising.
A causal model is not reality.
It is a representation of assumptions about how variables influence one another.
Good causal inference combines:
- evidence,
- experimental design,
- statistical methods,
- domain knowledge.
But uncertainty remains.
We should avoid replacing:
correlation is not causation
with:
our causal model is definitely correct.
Both correlation and causation require careful reasoning.
Prediction and causation can work together
We do not need to choose between predictive AI and causal reasoning.
They solve different parts of the problem.
A model might predict:
Which patients are at highest risk?
A causal analysis might ask:
Which treatment would reduce that risk?
Then an optimisation system might ask:
Given limited resources, how should treatments be allocated?
The complete system becomes:
PREDICTION
↓
CAUSAL EFFECTS OF POSSIBLE ACTIONS
↓
OPTIMISATION
↓
DECISION
This is much richer than prediction alone.
Prediction tells us where we may go
Causal reasoning helps answer:
How might our actions change where we go?
Recall the course framework:
PAST → DATA → MODEL → PREDICTION → DECISION → ACTION → FUTURE
Causal reasoning sits around the connection between:
DECISION
and:
FUTURE.
We need to understand:
ACTION → CONSEQUENCE
if we want to choose actions intelligently.
Correlation belongs earlier in the loop
Correlation is largely discovered from:
PAST DATA.
We observe:
X and Y tended to occur together.
This can support prediction.
Causation asks whether an intervention changes the process that generates the future.
So:
CORRELATION → PATTERNS IN OBSERVED HISTORY
while:
CAUSATION → CONSEQUENCES OF POSSIBLE ACTIONS
This distinction connects directly to the course's relationship between past and future.
AI can predict without understanding
A sufficiently powerful model may make extraordinarily accurate predictions while having little explicit representation of causal mechanisms.
This can be impressive.
But when the environment changes or we begin using the model to intervene, weaknesses may appear.
The model may have learned:
what usually happened
without learning:
what would happen if we changed the system.
That distinction becomes increasingly important as AI moves from:
prediction
to:
decision
to:
agency.
Agents need models of consequences
Imagine an AI agent choosing between actions.
It cannot simply know:
Action A has historically been associated with good outcomes.
It ideally wants to know:
If I choose Action A now, given the current state, what consequences are likely to follow?
That is fundamentally a causal question.
Agents need some understanding of:
action → transition → new state.
This brings us towards:
- state-space models,
- reinforcement learning,
- model-based control,
- world models.
A robot constantly reasons causally
Suppose a robot asks:
What happens if I move my arm left?
It predicts a future state conditional on an action.
Or:
What happens if I brake?
The machine is not merely predicting what the world will do on its own.
It is predicting:
what the world will do if I intervene.
This is the bridge between prediction and control.
Ask a different question
Whenever you observe a correlation, ask:
- Could X cause Y?
- Could Y cause X?
- Could another variable cause both?
- Could the measurement system create the relationship?
- Could selection create it?
- Does the relationship persist in other populations?
- Does it persist through time?
- What happens if we intervene on X?
- Is X actually something we can change?
- Are there feedback effects?
- Who experiences the causal effect?
- Could the effect differ between groups?
These questions shift our thinking from:
pattern recognition
towards:
system understanding.
The central idea
Correlation is enormously valuable.
It allows us to identify relationships in data and make predictions.
Machine learning is exceptionally powerful at discovering these relationships.
But:
A predictive relationship does not automatically tell us what will happen if we intervene.
Variables can move together because:
- one causes the other,
- the causal direction is reversed,
- a third variable affects both,
- the measurement system creates the pattern,
- the selection process creates the pattern,
- chance produces an apparent relationship.
Prediction asks:
What is likely to happen?
Causal reasoning asks:
What would happen if we did something different?
That distinction becomes critical once intelligent systems begin making decisions.
The course framework can therefore be expanded:
PAST DATA
↓
CORRELATIONS AND PATTERNS
↓
PREDICTIONS
↓
POSSIBLE ACTIONS
↓
CAUSAL CONSEQUENCES
↓
DECISION
↓
FUTURE
AI systems that merely predict can often survive on correlation.
AI systems that intervene in the world increasingly need to understand the consequences of their actions.
In the final lesson of this module, we will bring the ideas together by examining a particularly subtle problem:
when data lies without lying — how perfectly real measurements and mathematically correct statistics can nevertheless create a deeply misleading picture of the world.