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 GFCI 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 using 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, Choh-Man Teng
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionFciOrient
(R0R4Strategy strategy) Initializes a new instance of the FciOrient class with the specified R4Strategy. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fciOrientbk
(Knowledge bk, Graph graph, List<Node> variables) Orient the edges of a graph based on the given knowledge.void
finalOrientation
(Graph graph) Orients the graph (in place) according to rules in the graph (FCI step D).Returns the initial allowed colliders based on the current strategy.int
Returns the maximum path length, or -1 if unlimited.static boolean
isArrowheadAllowed
(Node x, Node y, Graph graph, Knowledge knowledge) Determines whether an arrowhead is allowed between two nodes in a graph, based on specific conditions.boolean
Checks if the complete rule set is being used.void
Performs FCI orientation on the given graph, including R0 and either the Spirtes or Zhang final orientation rules.void
Orients unshielded colliders in the graph.void
R1 If α ∗→ β o−−∗ γ, and α and γ are not adjacent, then orient the triple as α ∗→ β → γ.void
R10 Suppose α o→ γ, β → γ ← θ, p1 is an uncovered potentially directed (semidirected) path from α to β, and p2 is an uncovered p.d.void
R2 If α → β ∗→ γ or α ∗→ β → γ, and α ∗−o γ, then orient α ∗−o γ as α ∗→ γ.void
R3 If α ∗→ β ←∗ γ, α ∗−o θ o−∗ γ, α and γ are not adjacent, and θ ∗−o β, then orient θ ∗−o β as θ ∗→ β.void
R4 If u = <θ ,...,α,β,γ> is a discriminating path between θ and γ for β, and β o−−∗ γ; then if β ∈ Sepset(θ,γ), orient β o−−∗ γ as β → γ; otherwise orient the triple <α,β,γ> as α ↔ β ↔ γ.void
R5 For every (remaining) α o−−o β, if there is an uncovered circle path p = <α,γ,...,θ,β> between α and β s.t.void
R6 If α —- β o−−∗ γ (α and γ may or may not be adjacent), then orient β o−−∗ γ as β −−∗ γ.void
R7 If α −−o β o−−∗ γ, and α, γ are not adjacent, then orient β o−−∗ γ as β −−∗ γ.boolean
R8 If α → β → γ or α−−◦β → γ, and α o→ γ, orient α o→ γ as α → γ.boolean
R9 If α o→ γ, and p = <α,β,θ,...,γ> is an uncovered potentialy directed path from α to γ such that γ and β are not adjacent, then orient α o→ γ as α → γ.void
rulesR1R2cycle
(Graph graph) Apply rules R1 and R2 in cycles for a given graph.void
rulesR8R9R10
(Graph graph) Implements Zhang's rules R8, R9, R10, applies them over the graph once.void
setAllowedColliders
(Set<Triple> allowedColliders) Sets the allowed colliders for this object.void
setCompleteRuleSetUsed
(boolean completeRuleSetUsed) Sets the flag indicating if the complete rule set is being used.void
setDoDiscriminatingPathColliderRule
(boolean doDiscriminatingPathColliderRule) Sets whether the discriminating path collider rule should be used.void
setDoDiscriminatingPathTailRule
(boolean doDiscriminatingPathTailRule) Sets whether the discriminating path tail rule should be used.void
setEndpointStrategy
(SetEndpointStrategy endpointStrategy) Sets the endpoint strategy for this object.void
setInitialAllowedColliders
(HashSet<Triple> initialAllowedColliders) Sets the initial allowed colliders for the strategy.void
setKnowledge
(Knowledge knowledge) Sets the knowledge to use for the final orientation.void
setMaxPathLength
(int maxPathLength) Sets the maximum length of any discriminating path.void
setParallel
(boolean parallel) Sets whether the discriminating path orientation should be run in parallel.void
setTestTimeout
(long testTimeout) Sets the timeout for running tests.void
setVerbose
(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 whether an arrowhead is allowed between two nodes in a graph, based on specific conditions.- Parameters:
x
- The first node.y
- The second node.graph
- The graph data structure.knowledge
- The knowledge base containing forbidden connections.- Returns:
- true if an arrowhead is allowed between X and Y, false otherwise.
-
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
- aGraph
object
-
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 α ∗→ γ.- 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
- aGraph
object
-
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
- aGraph
object
-
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
- aGraph
object
-
ruleR6
R6 If α —- β o−−∗ γ (α and γ may or may not be adjacent), then orient β o−−∗ γ as β −−∗ γ.- Parameters:
graph
- aGraph
object
-
ruleR7
R7 If α −−o β o−−∗ γ, and α, γ are not adjacent, then orient β o−−∗ γ as β −−∗ γ.- Parameters:
graph
- aGraph
object
-
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
- aGraph
object
-
ruleR8
R8 If α → β → γ or α−−◦β → γ, and α o→ γ, orient α o→ γ as α → γ.- Parameters:
a
- αc
- γgraph
- aGraph
object- 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
- aGraph
object- Returns:
- Whether R9 was succesfully 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 ω are distinct, and are not adjacent, then orient α o→ γ as α → γ.- Parameters:
a
- αc
- γgraph
- aGraph
object
-
getMaxPathLength
public int getMaxPathLength()Returns the maximum path length, or -1 if unlimited.- Returns:
- the maximum path length
-
setMaxPathLength
public void setMaxPathLength(int maxPathLength) Sets the maximum length of any discriminating path.- Parameters:
maxPathLength
- the maximum length of any discriminating path, or -1 if unlimited.
-
setDoDiscriminatingPathTailRule
public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) Sets whether the discriminating path tail rule should be used.- Parameters:
doDiscriminatingPathTailRule
- True, if so.
-
setDoDiscriminatingPathColliderRule
public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) Sets whether the discriminating path collider rule should be used.- Parameters:
doDiscriminatingPathColliderRule
- True, if so.
-
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
-
setAllowedColliders
Sets the allowed colliders for this object. These are passed to R4 is the set of unshielded colliders for the model is to be restricted. TODO Think this through again.- Parameters:
allowedColliders
- the set of colliders allowed to interact with this object
-
getInitialAllowedColliders
Returns the initial allowed colliders based on the current strategy. These are the unshielded colliders from R4's first run.TODO think this through again.
- Returns:
- a collection of Triple objects representing the initial allowed colliders.
-
setInitialAllowedColliders
Sets the initial allowed colliders for the strategy.TODO: Think this thorugh again.
- Parameters:
initialAllowedColliders
- The set of initial allowed colliders.
-
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.
-