Class FciOrient
There are two versions of these final orientation steps, one due to Peter Spirtes (the original, in Causation, Prediction and Search), which is arrow complete, and the other due to Jiji Zhang, which is arrow and tail complete. The references for these are as follows.
Spirtes, P., Glymour, C. N., Scheines, R., & Heckerman, D. (2000). Causation, prediction, and search. MIT press.
Zhang, J. (2008). On the completeness of orientation rules for causal discovery in the presence of latent confounders and selection bias. Artificial Intelligence, 172(16-17), 1873-1896.
These final rules are used in all algorithms in Tetrad that follow and refine the FCI algorithm--for example, the FGES-FCI and RFCI algorihtms.
We've made the methods for each of the separate rules publicly accessible in case someone wants to use the individual rules in the context of their own algorithms.
Note: This class is a modified version of the original FciOrient class, in that we allow the R0 and R4 rules to be be overridden by subclasses. This is useful for the TeyssierScorer class, which needs to override these rules in order to calculate the score of the graph. It is also useful for DAG to PAG, which needs to override these rules in order to use D-SEP. The R0 and R4 rules are the only ones that cannot be carried out by an examination of the graph but which require additional analysis of the underlying distribution or graph. In addition, several methods have been optimized.
- Version:
- $Id: $Id
- Author:
- Erin Korber, June 2004, Alex Smith, December 2008, josephramsey 2024-8-21, Choh-Man Teng
-
Constructor Summary
ConstructorsConstructorDescriptionFciOrient(R0R4Strategy strategy) Initializes a new instance of the FciOrient class with the specified R4Strategy. -
Method Summary
Modifier and TypeMethodDescriptionvoidfciOrientbk(Knowledge bk, Graph graph, List<Node> variables) Orient the edges of a graph based on the given knowledge.voidfinalOrientation(Graph graph) Orients the graph (in place) according to rules in the graph (FCI step D).intReturns the maximum path length, or -1 if unlimited.static booleanisArrowheadAllowed(Node x, Node y, Graph graph, Knowledge K) Determines if an arrowhead can be placed at node Y in the given graph, based on the adjacency relationships, endpoint types, and any provided prior knowledge constraints.booleanChecks if the complete rule set is being used.static Set<DiscriminatingPath> listDiscriminatingPaths(Graph graph, int maxDiscriminatingPathLength, boolean checkXyNonadjacency) Lists all the discriminating paths in the given graph.static Set<DiscriminatingPath> listDiscriminatingPaths(Graph graph, Node w, Node y, int maxDiscriminatingPathLength, boolean checkEcNonadjacency) Lists the discriminating paths for <w, y> in the graph.voidPerforms FCI orientation on the given graph, including R0 and either the Spirtes or Zhang final orientation rules.voidOrients unshielded colliders in the graph.voidR1: If α *→ β o––* γ, and α and γ are not adjacent, then orient the triple as α *→ β → γ.voidR10 Suppose α oâ γ, β â γ â θ, p1 is an uncovered potentially directed (semidirected) path from α to β, and p2 is an uncovered p.d.voidR2: If α → β ∘→ γ or α ∘→ β → γ, and α ∘–o γ, then orient α ∘–o γ as α ∘→ γ.voidR3: If α *→ β ←* γ, α *–o θ o–* γ, α and γ are not adjacent, and θ *–o β, then orient θ *–o β as θ *→ β.voidR4 If u = <θ ,...,α,β,γ> is a discriminating path between θ and γ for β, and β oâââ γ; then if β â Sepset(θ,γ), orient β oâââ γ as β â γ; otherwise orient the triple <α,β,γ> as α â β â γ.voidR5 For every (remaining) α oââo β, if there is an uncovered circle path p = <α,γ,...,θ,β> between α and β s.t.voidR6 If α â- β oâââ γ (α and γ may or may not be adjacent), then orient β oâââ γ as β âââ γ.voidR7 If α ââo β oâââ γ, and α, γ are not adjacent, then orient β oâââ γ as β âââ γ.booleanR8 If α â β â γ or αâââ¦Î² â γ, and α oâ γ, orient α oâ γ as α â γ.booleanR9 If α oâ γ, and p = <α,β,θ,...,γ> is an uncovered potentialy directed path from α to γ such that γ and β are not adjacent, then orient α oâ γ as α â γ.voidrulesR1R2cycle(Graph graph) Apply rules R1 and R2 in cycles for a given graph.voidrulesR8R9R10(Graph graph) Implements Zhang's rules R8, R9, R10, applies them over the graph once.voidsetCompleteRuleSetUsed(boolean completeRuleSetUsed) Sets the flag indicating if the complete rule set is being used.voidsetEndpointStrategy(SetEndpointStrategy endpointStrategy) Sets the endpoint strategy for this object.voidsetKnowledge(Knowledge knowledge) Sets the knowledge to use for the final orientation.voidsetMaxDiscriminatingPathLength(int maxDiscriminatingPathLength) Sets the maximum length of any discriminating path.voidsetParallel(boolean parallel) Sets whether the discriminating path orientation should be run in parallel.voidsetTestTimeout(long testTimeout) Sets the timeout for running tests.voidsetUseR4(boolean useR4) Sets whether R4 should be run.voidsetVerbose(boolean verbose) Sets whether verbose output is printed.
-
Constructor Details
-
FciOrient
Initializes a new instance of the FciOrient class with the specified R4Strategy.- Parameters:
strategy- The FciOrientDataExaminationStrategy to use for the examination.- Throws:
NullPointerException- If the strategy parameter is null.- See Also:
-
-
Method Details
-
isArrowheadAllowed
Determines if an arrowhead can be placed at node Y in the given graph, based on the adjacency relationships, endpoint types, and any provided prior knowledge constraints.- Parameters:
x- The first node under consideration in the graph.y- The second node under consideration in the graph, where the arrowhead placement is evaluated.graph- The graph object containing nodes and their relationships.K- An object representing prior knowledge that may impose requirements or restrictions on edges.- Returns:
- true if an arrowhead is allowed at node Y under the given conditions; false otherwise.
-
listDiscriminatingPaths
public static Set<DiscriminatingPath> listDiscriminatingPaths(Graph graph, int maxDiscriminatingPathLength, boolean checkXyNonadjacency) Lists all the discriminating paths in the given graph.- Parameters:
graph- the graph to analyzemaxDiscriminatingPathLength- the maximum length of a discriminating pathcheckXyNonadjacency- whether to check for EC nonadjacency- Returns:
- a set of discriminating paths found in the graph
-
listDiscriminatingPaths
public static Set<DiscriminatingPath> listDiscriminatingPaths(Graph graph, Node w, Node y, int maxDiscriminatingPathLength, boolean checkEcNonadjacency) Lists the discriminating paths for <w, y> in the graph.- Parameters:
graph- The graph.w- The first node.y- The second node.maxDiscriminatingPathLength- The maximum length of w discriminating path.checkEcNonadjacency- Whether to check for EC nonadjacency.- Returns:
- The set of discriminating paths for <w, y>.
-
orient
Performs FCI orientation on the given graph, including R0 and either the Spirtes or Zhang final orientation rules.- Parameters:
graph- The graph to orient.unshieldedTriples- The set of unshielded triples oriented by R0. This set is updated with new triples.
-
setKnowledge
Sets the knowledge to use for the final orientation.- Parameters:
knowledge- This knowledge.
-
isCompleteRuleSetUsed
public boolean isCompleteRuleSetUsed()Checks if the complete rule set is being used.- Returns:
- true if the complete rule set is being used, false otherwise.
-
setCompleteRuleSetUsed
public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) Sets the flag indicating if the complete rule set is being used.- Parameters:
completeRuleSetUsed- boolean value indicating if the complete rule set is being used
-
ruleR0
Orients unshielded colliders in the graph. (FCI Step C, Zhang's step F3, rule R0.)- Parameters:
graph- The graph to orient.unshieldedTriples- The set of unshielded triples oriented by R0. This set is updated with new triples.
-
finalOrientation
Orients the graph (in place) according to rules in the graph (FCI step D).Zhang's rules R1-R10.
- Parameters:
graph- aGraphobject
-
rulesR1R2cycle
Apply rules R1 and R2 in cycles for a given graph.- Parameters:
graph- The graph to apply the rules on.
-
ruleR1
R1: If α *→ β o––* γ, and α and γ are not adjacent, then orient the triple as α *→ β → γ.- Parameters:
a- αb- βc- γgraph- the graph containing the edges and nodes
-
ruleR2
R2: If α → β ∘→ γ or α ∘→ β → γ, and α ∘–o γ, then orient α ∘–o γ as α ∘→ γ. Intuition: when there’s a directed path α → β → γ with a circle on the edge incident to β on one side, and α–γ is currently a circle–circle edge, we can orient α–γ toward γ.- Parameters:
a- αb- βc- γgraph- the graph in which the nodes exist
-
ruleR3
R3: If α *→ β ←* γ, α *–o θ o–* γ, α and γ are not adjacent, and θ *–o β, then orient θ *–o β as θ *→ β.- Parameters:
graph- the graph in which the nodes exist
-
ruleR4
R4 If u = <θ ,...,α,β,γ> is a discriminating path between θ and γ for β, and β oâââ γ; then if β â Sepset(θ,γ), orient β oâââ γ as β â γ; otherwise orient the triple <α,β,γ> as α â β â γ.- Parameters:
graph- aGraphobject
-
ruleR5
R5 For every (remaining) α oââo β, if there is an uncovered circle path p = <α,γ,...,θ,β> between α and β s.t. α,θ are not adjacent and β,γ are not adjacent, then orient α oââo β and every edge on p as undirected edges (--).- Parameters:
graph- the graph to orient.
-
ruleR6
R6 If α â- β oâââ γ (α and γ may or may not be adjacent), then orient β oâââ γ as β âââ γ.- Parameters:
graph- aGraphobject
-
ruleR7
R7 If α ââo β oâââ γ, and α, γ are not adjacent, then orient β oâââ γ as β âââ γ.- Parameters:
graph- aGraphobject
-
rulesR8R9R10
Implements Zhang's rules R8, R9, R10, applies them over the graph once. Orient arrow tails. I.e., tries R8, R9, and R10 in that sequence on each Ao->C in the graph.- Parameters:
graph- aGraphobject
-
ruleR8
R8 If α â β â γ or αâââ¦Î² â γ, and α oâ γ, orient α oâ γ as α â γ.- Parameters:
a- αc- γgraph- aGraphobject- Returns:
- Whether R8 was successfully applied.
-
ruleR9
R9 If α oâ γ, and p = <α,β,θ,...,γ> is an uncovered potentialy directed path from α to γ such that γ and β are not adjacent, then orient α oâ γ as α â γ.- Parameters:
a- The node A.c- The node C.graph- The graph being oriented.- Returns:
- Whether R9 was successfully applied.
-
ruleR10
R10 Suppose α oâ γ, β â γ â θ, p1 is an uncovered potentially directed (semidirected) path from α to β, and p2 is an uncovered p.d. path from α to θ. Let μ be the vertex adjacent to α on p1 (μ could be β), and Ï be the vertex adjacent to α on p2 (Ï could be θ). If μ and Ï ar e distinct, and are not adjacent, then orient α oâ γ as α â γ.- Parameters:
alpha- αgamma- γgraph- alphaGraphobject
-
getMaxDiscriminatingPathLength
public int getMaxDiscriminatingPathLength()Returns the maximum path length, or -1 if unlimited.- Returns:
- the maximum path length
-
setMaxDiscriminatingPathLength
public void setMaxDiscriminatingPathLength(int maxDiscriminatingPathLength) Sets the maximum length of any discriminating path.- Parameters:
maxDiscriminatingPathLength- the maximum length of any discriminating path, or -1 if unlimited.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output is printed.- Parameters:
verbose- True, if so.
-
setTestTimeout
public void setTestTimeout(long testTimeout) Sets the timeout for running tests.- Parameters:
testTimeout- the timeout value in milliseconds
-
setParallel
public void setParallel(boolean parallel) Sets whether the discriminating path orientation should be run in parallel.- Parameters:
parallel- True, if so.
-
setEndpointStrategy
Sets the endpoint strategy for this object.- Parameters:
endpointStrategy- the endpoint strategy to set- See Also:
-
fciOrientbk
Orient the edges of a graph based on the given knowledge.- Parameters:
bk- The knowledge containing forbidden and required edges.graph- The graph to be oriented.variables- The list of nodes in the graph.
-
setUseR4
public void setUseR4(boolean useR4) Sets whether R4 should be run.- Parameters:
useR4- True, if so.
-