Math & Statistics

Causal Inference: DAGs & Confounders

Mapping cause and effect relationships using Directed Acyclic Graphs and Structural Causal Models.

🔴 advanced5 min readcausality
Causal Inference provides mathematical tools (Judea Pearl's Structural Causal Models and DAGs) to estimate true causal effects from observational data. Directed Acyclic Graphs (DAGs) represent causal assumptions visually with nodes (variables) and directed arrows (causal paths). Key graph structures include Confounders (common causes), Colliders (common effects), and Mediators (intermediate steps), determining which variables must be controlled or un-conditioned to block spurious backdoors.

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:

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:

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

  1. 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$).
  2. 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

Question 1 of 3

What happens if an analyst accidentally conditions on (controls for) a Collider variable in a causal DAG model?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min