Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 23: Independence and d-Separation

Open in Colab

Correlation does not imply causation, but it does waggle its eyebrows suggestively.

Randall Munroe, xkcd

23.1 Why Independence Matters

Chapter 22 introduced Bayesian networks: a directed acyclic graph whose nodes are variables, with one conditional probability table (CPT) per node, P(X∣parents(X))P(X \mid \text{parents}(X)). The joint distribution is their product:

P(x1,…,xn)=∏iP(xi∣parents(xi))P(x_1, \dots, x_n) = \prod_i P(x_i \mid \text{parents}(x_i))

A full joint table over nn binary variables needs 2n−12^n - 1 numbers; the network needs only one number per row of each CPT. The saving comes entirely from what the graph says is independent of what. This chapter makes that precise: which independences can be read from the graph, how to read them, and what they do and do not tell us.

Our example is the classic Asia network (Lauritzen and Spiegelhalter, 1988), a small model of chest-clinic diagnosis:

joint table: 255 free numbers; the network: 18. Total probability 1.000000
P(lung cancer) = 0.0550;  P(lung cancer | smoker, positive X-ray) = 0.6460

The full joint table would need 255 numbers; the network needs 18. And it answers any question: a patient’s prior chance of lung cancer is 5.5%; for a smoker with a positive X-ray, 64.6%.

23.2 Three Connections

Every path in a network is built from three kinds of connection between consecutive variables. Each says something different about how evidence flows.

ConnectionShapeWithout evidence on the middleWith evidence on the middle
ChainS→L→ES \to L \to Edependent: smoking changes the chance of EEindependent: once LL is known, SS adds nothing about EE
Fork (common cause)L←S→BL \leftarrow S \to Bdependent: both share a causeindependent: given SS, LL and BB are unrelated
Collider (common effect)T→E←LT \to E \leftarrow Lindependent: tuberculosis and cancer are unrelateddependent: knowing EE, one cause explains away the other

The collider is the surprising one: observing a common effect, or any of its descendants, creates a dependence between causes that were independent. Let us check all three numerically, with a helper that tests whether P(X∣Y,Z)=P(X∣Z)P(X \mid Y, Z) = P(X \mid Z) for every value of YY and ZZ:

chain                  S and E given {}: dependent
chain                  S and E given {L}: independent
fork                   L and B given {}: dependent
fork                   L and B given {S}: independent
collider               T and L given {}: independent
collider               T and L given {E}: dependent
collider, descendant   T and L given {X}: dependent

Explaining away, in numbers. A positive X-ray raises the probability of tuberculosis. Learning, in addition, that the patient has lung cancer explains the X-ray, and brings tuberculosis back down:

P(tuberculosis | nothing known                  ) = 0.0104
P(tuberculosis | positive X-ray                 ) = 0.0924
P(tuberculosis | positive X-ray and lung cancer ) = 0.0104

A positive X-ray raises the probability of tuberculosis from 1.04% to 9.24%. Learning that the patient also has lung cancer brings it back to 1.04%, exactly where it started: E is “T or L”, and lung cancer alone accounts for everything the X-ray said about E.

23.3 d-Separation

Two variables can influence each other only along a trail: a path in the graph, ignoring arrow directions. A trail is active given evidence ZZ if every consecutive triple on it passes:

  • a chain or fork passes when its middle node is not in ZZ;

  • a collider passes when its middle node, or one of its descendants, is in ZZ.

XX and YY are d-separated by ZZ (“d” for directed) if no trail between them is active. The central theorem (Geiger, Verma and Pearl, 1990): if XX and YY are d-separated by ZZ in the graph, then X⊥Y∣ZX \perp Y \mid Z in every distribution that factorises over it, whatever its tables; and if they are not d-separated, some such distribution makes them dependent.

Checking every trail is exponential. The reachability algorithm (Koller and Friedman, Algorithm 3.1; also known as “Bayes ball”) walks the graph once, remembering whether each node was entered from a child (going up) or from a parent (going down):

reachable from A, no evidence:       ['D', 'E', 'T', 'X']
reachable from A, given E:           ['B', 'D', 'L', 'S', 'T']
reachable from A, given E and S:     ['L', 'T']

Without evidence, A reaches only its descendants (T, E, X, D): the collider at E blocks the way to L, S and B. Observing E opens the collider, and A now reaches L, S and B (and D through B), but no longer X, whose only link to A runs through the observed E. Adding S to the evidence blocks the fork at S: only T and L remain.

Checking the theorem. For every pair of variables and every evidence set of up to two other variables, we compare three verdicts: our algorithm, networkx (which implements d-separation independently), and the numbers of the joint table.

616 queries; d-separated in 156. Agreement with networkx: 616/616; with the numbers: 613/616
  graph says connected but the numbers say independent : ('E', 'X', ('T', 'L'))
  graph says connected but the numbers say independent : ('E', 'D', ('T', 'L'))
  graph says connected but the numbers say independent : ('X', 'D', ('T', 'L'))

Our algorithm agrees with networkx on all 616 queries, and with the numbers on 613. The three exceptions all ask about E, X or D given T and L: the graph says they may depend on each other, but E is deterministic (“T or L”), so knowing T and L fixes E, and the numbers find independences the graph does not show. d-separation guarantees every independence it finds; a particular distribution can have more. Such a distribution is called unfaithful to its graph, and deterministic nodes are the classic cause.

23.4 The Markov Blanket

Which variables does a node need to know about, to be independent of everything else? Its Markov blanket: its parents, its children, and its children’s other parents (the co-parents, because of the collider rule). Given its blanket, a node is independent of all other nodes.

