Correlation vs Causation

Measuring relationships and interpreting what they represent

Why

Confusing correlation with causation is one of the most common and costly errors in applied data science. Models trained on correlations will fail the moment the correlation breaks — and it always eventually breaks. This separates a data scientist who builds robust systems from one who keeps being surprised when models degrade in production.

It appears in feature selection (correlated vs causal features), model interpretation (high coefficient ≠ causal), and business recommendations ("our model says X correlates with churn — should we change X?").

Intuition

Two variables can move together for three reasons: X causes Y, Y causes X, or a third variable Z causes both. Correlation only tells you they move together — it says nothing about why.

The ice cream and drowning example: both rise in summer, not because ice cream causes drowning, but because hot weather (a confounder) causes both. Your model learns this correlation happily — then gives the wrong recommendation: "ban ice cream to prevent drowning."

Explanation
Pearson vs Spearman correlation
Pearson r
r = Cov(X,Y) / (σₓ·σᵧ). Range −1 to +1. Measures linear relationships only. r=0 doesn't mean no relationship — could be non-linear (Y = X²). Scale-invariant.
Spearman ρ
Pearson applied to ranks of X and Y. Use when relationship is monotonic but not linear, data has outliers, or data is ordinal. More robust for ML feature analysis.
Confounders — the hidden cause
Confounder Z causes both X and Y → spurious correlation: Z (hot weather) ↙ ↘ X (ice cream) Y (drowning) X and Y correlate, but X does NOT cause Y. Controlling for Z removes the correlation. ML example: "users who open app on Tuesdays churn less" Confounder: power users use app more AND churn less. Tuesday usage → power user signal, not a causal churn driver. Sending Tuesday notifications won't reduce churn.
Establishing causation
Randomised controlled trial
Randomly assign subjects to treatment/control. Random assignment breaks the confounder link — any difference must be causal. Gold standard. Often not feasible (ethical, cost).
Causal inference
When RCT isn't possible: propensity score matching, instrumental variables, difference-in-differences, regression discontinuity. More assumptions, less clean — but often the only option in production.