What does Simpson's Paradox and Back-Door Adjustment conclude, in numbers, about “One Table, Three Causal Graphs: Confounder, Mediator and Collider”?
Answer: Chapter 4 pairs one table with confounder, mediator and collider graphs, whose correct answers are +0.0500 and -0.2493.
Scope of the numbers: Branches, plans and conversions are illustrative; all calculations are generated by the book's programs. This is general analysis, not individualised business advice.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: -0.2493, 0.0500
| each graph reproduces the joint exactly: True | ||
| graph | formula | A-B |
| confounder | sum_z P(y|x,z)P(z) | +0.0500 |
| mediator | P(y|x) | -0.2493 |
| collider | P(y|x) | -0.2493 |
| stratified by z, collider graph | +0.0500 | (biased) |
| cells in the joint: 12 | total mass 1 |
Show the full program
# Chapter 4. p41: one joint table, three causal graphs, two answers.
# The p12 counts define P(x, z, y). Each graph below is a complete DAG
# on {X, Z, Y}, so each factorises this joint exactly (checked):
# confounder Z -> X, Z -> Y, X -> Y : P(y|do x) = sum_z P(y|x,z)P(z)
# mediator X -> Z, Z -> Y, X -> Y : P(y|do x) = P(y|x)
# collider X -> Z, Y -> Z, X -> Y : P(y|do x) = P(y|x)
# The data cannot choose among them; the graph chooses the formula.
from fractions import Fraction as F
DATA = [("flagship", 40, 50, 270, 360),
("community", 90, 200, 60, 150),
("outlet", 60, 300, 9, 60)]
def joint():
n = 0
for r in DATA:
n = n + r[2] + r[4]
p = {}
for z, r in enumerate(DATA):
for x, (yc, nc) in enumerate(((1, 2), (3, 4))):
p[(x, z, 1)] = F(r[yc], n)
p[(x, z, 0)] = F(r[nc] - r[yc], n)
return p
def marg(p, keep):
out = {}
for k in sorted(p):
kk = tuple(k[i] for i in keep)
out[kk] = out.get(kk, F(0)) + p[k]
return out
def main():
p = joint()
pz, px = marg(p, (1,)), marg(p, (0,))
pxz, pxy = marg(p, (0, 1)), marg(p, (0, 2))
ok = {"confounder": True, "mediator": True, "collider": True}
for (x, z, y), v in sorted(p.items()):
c = pz[(z,)] * pxz[(x, z)] / pz[(z,)] * v / pxz[(x, z)]
m = px[(x,)] * pxz[(x, z)] / px[(x,)] * v / pxz[(x, z)]
k = px[(x,)] * pxy[(x, y)] / px[(x,)] * v / pxy[(x, y)]
ok["confounder"] = ok["confounder"] and c == v
ok["mediator"] = ok["mediator"] and m == v
ok["collider"] = ok["collider"] and k == v
print("each graph reproduces the joint exactly: {}".format(
all(ok.values())))
do = []
for x in (0, 1):
s = F(0)
for z in range(len(DATA)):
s = s + p[(x, z, 1)] / pxz[(x, z)] * pz[(z,)]
do.append(s)
obs = [pxy[(x, 1)] / px[(x,)] for x in (0, 1)]
print("graph formula A-B")
print("confounder sum_z P(y|x,z)P(z) {:+.4f}".format(
float(do[0] - do[1])))
print("mediator P(y|x) {:+.4f}".format(
float(obs[0] - obs[1])))
print("collider P(y|x) {:+.4f}".format(
float(obs[0] - obs[1])))
print("stratified by z, collider graph {:+.4f} (biased)".format(
float(do[0] - do[1])))
print("cells in the joint: {} total mass {}".format(
len(p), sum_exact(p)))
def sum_exact(p):
t = F(0)
for k in sorted(p):
t = t + p[k]
return t
if __name__ == "__main__":
main()Single source and citation
Fan, Y. (2026). Simpson's Paradox and the Back-Door Criterion: Reversals When Branch Data Are Pooled and De-Confounding with Causal Graphs (Version 1.0.0), Chapter 4: One Table, Three Causal Graphs: Confounder, Mediator and Collider. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-302 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026302,
author = {Fan, Yafu},
title = {Simpson's Paradox and the Back-Door Criterion: Reversals When Branch Data Are Pooled and De-Confounding with Causal Graphs},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Every Branch Wins, the Total Loses: the Reversal Condition for 2 x 2 x k Tables
- Chapter 2 · How Common Are Reversals? The Smallest Example, Random Tables and Sampling Noise
- Chapter 3 · The Back-Door Adjustment Formula: Standardisation, Inverse Probability Weighting and a Structural Model with a Known Answer
- Chapter 5 · Enumerating Back-Door Sets: d-Separation, M-Bias and Counting Causal Graphs
- Chapter 6 · Sampling Error in Stratified Estimates: Intervals, Power and Sparse Strata
- Chapter 7 · Classics East and West: the Lüshi Chunqiu on Examining Hearsay, and Yule 1903
- Chapter 8 · Forced Stratification and Adjustment of Multi-Branch Reports: the Closed Loop, the Tool and a Pre-Registered Test