Causal Identification with Directed Acyclic Graphs#

A commerce analytics platform like Shopify wants to measure the causal effect of digital advertising spend (\(T\)) on the sales of its affiliated merchants (\(Y\)). The data team runs a regression of sales on advertising investment and finds a positive and significant coefficient. But one analyst points out a structural problem: larger merchants not only spend more on advertising — they also sell more for reasons unrelated to the ads. If merchant size (\(Z\)) determines both how much is spent on advertising and how many sales are made, the regression conflates the causal effect of advertising spend with the pre-existing advantage of larger merchants.

Which variables do we need to include as controls to recover the causal effect of \(T\) on \(Y\)? The answer to this question is not statistical — it is structural. It depends on how we believe the data were generated. In this section we introduce directed acyclic graphs (DAGs), the language that allows us to represent that causal structure and derive from it which variables to include in the regression and which to avoid.

This section covers four ideas: (1) what a DAG is and how to read it; (2) the three fundamental structures that determine whether controlling a variable opens or closes a spurious path; (3) the formal criterion that unifies these rules — the back-door criterion; and (4) Berkson’s paradox, an extreme case of collider selection bias that illustrates how dangerous it can be to condition on the wrong variable.


1. Learning Objectives#

By the end of this section, the reader will be able to:

  • Read a DAG and enumerate all paths from treatment \(T\) to outcome \(Y\).

  • Apply the three structural rules (fork, chain, collider) to determine whether a path is open or blocked.

  • Use the back-door criterion to derive the minimal set of control variables that identifies the causal effect.

  • Recognize and avoid collider bias: understand why controlling for the wrong variable worsens the estimate.

  • Distinguish between the total effect and the direct effect of \(T\) on \(Y\), and know when each is the relevant estimand.

  • Connect DAGs to real-world empirical failures, in particular Berkson’s paradox.

  • Understand when the front-door criterion can recover a causal effect even when the key confounder is unobserved, and apply the two-step estimation procedure.


2. What Is a DAG?#

A directed acyclic graph is a diagram where each node represents a variable and each arrow represents a direct causal relationship. The arrow \(A \rightarrow B\) means that \(A\) causes \(B\). The acyclicity requirement — no cycles — reflects that in the data-generating process we are modeling there is no simultaneous bidirectional causality: \(A\) can cause \(B\), but \(B\) cannot in turn cause \(A\) within the same static system.

The DAG for the Shopify example has three nodes and three arrows:

\[Z \rightarrow T \rightarrow Y \qquad Z \rightarrow Y\]

Merchant size (\(Z\)) causes advertising spend (\(T\)) and also directly causes sales (\(Y\)). Advertising spend, in turn, causes sales. The arrow \(T \rightarrow Y\) is the causal effect we want to estimate.

The central question of causal identification is: which variables do we need to include in the regression of \(Y\) on \(T\) so that the coefficient on \(T\) reflects the causal effect and nothing else? To answer this question, we need to identify all paths connecting \(T\) to \(Y\) in the DAG.

A path between two nodes is any sequence of arrows connecting them, regardless of direction. In the example above there are two paths from \(T\) to \(Y\):

  1. \(T \rightarrow Y\) — the direct causal path, the arrow of interest.

  2. \(T \leftarrow Z \rightarrow Y\) — a path that runs “backward” from \(T\) to \(Z\) and then forward to \(Y\).

The second path is called a back-door path: it begins with an arrow pointing into \(T\), meaning it is not part of the causal mechanism from \(T\) to \(Y\) but rather a source of confounding. If this path is open, the correlation between \(T\) and \(Y\) in the data reflects both the causal effect \(T \rightarrow Y\) and the shared influence of \(Z\).


3. The Three Fundamental Structures#

DAGs can have many nodes and arrows, but all of the complexity reduces to three elementary structures. Understanding these three is sufficient to analyze virtually any DAG that arises in empirical practice.

3.1 The Fork (Confounder)#

The most familiar structure is the fork: a variable \(Z\) causes both \(T\) and \(Y\).

\[T \leftarrow Z \rightarrow Y\]

