|
2 | 2 |
|
3 | 3 | """Predicates for good, bad, and neutral controls.""" |
4 | 4 |
|
| 5 | +from .algorithm.conditional_independencies import are_d_separated |
5 | 6 | from .dsl import Probability, Variable |
6 | 7 | from .graph import NxMixedGraph |
7 | 8 |
|
@@ -44,3 +45,27 @@ def is_bad_control(graph: NxMixedGraph, query: Probability, variable: Variable) |
44 | 45 | """ |
45 | 46 | _control_precondition(graph, query, variable) |
46 | 47 | raise NotImplementedError |
| 48 | + |
| 49 | + |
| 50 | +def is_outcome_ancestor( |
| 51 | + graph: NxMixedGraph, cause: Variable, effect: Variable, variable: Variable |
| 52 | +) -> bool: |
| 53 | + """Check if the variable is an outcome ancestor given a causal query and graph. |
| 54 | +
|
| 55 | + > In Model 8, Z is not a confounder nor does it block any back-door paths. Likewise, |
| 56 | + controlling for Z does not open any back-door paths from X to Y . Thus, in terms of |
| 57 | + asymptotic bias, Z is a “neutral control.” Analysis shows, however, that controlling for |
| 58 | + Z reduces the variation of the outcome variable Y , and helps to improve the precision |
| 59 | + of the ACE estimate in finite samples (Hahn, 2004; White and Lu, 2011; Henckel et al., |
| 60 | + 2019; Rotnitzky and Smucler, 2019). |
| 61 | +
|
| 62 | + :param graph: An ADMG |
| 63 | + :param cause: The intervention in the causal query |
| 64 | + :param effect: The outcome of the causal query |
| 65 | + :param variable: The variable to check |
| 66 | + :return: If the variable is a bad control |
| 67 | + """ |
| 68 | + if variable == cause: |
| 69 | + return False |
| 70 | + judgement = are_d_separated(graph, cause, variable) |
| 71 | + return judgement.separated and variable in graph.ancestors_inclusive(effect) |
0 commit comments