Tutorial · Causal inference

Drawing and Reading Causal DAGs

A practical guide to confounders, mediators, colliders, d-separation, and choosing adjustment sets without accidentally opening the wrong path.

A DAG is a picture of causal assumptions

DAG stands for Directed Acyclic Graph. Variables are shown as nodes and arrows encode assumed causal directions.

DirectedArrows have a direction: X → Y.
AcyclicYou cannot follow arrows and come back to where you started.
AssumptionsA DAG is not automatically learned from the data. It represents a causal story you are willing to defend.

One arrow means one causal claim

If you draw X → Y, you are asserting that changing X could causally change Y, directly or as part of the represented system.

Confounder, mediator, collider

Confounder

C → X
C → Y

C causes both exposure X and outcome Y. This creates a back-door path between X and Y.

Mediator

X → M → Y

M lies on the causal pathway from X to Y. Adjusting for M changes the estimand from total effect toward a direct effect.

Collider

X → C ← Y

C is caused by both X and Y. Conditioning on a collider can create an association that was not there before.

Practical rule: confounders are often variables you may need to adjust for; colliders are variables you generally do not want to condition on when estimating a total causal effect.

Not every path transmits association

Chain
X → M → Y

Open unless you condition on M.

Fork
X ← C → Y

Open unless you condition on C.

Collider
X → C ← Y

Closed by default. Conditioning on C can open it.

The graphical rule for blocking paths

Two variables are d-separated by a set Z when every path between them is blocked according to the DAG rules. In causal inference, we use this idea to decide whether a proposed adjustment set blocks noncausal paths without opening new ones.

A path is blocked when...

You condition on a non-collider along a chain or fork.

A collider path can become open when...

You condition on the collider itself or, in general, on one of its descendants.

d-separation is a graphical property. It is not the same thing as running a statistical independence test on your sample.

What should you adjust for?

The aim is to block noncausal back-door paths between exposure and outcome while leaving the causal pathway of interest intact.

Variable role
Adjust for total effect?
Why?
Confounder
Usually yes
Blocks a back-door path.
Mediator
Usually no
Blocks part of the causal effect you may want to estimate.
Collider
No
Can open a spurious path and induce bias.
Adjustment does not mean “put every available covariate into a regression.” The DAG determines which variables are appropriate for the causal estimand.

The front-door idea

If important confounding between X and Y is unmeasured, a valid back-door adjustment set may not exist.

Under stronger structural assumptions, a measured mediator M can sometimes identify the causal effect through a front-door strategy.

Canonical pattern

X → M → Y

The front-door criterion requires more than merely observing a mediator: the relevant paths involving X, M, and Y must satisfy the required graphical conditions.

Represent a DAG with dagitty

library(dagitty) g <- dagitty(" dag { C -> X C -> Y X -> Y } ") adjustmentSets(g, exposure = "X", outcome = "Y")

In this simple DAG, C is a confounder. A valid adjustment set contains C because it blocks the back-door path X ← C → Y.

What students most often get wrong

Adjusting for every measured covariateMore adjustment is not automatically better. Some variables create bias when conditioned on.
Adjusting for a colliderThis can open a previously blocked path and create an artificial association.
Treating a DAG as a statistical correlation graphArrows encode causal assumptions, not merely observed associations.
Thinking a DAG proves causalityA DAG helps formalize assumptions and identify consequences. The validity of the analysis still depends on whether those assumptions are defensible.

What to remember

Confounder

Common cause. Usually block it.

Mediator

On the causal pathway. Adjust only if your estimand calls for it.

Collider

Common effect. Usually leave it alone.