Ejemplo n.º 1
0
def get_adjustment_set(graph: CausalGraph, treatment: str,
                       outcome: str) -> Dict[str, List[Set[str]]]:
    return {
        "backdoor": backdoor.get_adjustment_sets(graph, treatment, outcome),
        "frontoor": frontdoor.get_adjustment_set(graph, treatment, outcome),
        "do-calculus": do_calculus.get_adjustment_set(graph, treatment,
                                                      outcome)
    }
Ejemplo n.º 2
0
 def test_canonical_frontdoor(self):
     model_str = SAMPLE_DAGS["canonical_frontdoor"]
     model = parse_model_string(model_str)
     adj_sets = get_adjustment_sets(model)
     # front door can't be identified using backdoor adjustment
     assert len(adj_sets) == 0
Ejemplo n.º 3
0
 def test_schrier_and_platt_2008(self):
     model_str = SAMPLE_DAGS["Shrier&Platt, 2008"]
     model = parse_model_string(model_str)
     adj_sets = get_adjustment_sets(model)
     assert len(adj_sets) == 7
Ejemplo n.º 4
0
 def test_big_m(self):
     model_str = SAMPLE_DAGS["big-M"]
     model = parse_model_string(model_str)
     adj_sets = get_adjustment_sets(model)
     assert len(adj_sets) == 4
     assert all("Z₁" in s for s in adj_sets)
Ejemplo n.º 5
0
 def test_m_bias(self):
     model_str = SAMPLE_DAGS["M-bias"]
     model = parse_model_string(model_str)
     adj_sets = get_adjustment_sets(model)
     assert len(adj_sets) == 1
     assert adj_sets[0] == set()  # no adjustment must be performed
Ejemplo n.º 6
0
 def test_simple_collider_backdoor(self):
     model = parse_model_string(["x[T]->y[O]", "w->x", "w->y"])
     adj_sets = get_adjustment_sets(model, treatment="x", outcome="y")
     assert adj_sets == [set("w")]