\(Z\) is a common cause of \(T\) and \(Y\) — what we typically call a confounder. The path \(T \leftarrow Z \rightarrow Y\) is a back-door path and, as long as we do not control for \(Z\), it remains open. The correlation between \(T\) and \(Y\) in the data mixes the causal effect of \(T\) with the influence of \(Z\).

To see this algebraically, suppose the data-generating process is:

\[Z \sim \mathcal{N}(0,1), \quad T = \gamma Z + \varepsilon_T, \quad Y = \beta T + \delta Z + \varepsilon_Y\]

where \(\varepsilon_T\) and \(\varepsilon_Y\) are noise terms independent of each other and of \(Z\). The causal effect of \(T\) on \(Y\) is \(\beta\). If we run the regression of \(Y\) on \(T\) without including \(Z\), the estimated coefficient converges to:

\[\text{plim}\,\hat{\beta}_{naive} = \beta + \frac{\delta \gamma}{\gamma^2 + \sigma^2_{\varepsilon_T}}\]

The second term is the omitted variable bias: positive when \(\delta\) and \(\gamma\) have the same sign (the confounder pushes \(T\) and \(Y\) in the same direction), and negative when they have opposite signs. Including \(Z\) in the regression makes \(T \perp \varepsilon_Y \mid Z\), which eliminates the bias and recovers \(\beta\). The full derivation appears in the appendix.

In the Shopify example: \(\delta > 0\) (larger merchants sell more) and \(\gamma > 0\) (larger merchants spend more on advertising), so the bias is positive — the regression without controls overestimates the effect of advertising.

3.2 The Collider#

The second structure is, for many students, the most surprising: the collider. Here, two variables that are independent (or correlated for other reasons) jointly cause a third variable \(A\):

\[T \rightarrow A \leftarrow Y\]

The two arrows “collide” at \(A\). The key property of the collider is the opposite of the fork: the path passing through a collider is blocked by default, and opens when we condition on it.

Why? Intuitively: if we know that \(A\) took a certain value, then information about \(T\) tells us something about \(Y\) even if \(T\) and \(Y\) were not directly related. Suppose \(A\) = “employee was hired,” \(T\) = technical skills, and \(Y\) = long-term potential. To be hired by a selective firm, a candidate needs to be strong in \(T\) or in \(Y\) (or both). If we observe that someone was hired but their technical skills are mediocre, we infer that their long-term potential must be high — even if in the general population the two variables are uncorrelated. Conditioning on \(A\) creates an artificial dependence between \(T\) and \(Y\) within the selected sample.

This has a direct implication for control selection: including \(A\) in the regression of \(Y\) on \(T\) — that is, conditioning on the collider — opens a spurious path that was previously closed, introducing bias where there was none.

A less obvious variant is M-Bias, with the structure:

\[T \leftarrow A \rightarrow B \leftarrow C \rightarrow Y\]

Here \(B\) is a collider for \(A\) and \(C\). The path \(T \leftarrow A \rightarrow B \leftarrow C \rightarrow Y\) is blocked by default (the collider \(B\) closes it). But if we include \(B\) in the regression, we open that path and create bias. The name M-Bias comes from the “M” shape the DAG traces. The remedy is to control for both \(A\) and \(C\), which re-blocks the path that \(B\) had opened.

3.3 The Mediator#

The third structure is the chain or mediator:

\[T \rightarrow M \rightarrow Y\]

\(M\) transmits part of the effect of \(T\) to \(Y\). Controlling for \(M\) does not introduce bias or eliminate confounding — it simply changes the question we are answering:

  • Without controlling \(M\): the coefficient on \(T\) captures the total effect of \(T\) on \(Y\), including the part that operates through \(M\).

  • Controlling for \(M\): the coefficient on \(T\) captures only the direct effect, the part that does not pass through \(M\).

In the digital product example: if \(T\) is the launch of a new feature, \(M\) is user engagement, and \(Y\) is revenue, the total effect includes both the direct impact of the feature and the increase in revenue that comes through higher engagement. If the product team wants to know whether the launch increases revenue in total, they should not control for \(M\). If they want to isolate the effect on revenue that does not pass through engagement, they should control for \(M\). Neither answer is “incorrect” — it depends on which business question is relevant.

Verification via Simulation#

