# Do-Calculus for Causal Diagram 7.5 from "The Book of Why" (napkin problem)

In "The Book of Why" the below causal diagram is described as the "simplest model" where estimation of the causal effect goes beyond front and back-door adjustment and thus requires do-calculus. Here, $$W$$, $$X$$, $$Y$$, $$Z$$ are all observed, and $$U_1$$ and $$U_2$$ are Unobserved.

I have played around a bit with the rules, about which I am still shaky, but haven't come up with a solution for $$P(Y|do(X))$$ that can be estimated from the diagram. Could someone better than me help come up with a solution?

• No idea myself, but I will say this: once you've read The Book of Why and Causal Inference in Statistics: A Primer, you might be ready (though I'm finding it EXTREMELY challenging) to tackle the "big daddy" book: Causality: Models, Reasoning, and Inference. That last book has by far the most complete discussion of the do calculus, and I would imagine that if you could master its discussion, you could probably derive the correct expression for $P(Y|\operatorname{do}(X)).$ Mar 19, 2021 at 14:15

Derivation (graphs licensing each step are provided below).

\begin{align} P(y|do(x)) &= P(y|do(x), do(z)) \qquad &\text{Rule 3: (Y \perp\!\!\!\perp Z|X)_{G_\overline{XZ}}}\\ &= P(y |x, do(z)) \qquad &\text{Rule 2: (Y\perp\!\!\!\perp X)_{G_{\overline{Z}\underline{X}}}}\\ &= \frac{P(y, x|do(z))}{P(x|do(z))} \qquad &\text{Def. of conditional probability}\\ &= \frac{\sum_{w}P(y, x|z, w)P(w)}{\sum_{w}P(x|z,w)P(w)}\qquad &\text{Backdoor using with W: (\{Y, X\}\perp\!\!\!\perp Z|W)_{G_{\underline{Z}}}} \end{align}

What does each step mean of the derivation means in plain English?

• Step 1 simply states that, when $$X$$ is held fixed (by intervention), manipulating $$Z$$ has no effect on $$Y$$;
• Step 2 states that, when $$Z$$ is held fixed (by intervention), there is no confounding between $$X$$ and $$Y$$;
• Step 3 is just applying the definition of conditional probability; and, finally,
• Step 4 notes that adjusting for $$W$$ is sufficient to identify the causal effect of $$Z$$ on $$X$$ and $$Y$$. This is because $$W$$ blocks all confounding paths from $$Z$$ to $$X$$ and $$Y$$ (backdoor paths). So we can use vanilla backdoor adjustment here.

Modified Graphs • This is excellent, thank you! Mar 20, 2021 at 17:04
• I'm looking at this example again, and I'm just not sure why conditioning only on $Z$ doesn't work. Conditioning only on $Z$ blocks the backdoor path $X\leftarrow Z\leftarrow W\leftarrow U_1\rightarrow Y,$ and the backdoor path $X\leftarrow U_2\to W\leftarrow U_1\to Y$ is already blocked because of the unconditioned collider at $W.$ Am I missing something? Jul 21, 2022 at 19:41
• @AdrianKeister conditioning on $Z$ partially opens the collider path. Jul 22, 2022 at 9:25
• Oh yeah, forgot about that "and descendants of colliders" bit. Thanks! Jul 22, 2022 at 14:34

In the following github repo, we provide Python software that assigns random probabilities to the nodes of the Napkin Bayesian Network. The software then does the marginalizations necessary to calculate P(y|x) and the right hand side of the Adjustment Formula given by Cinelli above. We find that they are always equal, no matter what the random probabilities are. Hence, Cinelli's Adjustment Formula reduces to P(y|do(x))=P(y|x)

https://github.com/rrtucci/napkin-do-calc