Skip to content
Knowledge

/knowledge/causal-inference

Causal Inference & A/B Testing

Did the thing we did actually cause the change — or would it have happened anyway? It's the hardest and most valuable question in analysis, and answering it honestly takes more than a correlation.

Studied
Causal Inference & Experimental DesignAdvanced · evaluation & A/B testing
When
Stats & gov analysis
Applied in
Did the intervention work?
Read / Refreshed
~16 min read2026-06-26

Almost every decision worth making is a causal one. Will this policy reduce harm? Did that change improve the outcome? Would the result have been different if we'd acted? Yet the data we have is overwhelmingly correlational — it tells us what went together, not what caused what. Causal inference is the discipline of bridging that gap: getting from "these two things move together" to "this one made that one happen", and being honest about how much confidence the bridge can bear.

It's the question I care about most in government-analyst work, because the alternative — mistaking a coincidence for an effect — leads to acting on things that don't work and crediting interventions for changes they didn't cause. This page is the toolkit, from the gold-standard experiment to the methods you reach for when you can't run one.

01

Correlation isn't enough

The famous warning — correlation does not imply causation — is true but usually under-explained. When two things, XX and YY, move together, there are several possibilities, and only one is the one you want:

  • XX causes YY (what you hope).
  • YY causes XX (reverse causation).
  • Some third thing ZZ causes both (a confounder — the classic "ice-cream sales and drownings both rise with temperature").
  • It's coincidence (especially with small samples or many comparisons).

The whole field is machinery for ruling out the second, third, and fourth so you're left with the first. The cleanest way to do that is to intervene — and that's where experiments come in.

02

The counterfactual: what would have happened

The modern way to define a causal effect is the potential outcomes framework. For a unit (a person, a region, a case), imagine two parallel worlds: one where it receives the treatment, with outcome Y(1)Y(1), and one where it doesn't, with outcome Y(0)Y(0). The causal effect for that unit is the difference:

τi=Yi(1)Yi(0)\tau_i = Y_i(1) - Y_i(0)

Here's the catch, and it has a grand name: the fundamental problem of causal inference. For any single unit you only ever observe one of those two worlds — the person either got the treatment or didn't. The other outcome, the counterfactual, is forever missing. You can never measure an individual effect directly.

03

The gold standard: randomise

How do you make two groups comparable in everything — including things you didn't measure or never thought of? You can't match them by hand on infinite variables. But there is one almost magical trick: assign the treatment at random. This is the randomised controlled trial (RCT).

Randomisation works because, with enough units, it makes the treatment and control groups statistically identical on average — same age mix, same prior behaviour, same everything, measured or not. Any confounder is balanced across both groups by chance, so the only systematic difference left is the treatment itself. That's why the simple difference in group averages becomes a credible causal estimate:

τ^=YˉtreatedYˉcontrol\hat{\tau} = \bar{Y}_{\text{treated}} - \bar{Y}_{\text{control}}

Randomisation is the only method that handles unknown confounders for free. Every observational method below is, in essence, an attempt to approximate what randomisation gives you automatically.

04

A/B testing: the RCT in the wild

An A/B test is just an RCT run on a product or process: split users at random into A (control) and B (treatment), show each group a different version, and compare a chosen metric. It's the workhorse of evidence-based decisions — and getting it right is more subtle than "ship it and check":

  • Power and sample size first. Decide before you start how big an effect you care about and how many units you need to detect it (the statistical power calculation). Underpowered tests fail to find real effects and waste the experiment.
  • Don't peek. Repeatedly checking results and stopping the moment they look significant inflates false positives badly — every peek is another roll of the dice. Fix the sample size (or use a proper sequential-testing method) and wait.
  • One change, one metric. Define the primary metric up front. Testing twenty metrics and celebrating whichever turns significant is just multiple comparisons in disguise.
  • Check the randomisation held. Sanity-check that the groups really are balanced on known covariates, and watch for leakage (users in both arms, network spillover between them).

05

Confounders, colliders & DAGs

When you can't randomise, you have to reason explicitly about which variables to adjust for — and the surprise is that adjusting for the wrong one makes things worse. A causal diagram (a DAG — directed acyclic graph) draws each variable as a node and each causal arrow between them, making the structure visible.

confounder — adjustZXYcollider — do NOT adjustXYC
A confounder (Z) sits upstream of both treatment and outcome and creates a spurious association — you must adjust for it. A collider (C) sits downstream of both; adjusting for it opens a fake association that wasn't there. Same-looking variables, opposite advice.

A confounder is a common cause of both treatment and outcome — leave it unadjusted and it fakes an effect; adjusting for it removes the bias. A collider is a common effect of both — and adjusting for it creates a spurious association that wasn't there. They look similar and demand opposite handling, which is exactly why drawing the diagram first beats blindly "controlling for everything".

06

When you can't randomise

Often randomising is impossible or unethical — you can't randomly assign a policy, a major life event, or who gets investigated. Quasi-experimental methods exploit natural variation to mimic an experiment. The main ones, weakest assumptions to strongest:

  • Matching / regression adjustment — build a comparison group that looks like the treated group on observed variables (propensity-score matching is the common flavour). Only as good as the confounders you measured.
  • Difference-in-differences — compare the change over time in a treated group against the change in an untreated group. If both groups would have moved in parallel without the treatment, the extra movement is the effect. Cancels out anything fixed about each group.
  • Instrumental variables — find a variable that nudges treatment but affects the outcome only through it, and use it to isolate causal variation.
  • Regression discontinuity — when treatment switches at a sharp threshold (a cutoff score, an age limit), units just either side are near-identical, so comparing them approximates a local experiment.

07

Traps that fake causation

Even careful analysts get fooled. The recurring traps:

  • Simpson's paradox — a trend that appears in every subgroup can reverse when the groups are combined (or vice versa). Aggregation can flip the sign of an effect, so always ask whether a lurking variable is splitting the data.
  • Selection bias — when who ends up in your data is related to the outcome (only successful cases get recorded, only certain people respond). The sample no longer represents the population, and effects get manufactured.
  • Regression to the mean — extreme values tend to be followed by less extreme ones for no causal reason. Act after a spike and the natural settling looks like your intervention worked.
  • p-hacking — slicing, re-testing, and trying specifications until something crosses significance. Tie this back to multiple comparisons: enough tests guarantee a "finding" that's pure noise. Pre-register the question.

08

Where it shows up in my work

09

Refresh in 60 seconds

The internal-validity spectrum (RCT → RDD/DiD → matching) and A/B pitfalls (peeking, power, multiple metrics) reflect current causal-inference and experimentation references alongside coursework.