With these three structures in mind, the DAG identification simulation allows us to verify each of these points empirically. The dashboard presents four scenarios: Fork, Collider, M-Bias, and Mediator. In each one, the true causal effect of \(T\) on \(Y\) is exactly 1.0. The student chooses which variables to include as controls and observes in real time how the OLS estimator moves toward or away from the true value.

Before using the simulation, reason from the rules above: which variables should you control for in each scenario so that the estimator is unbiased?

  • Fork: without controlling \(Z\), does the coefficient exceed 1.0? Add \(Z\) and verify that the bias disappears.

  • Collider: without any controls, is the bias approximately zero? Add only \(A\) — does bias appear? Conditioning on the collider opens a path that was previously blocked.

  • Collider again: add both \(A\) and \(B\). Is the true effect recovered? Including \(B\) re-blocks the path that \(A\) had opened.

  • M-Bias: without controls, is the estimator close to 1.0? Add only \(B\) — does the bias worsen rather than improve?

  • Mediator: without controlling \(M\) you get the total effect \(\approx 1.0\). Control for \(M\) — the coefficient falls because the indirect channel is absorbed by \(M\).


4. D-Separation and the Back-Door Criterion#

The three structures above are not just examples — they are the atomic building blocks of any DAG. The formal criterion that generalizes their logic is called d-separation.

4.1 D-Separation Rules#

A path between \(T\) and \(Y\) is blocked by a set of variables \(S\) if it contains at least one of the following:

  1. A chain \(\cdots \rightarrow V \rightarrow \cdots\) or a fork \(\cdots \leftarrow V \rightarrow \cdots\), where \(V \in S\) (controlling the intermediate node blocks the path).

  2. A collider \(\cdots \rightarrow V \leftarrow \cdots\), where \(V \notin S\) and no descendant of \(V\) belongs to \(S\) (the collider blocks by default; controlling a descendant re-opens it).

From these two conditions we derive three operational rules:

  1. Chain \(T \rightarrow M \rightarrow Y\): open if \(M \notin S\); blocked if \(M \in S\).

  2. Fork \(T \leftarrow Z \rightarrow Y\): open if \(Z \notin S\); blocked if \(Z \in S\).

  3. Collider \(T \rightarrow A \leftarrow (\cdots)\): blocked if \(A \notin S\) and no descendant of \(A \in S\); open if \(A \in S\) or a descendant of \(A \in S\).

A set \(S\) d-separates \(T\) from \(Y\) if all paths between \(T\) and \(Y\) are blocked by \(S\). The full mathematical formalization appears in the appendix.

4.2 The Back-Door Criterion#

The d-separation rules allow us to state the criterion that answers our original question: which controls does the regression need in order to identify the causal effect of \(T\)?

Result (Back-Door Criterion, Pearl 2009): A set \(S\) satisfies the back-door criterion relative to the pair \((T, Y)\) if:

  1. No element of \(S\) is a descendant of \(T\).

  2. \(S\) blocks every back-door path between \(T\) and \(Y\).

When \(S\) satisfies the criterion, the causal effect of \(T\) on \(Y\) is identifiable by adjustment:

\[E[Y(t)] = \sum_s E[Y \mid T=t,\, S=s] \cdot P(S=s)\]

In linear models this expression simplifies: the regression of \(Y\) on \(T\) and the variables in \(S\) identifies the causal coefficient of \(T\). The derivation appears in the appendix.

Returning to the Shopify example: the only back-door path is \(T \leftarrow Z \rightarrow Y\). The set \(S = \{Z\}\) satisfies the criterion because (i) merchant size \(Z\) is not a descendant of advertising spend \(T\), and (ii) \(\{Z\}\) blocks the only back-door path. Therefore, the regression of sales on advertising spend and merchant size identifies the causal effect of advertising.

Note what the criterion asks for: not to control for “everything relevant” or “everything correlated with \(T\).” It asks for exactly what is needed to block back-door paths, without conditioning on colliders or mediators when the question is the total effect. Over-controlling can be as harmful as under-controlling.


5. Collider Selection Bias: Berkson’s Paradox#

