Foundations to Frontier
Tests
A. Mathematical Foundations › A5 Statistics › Causal inference

Causal Graphs (DAGs) and d-Separation

A directed acyclic graph draws your causal assumptions: an arrow means 'directly causes'. From the picture alone you can read off which variables must be independent, and given what, using d-separation: chains and forks are blocked by conditioning on the middle node, and colliders are opened by it. You will learn the Markov factorization, the three elementary junctions, the d-separation rule, test it against simulated data, and use it to spot bad adjustment sets.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Drawing what causes what

Draw a dot for each quantity and an arrow from a cause to its effect. Rough terrain slows the rover and makes its wheels slip. Wheel slip ruins the odometry. That picture is a causal graph. It has no loops, because nothing can cause itself.

The picture is powerful. Just by looking at arrows, you can tell which things should be unrelated, and when learning one thing tells you about another.

Which paths carry association? A d-separation explorer
X Y Click other nodes to condition on them (shaded).
TerrainCmdSpeedSlipOdomErrBlur
Paths between Terrain and Cmd given Z = {}: all blocked → d-separated (independent)
  • Terrain → Speed ← Cmd: blocked at Speed (collider, not conditioned)
  • Terrain → Slip ← Speed ← Cmd: blocked at Slip (collider, not conditioned)
Rules: a chain (→ M →) or fork (← M →) is blocked if you condition on M. A collider (→ M ←) is blocked unless you condition on M or one of its descendants. Try Terrain and Cmd: independent, but conditioning on Speed (or on its descendant Blur) makes them dependent.
Why engineers care

Fault-diagnosis systems on spacecraft, Bayesian networks for robot perception, and causal analyses of fleet data all start with a graph of what affects what. The graph tells you which sensors carry independent evidence and which variables you must (or must not) control for.

📝 Quick check (Level 0)
0/3 answered
  1. 1. An arrow A → B in a causal graph means…
  2. 2. A DAG cannot contain…
  3. 3. Graphs let you predict which variables are…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Three junctions

Junction Shape A,CA, C marginally Given BB
Chain A→B→CA\to B\to C dependent independent
Fork A←B→CA\leftarrow B\to C dependent independent
Collider A→B←CA\to B\leftarrow C independent dependent

The collider is the surprise. Terrain and motor command both affect speed. They’re independent, but if you know the rover is slow, learning that the terrain was smooth makes a low command more likely. This is explaining away.

Markov factorization

A DAG says the joint distribution factorizes as

p(x1,…,xn)=∏ip(xi∣pa⁡(xi))p(x_1, \dots, x_n) = \prod_ip(x_i\mid\operatorname{pa}(x_i))

Each variable depends directly only on its parents. Equivalently, each variable is independent of its non-descendants given its parents (the local Markov property).

📝 Quick check (Level 1)
0/3 answered
  1. 1. In A → B → C, conditioning on B makes A and C…
  2. 2. In A → B ← C, conditioning on B makes A and C…
  3. 3. The DAG factorization uses P(xᵢ | …)

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

d-separation (Pearl, 1988)

A path between XX and YY is blocked by a set ZZ if it contains either

  • a chain →M→\to M\to or fork ←M→\leftarrow M\to with M∈ZM\in Z, or
  • a collider →M←\to M\leftarrow with neither MM nor any descendant of MM in ZZ.

XX and YY are d-separated by ZZ if every path is blocked. Then X⊥Y∣ZX\perp Y\mid Z in every distribution that factorizes over the graph. If they’re not d-separated, they’re dependent in almost every such distribution (faithfulness).

An algorithm

Lauritzen’s moralization criterion:

  1. Keep only the ancestors of X∪Y∪ZX\cup Y\cup Z.
  2. “Marry” parents of common children and drop directions.
  3. Delete ZZ.

XX and YY are d-separated by ZZ exactly when they’re disconnected in what remains. It runs in linear time.

🐍 Exercise 1: a d-separation oracle
Implement ancestors and d-separation via the moralized ancestral graph. Check chains, forks, colliders, a collider's descendant, and the M-bias graph.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Conditioning on a descendant of a collider…
  2. 2. d-separation implies conditional independence in…
  3. 3. Faithfulness assumes…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Why colliders open when conditioned

