← Back to list

Introduction to Causal Inference

Foundations of Causal Thinking for Data Analysis

Chris Kucewicz in Science For Life · 2026-01-09 05:14 · 59 claps · 5.5 min read
#statistics #causal-inference #data-science #econometrics #randomized-control-trials
Open on Medium ↗
Wiki topics: OPS · LLMOps & Inference ML · Machine Learning 📐 · Mathematics 🔬 · Science · General ⚖️ · Law & Justice

Introduction to Causal Inference

Foundations of Causal Thinking for Data Analysis

If you’ve ever taken a statistics class, one lesson likely stuck with you:

Correlation does not equal Causation.

Your stats teacher wasn’t just making a fuss — this idea is the foundation for understanding how to reason about cause and effect in data.

This post aims to give an intuitive, no-code introduction to the ideas behind moving from correlation to causation.

Photo by Henry Schneider on Unsplash

Photo by Henry Schneider on Unsplash

Understanding that two things are related is useful, but if we want to make decisions or understand how the world really works, we need to ask a different question:

Did X actually cause a change in Y?

Let’s start with a ridiculous example from Tyler Vignen’s website: Spurious Correlations:

Side-by-side line graph showing the U.S. violent crime rate and the number of babies named Cody (1985–2020). The graph is manipulated to make the two trends appear strongly correlated.

Side-by-side line graph showing the U.S. violent crime rate and the number of babies named Cody (1985–2020). The graph is manipulated to make the two trends appear strongly correlated.

By looking at the graph above, we see that the popularity of the name Cody is strongly correlated with violent crime rate. But does that mean banning the name Cody would reduce crime? Or that reducing crime somehow influences parents’ naming choices?

Obviously not. And that’s exactly the point: correlation alone doesn’t tell us what actually causes what. Correlation is just a clue, not proof.

(We could, of course, take time to understand how two seemingly unrelated phenomena might statistically appear related. After all, r = 0.972 and p < 0.01 looks pretty convincing! But that is beyond the scope of this post. If you’re interested in learning more about this phenomena, called data dredging, data snooping, or p-hacking, read more here: https://datascience.stanford.edu/news/data-snooping.)

From Association to Causation

Instead of asking “are X and Y related?”, causal inference asks:

“Does X cause Y?”

Causal inference is

the set of methods and reasoning we use to answer that question rigorously: to determine whether changes in X actually produce changes in Y, rather than just being associated with them.

And this question is the essence of causal thinking. This difference in the question is not semantic. It determines whether our analysis can support a decision, or just describe what we happened to observe. There are several key ideas we need to understand in order to say whether X causes Y.

The Counterfactual Framework

First, we need to wrap our brains around the idea of the counterfactual. The idea of counterfactuals is best described with an example: Imagine we work at a school and want to know if a new math tutoring program (X) actually improves student test scores (Y) — in other words, does the tutoring program cause better test scores? The “perfect” way to figure this out would be to take each student and measure their score twice: once with tutoring, and once without tutoring. Ideally, the difference in the student’s scores would give the true causal effect of the tutoring program.

In causal inference, we formalize this idea with counterfactual notation. For each student represented by the subscript, i, we imagine two potential outcomes:

The causal effect for that student would be written as:

The problem, though, is that we only ever observe one outcome. The student either gets tutoring or doesn’t; never both.

This unobserved outcome is the counterfactual, and it’s one of the reasons why causal thinking differs so sharply from correlation. It’s the mental model we use to reason about “what would have happened if things had been different?”, and it serves as the north star of causal inference: if we could observe both outcomes for the same person, calculating causation would be trivial.

Why Simple Comparisons Are Biased

Since we can’t see both what would happen and what actually happens for the same person, it might be tempting to just compare two different people: one who got the treatment and one who didn’t.

For example, let’s say we want to see whether attending a coding bootcamp increases salaries. We look at two people:

  • Person A attended the bootcamp and earns $100k
  • Person B didn’t go and earns $80k

Naively, we might think: “Wow, that bootcamp increased Person A’s salary by $20k!”

In notation, this naive comparison looks like:

where D = 1 indicates the treatment group (people who attended the bootcamp) and D = 0 indicates the control group (people who did not attend). Here, E[Y | D = d] is just the average outcome Y for the group with D = d.

The problem is that this difference compares average outcomes between the two groups, not the causal effect of the bootcamp itself. People who choose to attend may differ systematically from those who don’t (for example, in prior education, work experience, location, motivation, or other factors).

These pre-existing differences are called confounding variables, and they are exactly why correlation does not imply causation: the observed difference between groups might be due to these other factors, not the program itself.

Casual thinking forces us to ask:

“How can we compare these individuals as if they were identical in every way except for attending the bootcamp?”

In other words, how do we ensure we are comparing apples-to-apples, not apples-to-oranges?

Randomization and Causal Identification

Since cloning humans isn’t an option, how can we get close to that ideal counterfactual comparison? Enter the gold standard: Randomized Controlled Trials (RCTs).

The idea is this: Suppose before an upcoming election, we want to test whether sending reminder postcards increases voter turnout. We randomly assign registered voters to either:

  • Treatment group: receives a reminder postcard
  • Control group: does not receive a postcard

Random assignment ensures that the two groups are roughtly similar in all ways besides the treatment (postcard or not): age, prior voting history, political engagement, location, etc. Over time, we measure turnout in each group. The difference in turnout rates can now be interpreted as the causal effect of sending a postcard, because, thanks to randomization, the only systematic difference between the groups is wether they received the postcard. Randomization ensures apples-to-apples comparison.

(But if you’re still not convinced, check out this short visual explanation: https://www.youtube.com/watch?v=hs67NZKcFhI))

Casual Inference Without Randomization

But what happens when conducting a random experiment isn’t possible? Suppose we want to know whether having health insurance improves health outcomes. We ethically can’t randomly deny insurance to some people.

When RCTs aren’t feasible, researchers use statistical methods to approximate the counterfactual:

Each of these methods is a way to answer the same fundamental question:

What would have happened if X had (or hadn’t) occurred?

Causal inference trains us to think in terms of counterfactuals. It’s about imagining the world as it could have been, identifying factors that actually make a difference, and ignoring irrelevant variation.

Key Takeaways

  • Correlation is not causation. Knowing two things are related is just the beginning.
  • Ask the causal question: did X cause Y?
  • Confounding variables can create correlations that aren’t causal, so always consider other factors that could explain the relationship.
  • Counterfactuals are our mental model for causal thinking.
  • Randomization approximates the counterfactual when cloning isn’t possible.
  • When RCTs are infeasible, other tools exist to tease out causal effects.

I hope you found this post helpful as a first step in your journey to causal inference. In future posts, I’ll explore more of the tools researchers and economists use when RCTs aren’t available, like DiD, IV, and others.

For now, to dive deeper into causal inference, check out these resources:


메타데이터
post_id
049069fde64d
slug
introduction-to-causal-inference-049069fde64d
url
https://medium.com/science-for-life/introduction-to-causal-inference-049069fde64d
canonical_url
https://medium.com/science-for-life/introduction-to-causal-inference-049069fde64d
author_url
https://medium.com/@ckucewicz21
status
ok
fetched_at
2026-06-09 15:37:30