Foundations to Frontier
Tests
A. Mathematical Foundations › A5 Statistics › Causal inference

Correlation vs Causation and Confounding

Two quantities can move together without one causing the other: a hidden common cause (a confounder) can create, hide or even reverse an association, and filtering data on a common effect (a collider) can conjure one from nothing. You will quantify omitted-variable bias, see Simpson's paradox in real and robotics data, learn when adjusting for a variable removes bias and when it adds bias, and set up the questions the rest of causal inference answers.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Ice cream and sunburn

On days when people eat more ice cream, more people get sunburned. Does ice cream cause sunburn? No: sunny weather causes both. A hidden common cause like that is a confounder. It makes two things move together even though neither causes the other.

Asking “if I change X, will Y change?” is a different question from “do X and Y move together?” The first is about causation, the second only about correlation.

When does association mean causation?
XY
true causal effect β = 0.00 · pooled (naive) slope 0.97 · within-stratum slope (avg) 0.30 · bias γδ/(γ²+1) ≈ 1.00
Colours: low / middle / high Z. Dashed: the pooled regression of Y on X, which mixes the causal effect with the back-door path X ← Z → Y. Set β = 0: X has no effect on Y, yet the pooled line slopes. Stratifying on Z (solid lines) blocks the back door and recovers β.
Why engineers care

A new controller seems to cause more faults, but it was rolled out first on the oldest rovers. A sensor looks predictive, but only because the same weather affects it and the target. Mistaking correlation for causation leads to expensive wrong decisions. Causal thinking tells you which comparisons are fair.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A confounder is…
  2. 2. A strong correlation between X and Y proves X causes Y?
  3. 3. The causal question is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Three ways to get an association without causation

  1. Confounding: X←Z→YX\leftarrow Z\to Y. A common cause.
  2. Reverse causation: Y→XY\to X. Do more firefighters cause bigger fires?
  3. Selection (collider) bias: X→S←YX\to S\leftarrow Y, and we only see units with S=1S = 1. Among robots that passed qualification, speed and reliability may look negatively related even if they’re independent overall (Berkson’s paradox).

Plus plain chance: test enough pairs and some correlate (A5.1-10).

Simpson’s paradox

An association can reverse when you split by a third variable. In a classic kidney-stone study (Charig et al., 1986), treatment A had higher success for small stones and for large stones, but lower success overall. That’s because A was given mostly to the harder, large-stone cases. Which answer is “right” depends on the causal structure, not on the numbers alone. Here stone size affects both treatment choice and outcome, so the stratified comparison is the fair one.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Simpson's paradox is when…
  2. 2. Selecting only units that passed a test can…
  3. 3. 'More firefighters, bigger fires' is an example of…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Omitted-variable bias

Suppose Y=βX+δZ+εY = \beta X + \delta Z + \varepsilon and X=γZ+ηX = \gamma Z + \eta (unit variances, independent noise). The naive regression of YY on XX converges to

β^naive→β+δCov⁡(X,Z)Var⁡(X)=β+δγγ2+1\hat\beta_{\text{naive}} \to\beta + \delta\frac{\operatorname{Cov}(X, Z)}{\operatorname{Var}(X)} = \beta + \frac{\delta\gamma}{\gamma^2 + 1}

The bias is zero only if ZZ doesn’t affect YY (δ=0\delta = 0) or doesn’t affect XX (γ=0\gamma = 0). Regressing on both XX and ZZ gives β\beta, if ZZ is the only confounder and the model is right.

Adjust for confounders, not colliders or mediators

  • Adjusting for a confounder removes bias.
  • Adjusting for a mediator (X→M→YX\to M\to Y) removes part of the effect you want to measure.
  • Adjusting for a collider creates bias where none existed.

So “control for everything” is wrong advice. You need the causal graph (A5.3-3 and A5.3-4). Also, correlation measures only linear association: corr⁡(X,X2)=0\operatorname{corr}(X, X^2) = 0 for symmetric XX.

🐍 Exercise 1: confounding creates and hides effects
Simulate Z → X, Z → Y, X → Y. Show the naive slope is β + γδ/(γ² + 1) and that adjusting for Z recovers β, including a case where the true effect is 0 and one where confounding masks a real effect.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Omitted-variable bias is zero when…
  2. 2. Adjusting for a collider…
  3. 3. corr(X, X²) for X symmetric about 0 is…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Deriving the bias

