Causal Inference: DAGs & Confounders
Mapping cause and effect relationships using Directed Acyclic Graphs and Structural Causal Models.
What is Causal Inference?
Standard machine learning answers predictive questions: "Given feature $X$, what is the expected value of $Y$?" ($P(Y \mid X)$).
Causal Inference answers interventional and counterfactual questions:
- "If we raise the price of a subscription by 10 dollars ($do(\text{Price} = 10)$), how many customers will churn?"
- "Would Patient A have survived if they had received Treatment B instead of Treatment A?"
Frameworks developed by Judea Pearl (Structural Causal Models & DAGs) and Donald Rubin (Potential Outcomes Framework) provide mathematical rules to answer these questions using observational data.
Directed Acyclic Graphs (DAGs)
A Causal DAG visualizes causal assumptions:
- Nodes: Variables in the system.
- Directed Arrows ($A \to B$): Direct causal impact from $A$ to $B$.
The three fundamental 3-node structures in Causal DAGs are:
┌──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ 1. CONFOUNDER │ 2. MEDIATOR │ 3. COLLIDER │
├──────────────────────────┼──────────────────────────┼──────────────────────────┤
│ Z ──► X and Z ──► Y │ X ──► Z ──► Y │ X ──► Z and Y ──► Z │
│ Common cause of X & Y. │ Intermediate step in the │ Common effect of X & Y. │
│ MUST CONTROL FOR Z! │ causal path. │ DO NOT CONTROL FOR Z! │
└──────────────────────────┴──────────────────────────┴──────────────────────────┘
1. CONFOUNDER 2. MEDIATOR 3. COLLIDER
(Z) (X) (X) (Y)
╱ ╲ │ ╲ ╱
▼ ▼ ▼ ▼ ▼
(X) (Y) (Z) (Z)
│
▼
(Y)
The Backdoor Criterion & Conditioning Rules
To estimate the true causal effect of $X \to Y$, we must block all Spurious Backdoor Paths (paths with arrows pointing INTO $X$):
Rule 1: Always Control for Confounders
If $Z$ points to both $X$ and $Y$, $Z$ creates a spurious backdoor path ($X \leftarrow Z \rightarrow Y$).
Conditioning on $Z$ (including $Z$ in regression or matching) blocks the backdoor path, isolating the true causal effect!
Rule 2: DO NOT Control for Colliders!
If $X$ and $Y$ both point into $Z$ ($X \rightarrow Z \leftarrow Y$), $Z$ is a Collider.
Un-conditioned, the path between $X$ and $Y$ is already naturally blocked.
If you accidentally control for (condition on) Collider $Z$, you OPEN a spurious non-causal path between $X$ and $Y$ (Collider Stratification Bias)!
COLLIDER BIAS EXAMPLE:
Suppose Talent (X) and Beauty (Y) are independent in the general population.
If an agent selects Movie Stars (Z = Talent -> Star <- Beauty) and conditions ONLY on Movie Stars:
Among Movie Stars, Talent and Beauty will appear NEGATIVELY correlated! (If a star is not beautiful, they must be exceptionally talented to be famous).
Say this out loud
Causal Inference uses Directed Acyclic Graphs (DAGs) to isolate cause and effect. The three core structures are Confounders (common causes pointing to X and Y), Mediators (intermediate steps), and Colliders (common effects). Confounders must be controlled for to block backdoor paths, whereas Colliders must NEVER be controlled for to avoid opening spurious bias.
Followups to expect
- What is the Potential Outcomes Framework (Rubin Causal Model)? Defining individual causal effect as $Y_1(i) - Y_0(i)$ (the difference between outcomes under treatment vs control for subject $i$).
- What is the Fundamental Problem of Causal Inference? We can only observe $Y_1(i)$ OR $Y_0(i)$ for a single individual at any given time (the un-observed outcome is the missing Counterfactual).
Check yourself
What happens if an analyst accidentally conditions on (controls for) a Collider variable in a causal DAG model?