Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 37 ยท Graphs and Identification

Causal DAGs: Drawing Your Assumptions

Learn causal directed acyclic graphs: nodes, arrows, paths, chains, forks and colliders, d-separation rules and how a graph encodes what you assume, with Python code to enumerate paths.

A causal directed acyclic graph (DAG) is a drawing of your assumptions about what causes what. Each variable is a node, each direct causal influence is an arrow, and no variable can cause itself through a loop (acyclic). The graph does not give you effects by itself; it tells you which variables to adjust for, which not to, and what your claims depend on.

Building a DAG

Draw an arrow A -> B if A is a direct cause of B (with respect to the other variables in the graph). Missing arrows are strong assumptions ("A has no direct effect on B"), as important as the arrows you draw.

flowchart LR
  Age --> Treatment
  Age --> Recovery
  Treatment --> Recovery
  Wealth --> Treatment
  Wealth --> Health["Health"]
  Health --> Recovery

A small medical DAG: age and wealth influence who is treated; treatment affects recovery.

Tips: include every common cause of two variables in the graph, even if unmeasured (draw it as a node you cannot adjust for); order nodes by time; start simple and add what you believe matters.

Paths and the three building blocks

A path is a sequence of connected nodes, ignoring arrow direction. Association flows along a path depending on three local structures:

Structure Shape Association flows?
Chain (mediator) A -> M -> B Yes, until you condition on M
Fork (common cause) A <- C -> B Yes, until you condition on C
Collider A -> K <- B No, until you condition on K (or its descendant)

Three building blocks

Chain A โ†’ M โ†’ B
Fork A โ† C โ†’ B
Collider A โ†’ K โ† B

Conditioning blocks chains and forks but opens colliders.

1 / 2

d-separation

A path is blocked by a set of variables Z if it contains

  • a chain or fork whose middle node is in Z, or
  • a collider such that neither the collider nor any of its descendants is in Z.

If every path between A and B is blocked by Z, then A and B are d-separated by Z, and (under the graph's assumptions) A and B are statistically independent given Z. This is how graphs predict which correlations you should see.

Testing the building blocks by simulation

Python Chain, fork and collider in data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For the chain and fork, the association disappears after conditioning on the middle variable. For the collider, it is zero at first and appears after conditioning, as in collider bias.

Listing paths in code

A DAG is easy to store as a list of edges. This small helper lists all paths between two nodes and shows which are backdoor paths (those that start with an arrow into the treatment).

Python Enumerating paths in a DAG

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The direct path is causal; the paths through Age and through Wealth and Health are backdoor paths that carry confounding. The backdoor criterion says which variables block them.

What a DAG is and is not

  • It encodes qualitative assumptions; it says nothing about functional form or effect size.
  • It cannot be proven from data alone, though data can contradict it (a predicted independence that fails).
  • Different graphs can imply the same data patterns; domain knowledge chooses between them.
  • It is not a computational shortcut: a wrong graph gives a wrong answer with great confidence.

Show the graph to a domain expert. Disagreements about an arrow are exactly the places where your analysis could go wrong, and finding them early is the whole point.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a missing arrow between A and B mean in a DAG?

    Absent arrows are strong causal assumptions.
  2. 2. Conditioning on which node blocks a fork A <- C -> B?

    Conditioning on the common cause blocks the path.
  3. 3. Which structure becomes OPEN when you condition on its middle node?

    Colliders are blocked by default and opened by conditioning.
  4. 4. Can data alone prove that a DAG is correct?

    Many graphs imply the same patterns; assumptions come from subject knowledge.

Summary

  • A DAG is a map of assumptions: nodes are variables, arrows are direct causes.
  • Chains and forks pass association until conditioned on; colliders block until conditioned on.
  • d-separation tells you which independences a graph predicts.
  • A DAG encodes qualitative assumptions and must come from subject knowledge.

Next: The Backdoor Criterion