Collider A→B←CA\to B\leftarrow C with A⊥CA\perp C. By the factorization, p(a,c∣b)∝p(a)p(c)p(b∣a,c)p(a, c\mid b) \propto p(a)p(c)p(b\mid a, c). This doesn’t factor into f(a)g(c)f(a)g(c) unless p(b∣a,c)p(b\mid a, c) does. So A⊥̸C∣BA\not\perp C\mid B in general. ∎ For a chain, p(a,c∣b)∝p(a)p(b∣a)p(c∣b)=f(a)g(c)p(a, c\mid b) \propto p(a)p(b\mid a)p(c\mid b) = f(a)g(c), which gives independence. ∎

M-bias: a “pre-treatment” variable you shouldn’t adjust for

X←U1→M←U2→YX\leftarrow U_1\to M\leftarrow U_2\to Y, with U1,U2U_1, U_2 unobserved. MM occurs before treatment and is associated with both XX and YY, so it looks like a confounder. But the only path through it is closed at the collider MM. Adjusting for MM opens it and creates bias (Greenland, Pearl and Robins, 1999).

Markov equivalence

DAGs with the same skeleton and the same v-structures (colliders A→B←CA\to B\leftarrow C with A,CA, C non-adjacent) imply the same independences (Verma and Pearl, 1990). A→B→CA\to B\to C, A←B←CA\leftarrow B\leftarrow C and A←B→CA\leftarrow B\to C are indistinguishable from observational data. This limits causal discovery (A5.3-7).

Exercise 3.1: How many DAGs are Markov equivalent to A → B → C?

Three: the two chains and the fork. The collider A→B←CA\to B\leftarrow C has a v-structure, so it’s different.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Markov-equivalent DAGs share…
  2. 2. In M-bias, adjusting for M…
  3. 3. A chain A → B → C and fork A ← B → C are…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Testing a rover causal model against data

Write down the graph (Terrain → Speed ← Cmd, Terrain → Slip ← Speed, Slip → OdomErr). The graph predicts which partial correlations vanish. Simulating a linear-Gaussian structural model and checking every pair with conditioning sets of size 0 and 1, d-separation predicts every independence. On real logs, failed predictions falsify the graph. That is a practical model check (Textor et al., 2016, the dagitty tool).

🐍 Exercise 2 (research): d-separation vs data
Simulate a linear-Gaussian SEM over a 5-node rover graph. Compute partial correlations and check that they vanish exactly when d-separation says so.

DAGs in AI, robotics and aerospace

  • Bayesian networks for diagnosis and perception (Pearl, 1988; Koller and Friedman, 2009). NASA’s spacecraft diagnosis systems use model-based reasoning over component dependency graphs (Williams and Nayak, 1996, Livingstone).
  • Factor graphs in SLAM and state estimation: GTSAM-style smoothing encodes exactly a conditional-independence structure (Dellaert and Kaess, 2017).
  • Causal representation learning: learning variables and graphs from pixels (Schölkopf et al., 2021).
  • Fairness and robustness audits: path-specific effects through a DAG (Kusner et al., 2017).

References

  1. J. Pearl (1988). Probabilistic Reasoning in Intelligent Systems. Morgan Kaufmann.
  2. J. Pearl (2009). Causality, 2nd ed. Cambridge University Press.
  3. S. Lauritzen, A. P. Dawid, B. Larsen, H.-G. Leimer (1990). “Independence properties of directed Markov fields.” Networks, 20(5).
  4. T. Verma, J. Pearl (1990). “Equivalence and synthesis of causal models.” UAI.
  5. S. Greenland, J. Pearl, J. Robins (1999). “Causal diagrams for epidemiologic research.” Epidemiology, 10(1).
  6. D. Koller, N. Friedman (2009). Probabilistic Graphical Models. MIT Press.
  7. J. Textor et al. (2016). “Robust causal inference using directed acyclic graphs: the R package ‘dagitty’.” International Journal of Epidemiology, 45(6).
  8. B. Williams, P. Nayak (1996). “A model-based approach to reactive self-configuring systems.” AAAI.
  9. F. Dellaert, M. Kaess (2017). “Factor graphs for robot perception.” Foundations and Trends in Robotics, 6(1–2).
  10. B. Schölkopf et al. (2021). “Toward causal representation learning.” Proceedings of the IEEE, 109(5).