Class OSetTest
java.lang.Object
edu.cmu.tetrad.search.OSetTest
Unit tests for OSet (Henckel–Perković–Maathuis O-sets).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTests thatOSet.oSetCpdag(Graph, Node, Node, int)agrees withOSet.oSetDag(Graph, Node, Node)in a simple unconfounded causal chain.voidTests the behavior ofOSet.oSetCpdag(Graph, Node, Node, int)compared toOSet.oSetDag(Graph, Node, Node)using a minimal confounding example.voidTests theOSet.oSetDag(Graph, Node, Node)method using a classic Henckel–Perković–Maathuis example DAG.voidTestsOSet.oSetDag(Graph, Node, Node)on a simple causal chain with no confounding variables.
-
Constructor Details
-
OSetTest
public OSetTest()Default constructor for the OSetTest class. This class includes a set of unit tests designed to validate the behavior of causal graph-based methods for computing O-sets in both directed acyclic graphs (DAGs) and their equivalence-class representations (CPDAGs). The tests focus on verifying the correctness of O-set computations under various causal structures and scenarios, such as the presence of confounding variables or the absence of backdoor paths.
-
-
Method Details
-
testOSetDag_HenckelExample
public void testOSetDag_HenckelExample()Tests theOSet.oSetDag(Graph, Node, Node)method using a classic Henckel–Perković–Maathuis example DAG.The DAG structure is:
U -> X -> Z -> Y U -> Z W -> X (instrument)
For the causal pair (X, Y):
cn_G(X -> Y)= {Z, Y}pa_G(cn)= {X, U, Z}O_G(X -> Y)= {U}
The test verifies that:
- The computed O-set equals {U},
- and that it excludes mediators (Z), outcomes (Y), and instruments (W).
-
testOSetCpdag_matchesDag
public void testOSetCpdag_matchesDag()Tests the behavior ofOSet.oSetCpdag(Graph, Node, Node, int)compared toOSet.oSetDag(Graph, Node, Node)using a minimal confounding example.The DAG structure is:
U -> X -> Y U -> Y
For this graph:
O_G(X -> Y)in the DAG is {U}, since U is a parent of both X and Y and lies on a backdoor path from X to Y.- When the DAG is converted to its CPDAG, the edges become undirected (Markov equivalence class).
- In this case,
O_G(X -> Y)in the CPDAG differs from the DAG’s O-set, because the direction of causal flow is no longer uniquely identified.
The test therefore asserts that:
- The O-set in the DAG equals {U},
- The O-set in the CPDAG is not equal to that of the DAG, since the CPDAG loses orientation information.
-
testOSetDag_simpleChainNoConfounding
public void testOSetDag_simpleChainNoConfounding()TestsOSet.oSetDag(Graph, Node, Node)on a simple causal chain with no confounding variables.The DAG structure is:
X -> Z -> Y
In this graph:
- There are no common causes (backdoor paths) between X and Y,
- and all paths from X to Y are directed and causal.
Therefore, the O-set for (X, Y) should be empty:
O_G(X -> Y)= ∅
The test verifies that
OSet.oSetDag()returns an empty set, confirming correct handling of unconfounded causal chains. -
testOSetCpdag_agreesWithDag_inSimpleChainNoConfounding
public void testOSetCpdag_agreesWithDag_inSimpleChainNoConfounding()Tests thatOSet.oSetCpdag(Graph, Node, Node, int)agrees withOSet.oSetDag(Graph, Node, Node)in a simple unconfounded causal chain.The DAG structure is:
X -> Z -> Y
Because there are no common causes (no backdoor paths) between X and Y:
- All paths from X to Y are directed and causal,
- The total effect of X on Y is identified without adjustment,
- Hence
O_G(X -> Y)= ∅ in both the DAG and its CPDAG.
This test verifies that the O-set computed from the CPDAG matches that from the DAG, confirming consistency of
OSet.oSetCpdag()in the unconfounded case.
-