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 which Jiji Zhang worked out in his Ph.D. dissertation, which is both 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.
-
Constructor Summary
ConstructorsConstructorDescriptionFciOrient
(SepsetProducer sepsets) Constructs a new FCI search for the given independence test and background knowledge. -
Method Summary
Modifier and TypeMethodDescriptionvoid
doFinalOrientation
(Graph graph) Orients the graph according to rules in the graph (FCI step D).void
fciOrientbk
(Knowledge bk, Graph graph, List<Node> variables) Orients according to background knowledgeint
Getter for the fieldmaxPathLength
.Returns the map from {x,y} to {z1,...,zn} for x _||_ y | z1,..,zn.getUcCirclePaths
(Node n1, Node n2, Graph graph) Gets a list of every uncovered circle path between two nodes in the graph by iterating through the uncovered partially directed undirectedPaths and only keeping the circle undirectedPaths.getUcPdPaths
(Node n1, Node n2, Graph graph) Gets a list of every uncovered partially directed path between two nodes in the graph.static boolean
isArrowheadAllowed
(Node x, Node y, Graph graph, Knowledge knowledge) isArrowheadAllowed.boolean
isCompleteRuleSetUsed.Performs final FCI orientation on the given graph.void
orientTailPath
(List<Node> path, Graph graph) Orients every edge on a path as undirected (i.e.void
Orients colliders in the graph.void
ruleR1.void
Tries to apply Zhang's rule R10 to a pair of nodes A and C which are assumed to be such that Ao->C.void
ruleR2.void
Implements the double-triangle orientation rule, which states that if D*-oB, A*->B<-*C and A*-oDo-*C, and !adj(a, c), D*-oB, then D*->B.void
The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where the dots are a collider path from E to A with each node on the path (except L) a parent of C.void
Implements Zhang's rule R5, orient circle undirectedPaths: for any Ao-oB, if there is an uncovered circle path u = [A,C,...,D,B] such that A,D nonadjacent and B,C nonadjacent, then A---B and orient every edge on u undirected.void
Implements Zhang's rules R6 and R7, applies them over the graph once.boolean
Tries to apply Zhang's rule R8 to a pair of nodes A and C which are assumed to be such that Ao->C.boolean
Tries to apply Zhang's rule R9 to a pair of nodes A and C which are assumed to be such that Ao->C.void
rulesR1R2cycle
(Graph graph) rulesR1R2cycle.void
rulesR8R9R10
(Graph graph) Implements Zhang's rules R8, R9, R10, applies them over the graph once.void
setChangeFlag
(boolean changeFlag) Sets the change flag--marks externally that a change has been made.void
setCompleteRuleSetUsed
(boolean completeRuleSetUsed) Setter for the fieldcompleteRuleSetUsed
.void
setDoDiscriminatingPathColliderRule
(boolean doDiscriminatingPathColliderRule) Sets whether the discriminating path collider rule should be done.void
setDoDiscriminatingPathTailRule
(boolean doDiscriminatingPathTailRule) Sets whether the discriminating path tail rule should be done.void
setKnowledge
(Knowledge knowledge) Sets the knowledge to use for the final orientation.void
setMaxPathLength
(int maxPathLength) Setter for the fieldmaxPathLength
.void
setVerbose
(boolean verbose) Sets whether verbose output is printed.void
spirtesFinalOrientation
(Graph graph) spirtesFinalOrientation.void
zhangFinalOrientation
(Graph graph) zhangFinalOrientation.
-
Constructor Details
-
FciOrient
Constructs a new FCI search for the given independence test and background knowledge.- Parameters:
sepsets
- aSepsetProducer
object representing the independence test, which must be given only if the discriminating path rule is used. Otherwise, it can be null.
-
-
Method Details
-
getUcPdPaths
Gets a list of every uncovered partially directed path between two nodes in the graph.Probably extremely slow.
- Parameters:
n1
- The beginning node of the undirectedPaths.n2
- The ending node of the undirectedPaths.graph
- aGraph
object- Returns:
- A list of uncovered partially directed undirectedPaths from n1 to n2.
-
getUcCirclePaths
Gets a list of every uncovered circle path between two nodes in the graph by iterating through the uncovered partially directed undirectedPaths and only keeping the circle undirectedPaths.Probably extremely slow.
- Parameters:
n1
- The beginning node of the undirectedPaths.n2
- The ending node of the undirectedPaths.graph
- aGraph
object- Returns:
- A list of uncovered circle undirectedPaths between n1 and n2.
-
isArrowheadAllowed
isArrowheadAllowed.
-
orient
Performs final FCI orientation on the given graph.- Parameters:
graph
- The graph to further orient.- Returns:
- The oriented graph.
-
getSepsets
Returns the map from {x,y} to {z1,...,zn} for x _||_ y | z1,..,zn.- Returns:
- Thia map.
-
setKnowledge
Sets the knowledge to use for the final orientation.- Parameters:
knowledge
- This knowledge.
-
isCompleteRuleSetUsed
public boolean isCompleteRuleSetUsed()isCompleteRuleSetUsed.
- Returns:
- true if Zhang's complete rule set should be used, false if only R1-R4 (the rule set of the original FCI) should be used. False by default.
-
setCompleteRuleSetUsed
public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) Setter for the field
completeRuleSetUsed
.- Parameters:
completeRuleSetUsed
- set to true if Zhang's complete rule set should be used, false if only R1-R4 (the rule set of the original FCI) should be used. False by default.
-
ruleR0
Orients colliders in the graph. (FCI Step C)Zhang's step F3, rule R0.
- Parameters:
graph
- The graph to orient.
-
doFinalOrientation
Orients the graph according to rules in the graph (FCI step D).Zhang's step F4, rules R1-R10.
- Parameters:
graph
- aGraph
object
-
spirtesFinalOrientation
spirtesFinalOrientation.
- Parameters:
graph
- aGraph
object
-
zhangFinalOrientation
zhangFinalOrientation.
- Parameters:
graph
- aGraph
object
-
rulesR1R2cycle
rulesR1R2cycle.
- Parameters:
graph
- aGraph
object
-
ruleR1
ruleR1.
-
ruleR2
ruleR2.
-
ruleR3
Implements the double-triangle orientation rule, which states that if D*-oB, A*->B<-*C and A*-oDo-*C, and !adj(a, c), D*-oB, then D*->B.This is Zhang's rule R3.
- Parameters:
graph
- aGraph
object
-
ruleR4B
The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where the dots are a collider path from E to A with each node on the path (except L) a parent of C.B xo x is either an arrowhead or a circle / \ v v E....A --> C
This is Zhang's rule R4, discriminating paths.
- Parameters:
graph
- aGraph
object
-
ruleR5
Implements Zhang's rule R5, orient circle undirectedPaths: for any Ao-oB, if there is an uncovered circle path u = [A,C,...,D,B] such that A,D nonadjacent and B,C nonadjacent, then A---B and orient every edge on u undirected.- Parameters:
graph
- aGraph
object
-
ruleR6R7
Implements Zhang's rules R6 and R7, applies them over the graph once. Orient single tails. R6: If A---Bo-*C then A---B--*C. R7: If A--oBo-*C and A,C nonadjacent, then A--oB--*C- 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
-
orientTailPath
Orients every edge on a path as undirected (i.e. A---B).DOES NOT CHECK IF SUCH EDGES ACTUALLY EXIST: MAY DO WEIRD THINGS IF PASSED AN ARBITRARY LIST OF NODES THAT IS NOT A PATH.
- Parameters:
path
- The path to orient as all tails.graph
- aGraph
object
-
ruleR8
Tries to apply Zhang's rule R8 to a pair of nodes A and C which are assumed to be such that Ao->C.MAY HAVE WEIRD EFFECTS ON ARBITRARY NODE PAIRS.
R8: If Ao->C and A-->B-->C or A--oB-->C, then A-->C.
- Parameters:
a
- The node A.c
- The node C.graph
- aGraph
object- Returns:
- Whether R8 was successfully applied.
-
ruleR9
Tries to apply Zhang's rule R9 to a pair of nodes A and C which are assumed to be such that Ao->C.MAY HAVE WEIRD EFFECTS ON ARBITRARY NODE PAIRS.
R9: If Ao->C and there is an uncovered p.d. path u=<A,B,..,C> such that C,B nonadjacent, then A-->C.
- Parameters:
a
- The node A.c
- The node C.graph
- aGraph
object- Returns:
- Whether R9 was succesfully applied.
-
fciOrientbk
Orients according to background knowledge -
getMaxPathLength
public int getMaxPathLength()Getter for the field
maxPathLength
.- Returns:
- the maximum length of any discriminating path, or -1 of unlimited.
-
setMaxPathLength
public void setMaxPathLength(int maxPathLength) Setter for the field
maxPathLength
.- Parameters:
maxPathLength
- 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.
-
setChangeFlag
public void setChangeFlag(boolean changeFlag) Sets the change flag--marks externally that a change has been made.- Parameters:
changeFlag
- This flag.
-
setDoDiscriminatingPathColliderRule
public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) Sets whether the discriminating path collider rule should be done.- Parameters:
doDiscriminatingPathColliderRule
- True is done.
-
setDoDiscriminatingPathTailRule
public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) Sets whether the discriminating path tail rule should be done.- Parameters:
doDiscriminatingPathTailRule
- True if done.
-
ruleR10
Tries to apply Zhang's rule R10 to a pair of nodes A and C which are assumed to be such that Ao->C.MAY HAVE WEIRD EFFECTS ON ARBITRARY NODE PAIRS.
R10: If Ao->C, B-->C<--D, there is an uncovered p.d. path u1=<A,M,...,B> and an uncovered p.d. path u2= <A,N,...,D> with M != N and M,N nonadjacent then A-->C.
- Parameters:
a
- The node A.c
- The node C.graph
- aGraph
object
-