Cov⁡(X,Y)=βVar⁡(X)+δCov⁡(X,Z)=β(γ2+1)+δγ\operatorname{Cov}(X, Y) = \beta\operatorname{Var}(X) + \delta\operatorname{Cov}(X, Z) = \beta(\gamma^2 + 1) + \delta\gamma, so Cov⁡(X,Y)/Var⁡(X)=β+δγ/(γ2+1)\operatorname{Cov}(X, Y)/\operatorname{Var}(X) = \beta + \delta\gamma/(\gamma^2 + 1). ∎ Notice that the sign of the bias is the sign of δγ\delta\gamma. That’s useful for sensitivity reasoning: “even a confounder this strong couldn’t explain the effect away” (Cornfield et al., 1959, on smoking and lung cancer; see also VanderWeele and Ding, 2017, on E-values).

Collider bias, formally

If X⊥YX\perp Y and S=1[X+Y>c]S = \mathbb 1[X + Y > c], then conditioning on S=1S = 1: given that the sum is large, learning XX is small makes YY likely large. So corr⁡(X,Y∣S=1)<0\operatorname{corr}(X, Y\mid S = 1) < 0.

Standardization (the adjustment formula)

If ZZ blocks all confounding (A5.3-4), the effect of setting X=xX = x is

P(Y=1∣do⁡(X=x))=∑zP(Y=1∣X=x,Z=z)P(z)P(Y = 1\mid\operatorname{do}(X = x)) = \sum_zP(Y = 1\mid X = x, Z = z)P(z)

Weight the stratum-specific rates by the population distribution of ZZ, not by the distribution within each treatment group.

Exercise 3.1: The kidney-stone numbers

A: small 81/87 = 0.931, large 192/263 = 0.730, overall 273/350 = 0.780. B: small 234/270 = 0.867, large 55/80 = 0.688, overall 289/350 = 0.826. A wins in each stratum but loses overall, because 75% of A’s patients had large stones vs 23% of B’s.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The sign of the omitted-variable bias is the sign of…
  2. 2. The adjustment formula weights strata by…
  3. 3. Conditioning on X + Y > c makes independent X and Y…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Is the new grasp planner worse?

Fleet logs show planner B succeeds less often than planner A overall. But operators sent planner B mostly to hard objects. Stratifying by object difficulty, B is better on easy and on hard objects. Standardizing over the fleet’s difficulty mix gives B’s real advantage. Telemetry analyses in robotics and aerospace (anomaly vs. software version, failure vs. mission profile) routinely hit this trap. The fix is a causal model of how treatments were assigned, or better, randomization (A5.3-5).

🐍 Exercise 2 (research): Simpson's paradox in grasp logs
Compute overall and per-difficulty success rates for two planners when the better planner was preferentially used on hard objects, then standardize over difficulty to recover the true effect.

Causal pitfalls in AI, robotics and aerospace

  • Shortcut learning and spurious correlations: classifiers keying on hospital tokens or backgrounds instead of the object (Geirhos et al., 2020). Causal-invariance training targets features stable across environments (Arjovsky et al., 2019).
  • Causal confusion in imitation learning: a driving policy that copies the brake light instead of the obstacle (de Haan, Jayaraman and Levine, 2019).
  • Survivorship and selection bias: the WWII bomber-armor analysis by Abraham Wald, and fleet data that includes only vehicles that kept reporting.
  • Off-policy evaluation: logged actions are confounded by the old policy’s choices; this is why inverse-propensity weighting is used (A5.3-6).

References

  1. J. Pearl, M. Glymour, N. Jewell (2016). Causal Inference in Statistics: A Primer. Wiley.
  2. M. Hernán, J. Robins (2020). Causal Inference: What If. Chapman & Hall/CRC.
  3. C. Charig, D. Webb, S. Payne, J. Wickham (1986). “Comparison of treatment of renal calculi by open surgery, PCNL, and ESWL.” BMJ, 292.
  4. E. H. Simpson (1951). “The interpretation of interaction in contingency tables.” JRSS B, 13(2).
  5. J. Berkson (1946). “Limitations of the application of fourfold table analysis to hospital data.” Biometrics Bulletin, 2(3).
  6. J. Cornfield et al. (1959). “Smoking and lung cancer: recent evidence and a discussion of some questions.” JNCI, 22.
  7. T. VanderWeele, P. Ding (2017). “Sensitivity analysis in observational research: introducing the E-value.” Annals of Internal Medicine, 167(4).
  8. P. de Haan, D. Jayaraman, S. Levine (2019). “Causal confusion in imitation learning.” NeurIPS.
  9. R. Geirhos et al. (2020). “Shortcut learning in deep neural networks.” Nature Machine Intelligence, 2.
  10. M. Arjovsky, L. Bottou, I. Gulrajani, D. Lopez-Paz (2019). “Invariant risk minimization.” arXiv:1907.02893.