Day 60. Phase 4 Capstone: DAGs Meet Potential Outcomes (SWIGs)
Single-world intervention graphs split each treated node into the value it would have taken and the value we set, so potential outcomes appear in the graph. d-separation in the split graph reads off Phase 3's ignorability assumptions directly, unifying the two languages of causal inference.
- ●Construct the single-world intervention graph (SWIG) for one or several interventions.
- ●Read conditional ignorability, and its failure, from d-separation in a SWIG.
- ●Derive the adjustment formula and the g-formula from SWIG independences plus consistency.
- ●Carry a policy question through the whole Phase 4 toolkit (DAG, identification, adjustment set, bad controls, selection and mediation).
Theory
Two languages, one model
Phase 3 wrote assumptions with potential outcomes (). Phase 4 wrote them with graphs (back-door paths). Single-world intervention graphs (Richardson and Robins, 2013) put the potential outcomes into the graph, so ignorability can be checked by d-separation.
Node splitting
To intervene on and set it to :
- Split into two halves: the random half (the value it would naturally take), which keeps all incoming arrows, and the fixed half , which keeps all outgoing arrows.
- Relabel every descendant of as the potential outcome .
Example: , becomes
There is no edge between and : the natural treatment and the potential outcome are linked only through .
Reading ignorability
Apply d-separation in the SWIG (fixed nodes are constants and can be treated as conditioned on):
With consistency () and positivity, this gives the adjustment formula
The back-door criterion holds for exactly when d-separates from in the SWIG.
Several interventions
For sequential treatments , split both: the SWIG contains , and . Sequential ignorability, and , can be read off, and it yields the g-formula of Day 55.
Single world, by design
A SWIG represents one intervention at a time. It cannot express cross-world statements like , which natural mediation effects require (Day 58). That is a feature: assumptions that no experiment could ever check stay visibly separate.
Phase 4 in one table
| Question | Tool (Day) |
|---|---|
| What does my causal story imply? | DAG, factorisation, d-separation (46–49) |
| What happens if we intervene? | SCM and the do-operator (50–51) |
| Which covariates should I adjust for? | back-door criterion, good and bad controls (52–53) |
| Confounder unobserved? | front door, do-calculus, ID algorithm (54–56) |
| Who is in my sample? | selection nodes and recoverability (57) |
| Through which channel? | mediation (58) |
| What would have happened to this unit? | counterfactuals (59) |
| Does my ignorability assumption hold in my graph? | SWIGs (60) |
Part 1 · Warm-up
Exercise 1 · Draw a SWIG
Draw the SWIG for intervening on in , , .
Show solution
Step 1. Split : random half keeps ; fixed half keeps and .
Step 2. Descendants of : and become and .
Answer: ; ; ; .
Exercise 2 · Read ignorability
In the SWIG of Exercise 1, is ? Is ?
Show solution
Step 1. Paths from to : only ( has no outgoing edges).
Step 2. Unconditioned, the fork at is open: not independent.
Step 3. Given , it is blocked: .
Exercise 3 · Unobserved confounding
In , ( unobserved), draw the SWIG and decide whether any observed variable makes ignorable.
Show solution
Step 1. SWIG: , , .
Step 2. The path is open unless is conditioned on.
Answer: no observed set works; . This is the bow, non-identified (Day 56).
Exercise 4 · Two interventions
Draw the SWIG for intervening on and in , , , .
Show solution
Step 1. Split into ; has no parents, points to and .
Step 2. Split : the random half is (a descendant of ), keeping ; the fixed half points to .
Step 3. becomes , with parents .
Answer: , , , , , and isolated.
Exercise 5 · What a SWIG cannot show
Why can't a SWIG display the assumption used for natural direct effects?
Show solution
Step 1. A SWIG contains variables from a single intervention: either (intervening on with ) or (intervening on and with ), not both.
Step 2. The assumption relates two different interventions on the same unit.
Answer: it is a cross-world assumption; no single-world graph contains both variables, and no experiment can test it.
Part 2 · Proofs
Exercise 6 · From ignorability to the adjustment formula
Assume , consistency and positivity. Prove .
Show solution
Step 1. LIE: .
Step 2. Ignorability: (positivity makes the conditioning event possible).
Step 3. Consistency: on , , so this is .
Step 4. Substitute.
Exercise 7 · Back-door implies SWIG separation
Suppose satisfies the back-door criterion for in . Argue that d-separates from in the SWIG.
Show solution
Step 1. In the SWIG, the random half has only incoming edges, so every path from to starts with an edge into : these are exactly the back-door paths of (with descendants of relabelled).
Step 2. Directed paths from in now start at the fixed node , not at , so they are not – paths.
Step 3. contains no descendant of , so in the SWIG it contains no potential outcome; conditioning on it opens or blocks the same nodes as in .
Step 4. blocks every back-door path in , hence every – path in the SWIG.
Exercise 8 · The g-formula from sequential ignorability
For the SWIG of Exercise 4 (with no – edge), assume , , , and consistency. Prove .
Show solution
Step 1. By the first assumption and consistency of : .
Step 2. Second assumption: condition additionally on (which equals when ): .
Step 3. Consistency: when and , .
Step 4. Substitute.
Exercise 9 · M-bias in a SWIG
In , , , , , show with the SWIG that but not .
Show solution
Step 1. SWIG: , , , , . is not a descendant of , so it is not relabelled.
Step 2. The only – path: , with a collider at .
Step 3. Unconditioned: blocked, so . Given : open.
Answer: treatment is marginally ignorable but not given : the potential-outcome version of M-bias.
Exercise 10 · Why the front door is not "ignorability"
In the front-door graph , , , show that no observed set makes , and explain how identification still succeeds.
Show solution
Step 1. SWIG: , , .
Step 2. The path is open, and the only observed candidate, , is not on it.
Step 3. So no conditioning set gives ignorability of .
Step 4. Identification works through two separate ignorabilities: (in this SWIG) and (in the SWIG for intervening on ), chained as in Day 54.
Part 3 · Applied
Exercise 11 · Microfinance and women's decision-making
An NGO asks whether microloans to women () increase their say in household decisions (). Available variables: baseline education , baseline household assets , village (loan officers choose villages based on market access, which also affects bargaining norms), business started after the loan , and survey participation (husbands sometimes refuse interviews when the wife's power rises). Lay out a Phase 4 analysis plan.
Show solution
Step 1. DAG: ; ; ; ; .
Step 2. Identification: blocks the back-door paths and contains no descendants: admissible (SWIG: ).
Step 3. Bad controls: business is a mediator; exclude for the total effect.
Step 4. Selection: depends on , so analysing respondents biases results; collect refusal data and use bounds or weights based on predictors of refusal (Day 57).
Step 5. Mechanism: the share via business start is a mediation question needing – unconfoundedness (Day 58).
Answer: adjust for ; don't adjust for ; address non-response explicitly; treat mediation as secondary with sensitivity checks.
Exercise 12 · Auditing a regression
A paper estimates the return to a vocational degree by regressing earnings on , age, parental income, current occupation and current job tenure. Using a DAG, list which controls are appropriate and which are not.
Show solution
Step 1. Age and parental income precede the degree and affect earnings: confounders; keep.
Step 2. Occupation and tenure are affected by the degree: mediators (and colliders if ability affects them): exclude for the total return.
Step 3. Missing: ability or school grades, which affect both and ; if unobserved, the estimate remains biased, and a sensitivity analysis is needed.
Answer: keep age and parental income; drop occupation and tenure; flag ability.
Exercise 13 · Sequential HIV treatment, by simulation
In the simulated clinic below, treatment at visit 1 (, randomised) raises CD4 counts ; doctors give treatment at visit 2 () mainly to patients with low CD4; unobserved health affects CD4 and viral suppression . The true effect of "always treat" versus "never treat" is 0.45. Compare the naive comparison, a regression on , and the g-formula.
Show solution
Step 1. Naive comparison (always-treated versus never-treated patients): biased, because depends on , which depends on . The code gives about 0.38.
Step 2. Regression on : is a mediator for and a collider (); the sum of coefficients is about 0.41.
Step 3. g-formula: at minus : about 0.45.
Answer: only the g-formula, justified by sequential ignorability in the SWIG, recovers the effect; Day 96 develops it and its weighting cousin.
Exercise 14 · One question, several designs
A health system asks for the effect of ICU admission on 30-day mortality . For each data situation, name the Phase 4 strategy or say "not identified": (a) severity scores used for admission are recorded; (b) severity is not recorded, but admission affects mortality only through hours of ventilation, which are not confounded with mortality given admission; (c) severity is not recorded and nothing else is known; (d) only patients who survived 24 hours are in the data.
Show solution
Step 1. (a) Back-door adjustment for severity (and other admission criteria) (Day 52).
Step 2. (b) Front door through ventilation hours (Day 54), if its strong assumptions are credible.
Step 3. (c) The bow: not identified (Day 56); bounds, sensitivity, or an instrument such as bed availability (Phase 5).
Step 4. (d) Selection on a variable affected by both admission and severity: a collider (Day 57); estimates for survivors are biased unless selection can be modelled.
Exercise 15 · Reading a SWIG for a vaccine study
Observational vaccine data: age vaccination , infection ; health-seeking behaviour (unobserved) and testing ; ; only tested people are analysed. Draw the SWIG for and decide whether , and what the testing restriction does.
Show solution
Step 1. SWIG: , , , , , (testing is a descendant of through ).
Step 2. Paths from to : (blocked by ) and (collider at , blocked if not conditioned).
Step 3. So in the full population.
Step 4. Restricting to tested people conditions on , opening .
Answer: age adjustment suffices in population data, but tested-only data are biased by health-seeking behaviour (the motivation for test-negative designs, which make further assumptions).
Verify in Python
import numpy as np
import networkx as nx
dsep = getattr(nx, "is_d_separator", None) or nx.d_separated # name changed in networkx 3.3
def swig(G, A):
"""Split node A into random half A and fixed half 'a'; relabel descendants of A as V(a)."""
desc = nx.descendants(G, A)
name = lambda v: f"{v}(a)" if v in desc else v
S = nx.DiGraph(); S.add_nodes_from([name(v) for v in G] + ["a"])
for u, v in G.edges:
S.add_edge("a" if u == A else name(u), name(v))
return S
G = nx.DiGraph([("L", "A"), ("L", "Y"), ("A", "Y"), ("A", "M"), ("M", "Y")])
S = swig(G, "A")
print("SWIG edges:", sorted(S.edges))
print("Y(a) _||_ A:", dsep(S, {"Y(a)"}, {"A"}, {"a"}), "| given L:", dsep(S, {"Y(a)"}, {"A"}, {"a", "L"}))
Mb = swig(nx.DiGraph([("U1", "A"), ("U1", "M"), ("U2", "M"), ("U2", "Y"), ("A", "Y")]), "A")
print("M-bias: Y(a) _||_ A:", dsep(Mb, {"Y(a)"}, {"A"}, {"a"}), "| given M:", dsep(Mb, {"Y(a)"}, {"A"}, {"a", "M"}))
V = swig(nx.DiGraph([("G", "A"), ("H", "A"), ("G", "Y"), ("A", "Y"), ("H", "T"), ("Y", "T")]), "A")
print("vaccine: Y(a) _||_ A | G:", dsep(V, {"Y(a)"}, {"A"}, {"a", "G"}), "| G, T(a):", dsep(V, {"Y(a)"}, {"A"}, {"a", "G", "T(a)"}))
# Exercise 13: sequential treatment and the g-formula
rng = np.random.default_rng(60); n = 2_000_000
def clinic(a1=None, a2=None):
U = rng.random(n) < .5
A1 = rng.random(n) < .5 if a1 is None else np.full(n, a1, bool)
L = rng.random(n) < .2 + .4 * A1 + .3 * U # high CD4
A2 = rng.random(n) < (.8 - .6 * L) if a2 is None else np.full(n, a2, bool)
Y = rng.random(n) < .1 + .2 * A1 + .25 * A2 + .3 * U # viral suppression
return A1, L, A2, Y
A1, L, A2, Y = clinic()
truth = clinic(1, 1)[3].mean() - clinic(0, 0)[3].mean()
g = lambda a1, a2: sum(Y[(A1 == a1) & (L == l) & (A2 == a2)].mean() * (L[A1 == a1] == l).mean() for l in (0, 1))
b = np.linalg.lstsq(np.column_stack([np.ones(n), A1, L, A2]).astype(float), Y.astype(float), rcond=None)[0]
print(f"truth {truth:.3f} naive {Y[A1 & A2].mean() - Y[~A1 & ~A2].mean():.3f} regression {b[1] + b[3]:.3f} g-formula {g(1, 1) - g(0, 0):.3f}")
Key takeaways
- A SWIG splits each intervened node into its natural and fixed halves and relabels descendants as potential outcomes.
- Ignorability is d-separation in the SWIG; with consistency and positivity it yields the adjustment formula and, for sequential treatments, the g-formula.
- SWIGs keep single-world assumptions testable in principle and cross-world assumptions visibly separate. Phase 5 now turns to designs (instruments, differences-in-differences, discontinuities) for when no admissible set is observed.
Simulation Lab: Single-World Intervention Graphs
Open full screen →Split the treatment node, relabel potential outcomes, and read ignorability straight off the graph.
The SWIG splits the treatment into its natural value A (keeps incoming arrows) and the value we set, a (keeps outgoing arrows); everything downstream becomes a potential outcome. Click nodes to condition on them. Ignorability Y(a) ⫫ A | L holds exactly when every path between A and Y(a) is blocked. Dashed nodes are unobserved.