Package edu.cmu.tetrad.search
Class Gfci
java.lang.Object
edu.cmu.tetrad.search.Gfci
- All Implemented Interfaces:
IGraphSearch
*-FCI implements a template modification of GFCI that starts with a given Markov CPDAG and then fixes that result to
be correct for latent variables models. First, colliders from the Markov DAG are copied into the final circle-circle
graph, and some independence reasoning is used to remove edges from this and add the remaining colliders into the
graph. Then, the FCI final orientation rules are applied.
The Markov CPDAG needs to be supplied by classes inheriting from this abstract class using the getMarkovCpdag() methods.
The reference for the GFCI algorithm this is being modeled from is here:
Ogarrio, J. M., Spirtes, P., & Ramsey, J. (2016, August). A hybrid causal search algorithm for latent variable models. In Conference on probabilistic graphical models (pp. 368-379). PMLR.
We modify this by insistent that getMarkovCpdag() is overridden by a method that will return a CPDAG Markov to the data or underlying generative model and removing the possible d-sep step of the original algorithm.
This class is configured to respect knowledge of forbidden and required edges, including knowledge of temporal tiers.
- Author:
- josephramsey, bryanandrews
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGfci(IndependenceTest test, Score score) Constructs a new GFci algorithm with the given independence test and score. -
Method Summary
Modifier and TypeMethodDescriptionReturns the independence test used in search.Returns the knowledge used in search.Executes the FGES algorithm to compute the Markov equivalence class in the form of a completed partially directed acyclic graph (CPDAG) based on the provided score and algorithm configuration.booleanIndicates whether verbose output is enabled.search()Runs the graph and returns the search PAG.sepsetSubsetOfAdjxOrAdjy(Graph graph, Node x, Node y, Set<Node> containing, IndependenceTest test, int depth, List<Node> order, boolean useMaxP) Finds a separating set that is a subset of the adjacency of nodes x or y in the input graph.voidsetCompleteRuleSetUsed(boolean completeRuleSetUsed) Sets whether Zhang's complete rules are used.voidsetDepth(int depth) Sets the depth of the search for the possible m-sep search.voidsetFaithfulnessAssumed(boolean faithfulnessAssumed) Sets whether one-edge faithfulness is assumed.voidsetGuaranteePag(boolean guaranteePag) Sets the flag indicating whether to guarantee the output is a legal PAG.voidsetKnowledge(Knowledge knowledge) Sets the knowledge to use in search.voidsetMaxDegree(int maxDegree) Sets the maximum indegree of the output graph.voidsetMaxDiscriminatingPathLength(int maxDiscriminatingPathLength) Sets the maximum length of any discriminating path.voidsetNumThreads(int numThreads) Sets the number of threads to use in the search.voidsetOut(PrintStream out) Sets the print stream used for output, default System.out.voidsetReplicatingGraph(boolean replicatingGraph) Sets the state of the replicatingGraph property.voidsetStartFromCompleteGraph(boolean startFromCompleteGraph) Sets whether the search should start from a complete graph.voidsetUseMaxP(boolean useMaxP) Sets whether the "Use Max-P" option is enabled or not.voidsetVerbose(boolean verbose) Sets whether verbose output should be printed.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.cmu.tetrad.search.IGraphSearch
getTest, setTest
-
Constructor Details
-
Gfci
Constructs a new GFci algorithm with the given independence test and score.- Parameters:
test- The independence test to use.score- The score to use.
-
-
Method Details
-
sepsetSubsetOfAdjxOrAdjy
public static Set<Node> sepsetSubsetOfAdjxOrAdjy(Graph graph, Node x, Node y, Set<Node> containing, IndependenceTest test, int depth, List<Node> order, boolean useMaxP) Finds a separating set that is a subset of the adjacency of nodes x or y in the input graph.- Parameters:
graph- The graph being analyzed.x- The first node between which independence is checked.y- The second node between which independence is checked.containing- A set of nodes that must be included in the separating set.test- The independence test used to evaluate separation.depth- The maximum size of subsets to be tested for independence.order- An optional list specifying the order of nodes for additional constraints.useMaxP- True if the maxP method should be used.- Returns:
- A separating set of nodes (if found) that is a subset of the adjacency of x or y, or
nullif no such set is found.
-
search
Runs the graph and returns the search PAG.- Specified by:
searchin interfaceIGraphSearch- Returns:
- This PAG.
- Throws:
InterruptedException- if any
-
getKnowledge
Returns the knowledge used in search.- Returns:
- This knowledge
-
setKnowledge
Sets the knowledge to use in search.- Parameters:
knowledge- This knowledge.
-
setCompleteRuleSetUsed
public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) Sets whether Zhang's complete rules are used.- 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. True by default.
-
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.
-
isVerbose
public boolean isVerbose()Indicates whether verbose output is enabled.- Returns:
- true if verbose output is enabled, false otherwise.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output should be printed.- Parameters:
verbose- True, if so.
-
getIndependenceTest
Returns the independence test used in search.- Returns:
- This test.
-
setDepth
public void setDepth(int depth) Sets the depth of the search for the possible m-sep search.- Parameters:
depth- This depth.
-
setGuaranteePag
public void setGuaranteePag(boolean guaranteePag) Sets the flag indicating whether to guarantee the output is a legal PAG.- Parameters:
guaranteePag- A boolean value indicating whether to guarantee the output is a legal PAG.
-
setMaxDegree
public void setMaxDegree(int maxDegree) Sets the maximum indegree of the output graph.- Parameters:
maxDegree- This maximum.
-
setOut
Sets the print stream used for output, default System.out.- Parameters:
out- This print stream.
-
setFaithfulnessAssumed
public void setFaithfulnessAssumed(boolean faithfulnessAssumed) Sets whether one-edge faithfulness is assumed. For FGES- Parameters:
faithfulnessAssumed- True, if so.- See Also:
-
setNumThreads
public void setNumThreads(int numThreads) Sets the number of threads to use in the search.- Parameters:
numThreads- The number of threads to use. Must be at least 1.
-
setStartFromCompleteGraph
public void setStartFromCompleteGraph(boolean startFromCompleteGraph) Sets whether the search should start from a complete graph.- Parameters:
startFromCompleteGraph- A boolean value indicating if the search should start from a complete graph.
-
getMarkovCpdag
Executes the FGES algorithm to compute the Markov equivalence class in the form of a completed partially directed acyclic graph (CPDAG) based on the provided score and algorithm configuration.- Returns:
- The resulting CPDAG representing the Markov equivalence class.
- Throws:
InterruptedException- if the operation is interrupted.
-
setUseMaxP
public void setUseMaxP(boolean useMaxP) Sets whether the "Use Max-P" option is enabled or not.- Parameters:
useMaxP- A boolean flag indicating whether the "Use Max-P" option is enabled (true) or disabled (false).
-
setReplicatingGraph
public void setReplicatingGraph(boolean replicatingGraph) Sets the state of the replicatingGraph property.- Parameters:
replicatingGraph- a boolean value indicating whether the graph is in a replicating state.
-