Skip to content

Commit 4fe4524

Browse files
cthoytdjinnome
andcommitted
Add Jeremy's example graphs
Co-Authored-By: Jeremy Zucker <[email protected]>
1 parent c70c8e5 commit 4fe4524

File tree

1 file changed

+173
-4
lines changed

1 file changed

+173
-4
lines changed

src/y0/examples.py

Lines changed: 173 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Example:
316316

317317
line_5_example = Example(
318318
name="graph containing a hedge",
319-
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy. ",
319+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
320320
graph=NxMixedGraph.from_edges(directed=[(X, Y)], undirected=[(X, Y)]),
321321
identifications=[
322322
dict(
@@ -336,7 +336,7 @@ class Example:
336336
description="If there are no bidirected arcs from X to the other nodes in the"
337337
" current subproblem under consideration, then we can replace acting"
338338
" on X by conditioning, and thus solve the subproblem.",
339-
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy. ",
339+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
340340
graph=NxMixedGraph.from_edges(directed=[(X, Y), (X, Z), (Z, Y)], undirected=[(X, Z)]),
341341
identifications=[
342342
dict(
@@ -366,7 +366,7 @@ class Example:
366366

367367
line_7_example = Example(
368368
name="ID Line 7 example, figure 5a and b",
369-
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy. ",
369+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
370370
graph=NxMixedGraph.from_edges(directed=[(X, Y1), (W1, Y1)], undirected=[(W1, Y1)]),
371371
identifications=[
372372
dict(
@@ -392,7 +392,7 @@ class Example:
392392

393393
figure_6a = Example(
394394
name="Causal graph with identifiable conditional effect P(y|do(x),z)",
395-
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy. ",
395+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
396396
graph=NxMixedGraph.from_edges(directed=[(X, Z), (Z, Y)], undirected=[(X, Z)]),
397397
identifications=[
398398
dict(
@@ -416,6 +416,175 @@ class Example:
416416
],
417417
)
418418

419+
figure_9a = Example(
420+
name="Original causal diagram",
421+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
422+
graph=NxMixedGraph.from_edges(directed=[(X, W), (W, Y), (D, Z), (Z, Y)], undirected=[(X, Y)]),
423+
)
424+
425+
figure_9b = Example(
426+
name="Parallel worlds graph for :math:`P(y_x|x', x_d, d)`",
427+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
428+
graph=NxMixedGraph.from_edges(
429+
directed=[
430+
(X @ ~X, W @ ~X),
431+
(W @ ~X, Y @ ~X),
432+
(D @ ~X, Z @ ~X),
433+
(Z @ ~X, Y @ ~X),
434+
(X, W),
435+
(W, Y),
436+
(D, Z),
437+
(Z, Y),
438+
(X @ D, W @ D),
439+
(W @ D, Y @ D),
440+
(D @ D, Z @ D),
441+
(Z @ D, Y @ D),
442+
],
443+
undirected=[
444+
(X, Y),
445+
(X @ D, X),
446+
(Y @ ~X, Y),
447+
(Y, Y @ D),
448+
(Y @ D, Y @ ~X),
449+
(X, Y @ ~X),
450+
(X @ D, Y),
451+
(X, Y @ D),
452+
(X @ D, Y @ ~X),
453+
(X @ D, Y @ D),
454+
(D @ ~X, D),
455+
(W @ ~X, W),
456+
(W, W @ D),
457+
(W @ D, W @ ~X),
458+
(Z @ ~X, Z),
459+
(Z, Z @ D),
460+
(Z @ ~X, Z @ D),
461+
],
462+
),
463+
)
464+
465+
figure_9c = Example(
466+
name="Counterfactual graph for :math:`P(y_x | x', z_d, d)`",
467+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
468+
graph=NxMixedGraph.from_edges(
469+
directed=[(X @ ~X, W @ ~X), (W @ ~X, Y @ ~X), (D, Z), (Z, Y @ ~X)],
470+
undirected=[(X, Y @ ~X)],
471+
),
472+
)
473+
474+
figure_9d = Example(
475+
name="Counterfactual graph resulting from application of make_counterfactual_graph() with"
476+
" joint distribution from which :math:`P(y_{x,z}|x')` is derived, namely :math:`P(y_{x,z}, x')`",
477+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
478+
graph=NxMixedGraph.from_edges(
479+
nodes=(X, X @ (Z, ~X), Z @ (Z, ~X), W @ (Z, ~X), Y @ (Z, ~X)),
480+
directed=[
481+
(X @ (Z, ~X), W @ (Z, ~X)),
482+
(Z @ (Z, ~X), Y @ (Z, ~X)),
483+
(W @ (Z, ~X), Y @ (Z, ~X)),
484+
],
485+
undirected=[(X, Y @ (Z, ~X))],
486+
),
487+
)
488+
489+
figure_9e = Example(
490+
name="Counterfactual graph for :math:`P(Y @ (~X, Z) | X)`",
491+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
492+
graph=NxMixedGraph.from_edges(
493+
nodes=(D, X, X @ (~X, Z), Z @ (~X, Z), W @ (~X, Z), Y @ (~X, Z)),
494+
directed=[(D, Z), (X @ (~X, Z), W @ (~X, Z)), (Z, Y @ (~X, Z)), (W @ (~X, Z), Y @ (~X, Z))],
495+
undirected=[(X, Y @ (~X, Z))],
496+
),
497+
)
498+
499+
figure_11a = Example(
500+
name="Intermediate graph obtained by **make-cg** in constructing the"
501+
" counterfactual graph for for :math:`P(y_x|x', z_d, d)` from Figure 9b",
502+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
503+
graph=NxMixedGraph.from_edges(
504+
directed=[
505+
(X @ ~X, W @ ~X),
506+
(W @ ~X, Y @ ~X),
507+
(D, Z @ ~X),
508+
(Z @ ~X, Y @ ~X),
509+
(X, W),
510+
(W, Y),
511+
(D, Z),
512+
(Z, Y),
513+
(X, W @ D),
514+
(W @ D, Y @ D),
515+
(D @ D, Z @ D),
516+
(Z @ D, Y @ D),
517+
],
518+
undirected=[
519+
(X, Y),
520+
(Y @ ~X, Y),
521+
(Y, Y @ D),
522+
(Y @ D, X),
523+
(X, Y @ ~X),
524+
(Y @ D, Y @ ~X),
525+
(W @ ~X, W),
526+
(W, W @ D),
527+
(W @ D, W @ ~X),
528+
(Z @ ~X, Z),
529+
(Z, Z @ D),
530+
(Z @ ~X, Z @ D),
531+
],
532+
),
533+
)
534+
535+
figure_11b = Example(
536+
name="Intermediate graph obtained by **make-cg** in constructing the"
537+
" counterfactual graph for for :math:`P(y_x|x', z_d, d)` from Figure 9b",
538+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
539+
graph=NxMixedGraph.from_edges(
540+
directed=[
541+
(X @ ~X, W @ ~X),
542+
(W @ ~X, Y @ ~X),
543+
(D, Z),
544+
(Z, Y @ ~X),
545+
(Z, Y @ D),
546+
(Z, Y),
547+
(X, W),
548+
(W, Y),
549+
(W, Y @ D),
550+
],
551+
undirected=[
552+
(X, Y),
553+
(Y @ ~X, Y),
554+
(Y, Y @ D),
555+
(Y @ D, X),
556+
(Y @ D, Y @ ~X),
557+
(X, Y @ ~X),
558+
(X, Y @ D),
559+
(W @ ~X, W),
560+
],
561+
),
562+
)
563+
564+
figure_11c = Example(
565+
name="Intermediate graph obtained by **make-cg** in constructing the counterfactual"
566+
" graph for for :math:`P(y_x|x', z_d, d)` from Figure 9b",
567+
reference="Shpitser, I., & Pearl, J. (2008). Complete Identification Methods for the Causal Hierarchy.",
568+
graph=NxMixedGraph.from_edges(
569+
directed=[
570+
(X @ ~X, W @ ~X),
571+
(W @ ~X, Y @ ~X),
572+
(D, Z),
573+
(Z, Y @ ~X),
574+
(Z, Y),
575+
(X, W),
576+
(W, Y),
577+
],
578+
undirected=[
579+
(X, Y),
580+
(Y @ ~X, Y),
581+
(X, Y @ ~X),
582+
(W @ ~X, W),
583+
],
584+
),
585+
)
586+
587+
419588
cyclic_directed_example = Example(
420589
name="Cyclic directed graph",
421590
reference="out of the mind of JZ and ZW",

0 commit comments

Comments
 (0)