So far, colliders appeared as variables someone might be tempted to control for. But there is a more dangerous variant: when the sample selection process is the collider. In that case the bias is not introduced by the analyst including a variable — it is built into the design of the study itself.

Imagine that the people team at a highly selective tech firm wants to study whether first-year performance (\(X\)) predicts long-term success (\(Y\), measured as promotions and retention over five years). They look at data from all current employees and find a surprisingly negative correlation: those who performed best in their first year have worse long-term trajectories. Does early talent “burn out” employees? Not necessarily.

The problem is structural: to be hired by that selective firm, a candidate must demonstrate convincing signals of quality — either high expected performance (\(X\), via technical skills) or high expected long-term potential (\(Y\), via references, past projects, interviews). The hiring process implicitly conditions on the sum \(X + Y\): only those who exceed a joint threshold make it into the sample. The variable \(S\) = “was hired” is caused by both \(X\) and \(Y\):

\[X \rightarrow S \leftarrow Y\]

\(S\) is a collider. By studying only the employees who were hired, we condition on \(S\). And as we saw in section 3.2, conditioning on a collider opens the path \(X \rightarrow S \leftarrow Y\), creating an artificial negative correlation between \(X\) and \(Y\) within the selected sample — even when the population-level correlation is positive or zero. This is Berkson’s paradox.

The paradox appears whenever a sample is selected by conditioning — explicitly or implicitly — on a function of the variables of interest: studies of startups that raised venture capital (selected on team quality + market opportunity), studies of elite athletes who competed internationally, studies of hospitalized patients (selected on severe symptoms). In all these cases, the observed correlation in the selected sample can differ dramatically from the population correlation, and can even reverse sign.

The following simulation lets us explore how much the observed correlation changes as selection becomes more severe.

  • Scenario Berkson (no true causal effect between \(X\) and \(Y\)), 75% retention: is the coefficient in the selected sample negative, even though in the full population it is \(\approx 0\)?

  • Reduce retention to 25%: does the sign reversal intensify with stricter selection?

  • Switch to scenario Selection with \(\beta = 0.5\), 50% retention: can collider selection reverse even a positive true effect?

  • Return to Berkson with 90% retention: the paradox nearly disappears — mild selection, mild distortion.

What Do We Observe?#

The simulation confirms that Berkson’s paradox is a direct consequence of the collider structure, not of measurement error or insufficient sample size. As selection becomes more severe (lower retention percentage), the correlation in the selected sample diverges further from the population correlation and can reverse sign even when the true causal effect is positive.

The error is structural: adding more observations from the selected sample does not fix the problem. The negative correlation becomes more precise as \(n\) grows, but it continues to point in the wrong direction. The correction requires access to the full population or a design that avoids conditioning on the collider.


6. The Limits of DAGs: When Back-Door Adjustment Is Not Enough#

The back-door criterion identifies the causal effect whenever there exists a set of observable variables \(S\) that blocks all back-door paths. This condition — which economists call the conditional independence assumption (CIA) or conditional ignorability — is the same one that underpins the regression control strategy discussed in the multiple regression section, now expressed in the language of DAGs.

But in many empirical problems of practical interest, the key confounders are unobservable. In the Shopify example, if merchant size \(Z\) is not recorded in the data, we cannot block the path \(T \leftarrow Z \rightarrow Y\) by regression adjustment. No statistical control can substitute for a variable that does not exist in the data.

There is, however, one purely graph-based exception: if the causal effect of \(T\) on \(Y\) operates entirely through a fully observable mediator — and if that mediator is not directly caused by the unobserved confounder — then the front-door criterion can identify the causal effect without ever observing the confounder. Section 7 develops this case.

When even that structure is absent, stronger identification strategies are needed: methods that exploit exogenous variation in the treatment to construct a credible counterfactual without needing to control for the confounder directly. The following sections of this chapter present the main quasi-experimental methods — including the differences-in-differences strategy we saw earlier. In all of them, the language of DAGs remains useful for formalizing what the method identifies and under which assumptions — only the identification condition is not the back-door criterion but a different criterion that does not require observing \(Z\).


Appendix: Formal Derivations#

A.1 Omitted Variable Bias and the Back-Door Criterion#