Markov blanket of L: ['E', 'S', 'T'];  independent of ['A', 'B', 'X', 'D'] given it: True
Markov blanket of E: ['B', 'D', 'L', 'T', 'X'];  independent of ['A', 'S'] given it: True
Markov blanket of S: ['B', 'L'];  independent of ['A', 'T', 'E', 'X', 'D'] given it: True

The Markov blanket is what makes Gibbs sampling (Chapter 24) cheap: to resample one variable, only its blanket matters. It is also the natural set of features if you want to predict one variable from the others.

23.5 Markov Equivalence

Different graphs can encode exactly the same independences. The chain X→Y→ZX \to Y \to Z, the reverse chain X←Y←ZX \leftarrow Y \leftarrow Z and the fork X←Y→ZX \leftarrow Y \to Z all say one thing: X⊥Z∣YX \perp Z \mid Y. Only the collider X→Y←ZX \to Y \leftarrow Z says something different (X⊥ZX \perp Z, but not given YY).

Theorem (Verma and Pearl, 1990): two networks are Markov equivalent (encode the same independences) if and only if they have the same skeleton (the undirected edges) and the same v-structures (colliders X→Y←ZX \to Y \leftarrow Z whose parents are not linked).

chain X→Y→Z        equivalent to the chain X→Y→Z: True;  v-structures []
chain X←Y←Z        equivalent to the chain X→Y→Z: True;  v-structures []
fork X←Y→Z         equivalent to the chain X→Y→Z: True;  v-structures []
collider X→Y←Z     equivalent to the chain X→Y→Z: False;  v-structures [('X', 'Y', 'Z')]

How many networks are equivalent to the Asia network? We try every way of reversing a subset of its edges and keep the acyclic graphs equivalent to it:

6 networks (counting itself) encode exactly the same independences as Asia
edges whose direction data alone cannot decide: [('A', 'T'), ('S', 'B'), ('S', 'L')]

Six networks, including Asia itself, imply exactly the same independences. Some combinations of the directions of A → T, S → L and S → B can be reversed; but the arrows into the colliders E and D, and E → X, are the same in all six (reversing E → X would create a new v-structure at E).

This has a practical consequence for causal claims. Data observed passively can at best identify the equivalence class, not the arrows inside it: whether smoking causes lung cancer or lung cancer “causes” smoking is the same pattern of independences. Telling them apart needs interventions (experiments, Chapter 10’s A/B tests at scale), background knowledge (a cause comes before its effect), or the extra assumptions of causal inference (Pearl’s do-calculus).

23.6 Intervening Is Not Observing

Observing that a patient smokes and making a patient smoke are different operations. Pearl writes the second as P(⋅∣do(S=1))P(\cdot \mid do(S = 1)): cut every arrow into SS, set it, and compute in the cut (“mutilated”) graph. Here SS has no parents, so the two coincide for the effects of smoking; they differ when we intervene on a variable with causes. Observing a positive X-ray raises the probability of lung cancer; forcing the X-ray to be positive (a faulty machine) does not:

P(lung cancer)                = 0.0550
P(lung cancer | X-ray = 1)    = 0.4887   (observing)
P(lung cancer | do(X-ray = 1)) = 0.0550   (intervening)

Observing a positive X-ray raises the probability of lung cancer from 5.5% to 48.9%: the X-ray is evidence about its cause. Forcing the X-ray leaves it at 5.5%: acting on an effect tells us nothing about its causes.

23.7 Summary

  • A Bayesian network’s compactness comes from the conditional independences its graph encodes.

  • Chains and forks pass influence unless their middle node is observed; colliders block it unless the middle node or a descendant is observed (explaining away).

  • d-separation reads every implied independence from the graph; the reachability algorithm decides it in one pass, and it agrees with the numbers.

  • Given its Markov blanket (parents, children, children’s other parents) a node is independent of everything else.

  • Networks with the same skeleton and v-structures are Markov equivalent: passive data cannot tell them apart. Causal direction needs interventions or assumptions; do(X)do(X) differs from observing XX.

Exercises

  1. In the Asia network, list all trails between A and D. Which are active given {E}? Given {B}? Given nothing?

  2. Is S d-separated from X given {L}? Given {E}? Given {L, T}? Explain each answer with the three connections.

  3. Give the Markov blanket of T and of B. Verify one of them with the independent function.

  4. Draw all Markov-equivalent versions of X→Y→Z←WX \to Y \to Z \leftarrow W. Which edges can be reversed?

  5. A hospital admits patients who have disease A or disease B. In the hospital’s data, A and B are negatively correlated. Explain with a collider. (This is Berkson’s paradox.)

  6. Why is P(L∣do(X=1))=P(L)P(L \mid do(X = 1)) = P(L) in the Asia network? Would P(D∣do(E=1))P(D \mid do(E = 1)) equal P(D∣E=1)P(D \mid E = 1)? Why?

  7. Prove that in a chain X→Y→ZX \to Y \to Z, P(z∣x,y)=P(z∣y)P(z \mid x, y) = P(z \mid y), using only the factorisation.

Further Reading

  • D. Koller, N. Friedman, Probabilistic Graphical Models: Principles and Techniques, MIT Press, 2009, Chapter 3.

  • J. Pearl, Causality, 2nd ed., Cambridge University Press, 2009.

  • J. Pearl, D. Mackenzie, The Book of Why, Basic Books, 2018.

  • S. Lauritzen, D. Spiegelhalter, “Local computations with probabilities on graphical structures and their application to expert systems”, JRSS B, 1988.

  • R. Shachter, “Bayes-ball: the rational pastime”, UAI, 1998.