Consider the fork data-generating process with \(\text{Var}(Z) = 1\):

\[Z \sim \mathcal{N}(0, 1), \quad T = \gamma Z + \varepsilon_T, \quad Y = \beta T + \delta Z + \varepsilon_Y\]

where \(\varepsilon_T \sim \mathcal{N}(0, \sigma^2_{\varepsilon_T})\), \(\varepsilon_Y \sim \mathcal{N}(0, \sigma^2_{\varepsilon_Y})\), independent of each other and of \(Z\).

Step 1 — Compute the relevant covariances:

\[\text{Cov}(T, Z) = \gamma, \qquad \text{Var}(T) = \gamma^2 + \sigma^2_{\varepsilon_T}\]
\[\text{Cov}(Y, T) = \beta \text{Var}(T) + \delta \text{Cov}(Z, T) = \beta(\gamma^2 + \sigma^2_{\varepsilon_T}) + \delta\gamma\]

Step 2 — The OLS estimator of \(Y\) on \(T\) without \(Z\) converges in probability to:

\[\text{plim}\,\hat{\beta}_{naive} = \frac{\text{Cov}(Y, T)}{\text{Var}(T)} = \beta + \frac{\delta\gamma}{\gamma^2 + \sigma^2_{\varepsilon_T}}\]

The second term is the omitted variable bias (OVB). This result connects directly to the OVB formula discussed in the multiple regression section.

Step 3 — With back-door adjustment (\(S = \{Z\}\)): the correctly specified model is \(Y = \beta T + \delta Z + \varepsilon_Y\). Since \(\varepsilon_Y\) is independent of both \(T\) and \(Z\) by construction, the OLS estimator of the regression \(Y \sim T + Z\) is unbiased: \(\text{plim}\,\hat{\beta} = \beta\).

A.2 Formalization of D-Separation#

Definition (blocked path). Let \(\pi\) be a path between two nodes in a DAG, and let \(S\) be a set of nodes. The path \(\pi\) is blocked by \(S\) if there exists at least one node \(V\) on \(\pi\) such that:

(a) \(V\) is a chain or fork node on \(\pi\) (that is, \(\cdots \rightarrow V \rightarrow \cdots\) or \(\cdots \leftarrow V \rightarrow \cdots\)), and \(V \in S\); or

(b) \(V\) is a collider on \(\pi\) (that is, \(\cdots \rightarrow V \leftarrow \cdots\)), and \(V \notin S\) and no descendant of \(V\) belongs to \(S\).

Definition (d-separation). Two nodes \(X\) and \(Y\) are d-separated by \(S\) if all paths between \(X\) and \(Y\) are blocked by \(S\). Otherwise they are said to be d-connected given \(S\).

Theorem (Pearl 2009). In any DAG, \(X\) and \(Y\) are d-separated by \(S\) if and only if \(X \perp\!\!\!\perp Y \mid S\) in every probability distribution compatible with the DAG.

Corollary (back-door identification). Let \(S\) be a set satisfying the back-door criterion relative to \((T, Y)\). Then the effect of Pearl’s do-operator (intervention) is identifiable:

\[P(Y \mid do(T = t)) = \int P(Y \mid T = t,\, S = s)\, dP(s)\]

where \(do(T = t)\) denotes setting \(T\) to \(t\) by removing all arrows pointing into \(T\) in the DAG. In the linear case, this integral reduces to the coefficient of \(T\) in the regression of \(Y\) on \(T\) and \(S\).

References#

The interactive dashboards in this section draw on Pearl and Mackenzie [2018], Pearl [2009], Pearl et al. [2016], and Cinelli et al. [2022].

[CFP22]

Carlos Cinelli, Andrew Forney, and Judea Pearl. A crash course in good and bad controls. Sociological Methods & Research, 2022.

[Pea09]

Judea Pearl. Causality: Models, Reasoning, and Inference. Cambridge University Press, 2nd edition, 2009.

[PGJ16]

Judea Pearl, Madelyn Glymour, and Nicholas P Jewell. Causal Inference in Statistics: A Primer. Wiley, 2016.

[PM18]

Judea Pearl and Dana Mackenzie. The book of why: the new science of cause and effect. Basic books, 2018.