Class Pc
- All Implemented Interfaces:
- IGraphSearch
Implements the PC (Peter and Clark) algorithm, which uses conditional independence testing as an oracle to first of all remove extraneous edges from a complete graph, then to orient the unshielded colliders in the graph, and finally to make any additional orientations that are capable of avoiding additional unshielded colliders in the graph. An version of this algorithm was proposed earlier than this, but the standard reference for the algorithm is in Chapter 6 of the following book:
Spirtes, P., Glymour, C. N., Scheines, R., & Heckerman, D. (2000). Causation, prediction, and search. MIT press.
A modified rule set capable of dealing effectively with knowledge of required and forbidden edges is due to Chris Meek, with this reference:
Meek, C. (1995), "Causal inference and causal explanation with background knowledge."
This class is configured to respect knowledge of forbidden and required edges, including knowledge of temporal tiers.
- Author:
- peterspirtes, chrismeek, clarkglymour, josephramsey
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionPc(IndependenceTest independenceTest) Constructs a new PC search using the given independence test as oracle.
- 
Method SummaryModifier and TypeMethodDescriptionReturns The edges of the searched graph.intgetDepth()Returns the current depth of search--that is, the maximum number of conditioning nodes for any conditional independence checked.longReturns the elapsed time of the search, in milliseconds.Returns the independence test being used in the search.Returns the knowledge specification used in the search.getNodes()Returns the nodes of the search graph.Returns the non-adjacencies of the searched graph.intReturns the number of independence tests performed in the search.Returns the sepset map from the most recent search.booleanReturns true iff edges will not be added if they would create cycles.search()Runs PC starting with a complete graph over all nodes of the given conditional independence test, using the given independence test and knowledge and returns the resultant graph.Runs the search using a particular implementation of the fast adjacency search (FAS), over the given sublist of nodes.Runs PC starting with a commplete graph over the given list of nodes, using the given independence test and knowledge and returns the resultant graph.voidsetAggressivelyPreventCycles(boolean aggressivelyPreventCycles) Sets whether cycles should be aggressively checked.voidsetDepth(int depth) Sets the depth of the search--that is, the maximum number of conditioning nodes for any conditional independence checked.voidsetKnowledge(Knowledge knowledge) Sets the knowledge specification to be used in the search.voidsetMaxPPathLength(int maxPPathLength) Sets the maximum path length for the PC heuristic.voidsetStable(boolean stable) Sets whether the stable adjacency search should be used.voidsetUseMaxP(boolean useMaxP) Sets whether the max p method should be used in the adjacency searc h.voidsetVerbose(boolean verbose) Sets whether verbose output should be given.
- 
Constructor Details- 
PcConstructs a new PC search using the given independence test as oracle.- Parameters:
- independenceTest- The oracle for conditional independence facts. This does not make a copy of the independence test, for fear of duplicating the data set!
 
 
- 
- 
Method Details- 
isAggressivelyPreventCyclespublic boolean isAggressivelyPreventCycles()Returns true iff edges will not be added if they would create cycles.- Returns:
- True if so.
 
- 
setAggressivelyPreventCyclespublic void setAggressivelyPreventCycles(boolean aggressivelyPreventCycles) Sets whether cycles should be aggressively checked.- Parameters:
- aggressivelyPreventCycles- Set to true just in case edges will not be addeds if they would create cycles.
 
- 
getIndependenceTestReturns the independence test being used in the search.- Returns:
- this test.
 
- 
getKnowledgeReturns the knowledge specification used in the search. Non-null.- Returns:
- This knowledge.
 
- 
setKnowledgeSets the knowledge specification to be used in the search. May not be null.- Parameters:
- knowledge- The knowledge.
 
- 
getSepsetsReturns the sepset map from the most recent search. Non-null after the first call tosearch().- Returns:
- This map.
 
- 
getDepthpublic int getDepth()Returns the current depth of search--that is, the maximum number of conditioning nodes for any conditional independence checked.- Returns:
- This depth.
 
- 
setDepthpublic void setDepth(int depth) Sets the depth of the search--that is, the maximum number of conditioning nodes for any conditional independence checked.- Parameters:
- depth- The depth of the search. The default is 1000. A value of -1 may be used to indicate that the depth should be high (1000). A value of Integer.MAX_VALUE may not be used, due to a bug on multi-core machines.
 
- 
searchRuns PC starting with a complete graph over all nodes of the given conditional independence test, using the given independence test and knowledge and returns the resultant graph. The returned graph will be a CPDAG if the independence information is consistent with the hypothesis that there are no latent common causes. It may, however, contain cycles or bidirected edges if this assumption is not born out, either due to the actual presence of latent common causes, or due to statistical errors in conditional independence judgments.- Specified by:
- searchin interface- IGraphSearch
- Returns:
- The found CPDAG. In some cases there may be some errant bidirected edges or cycles, depending on the settings and whether the faithfulness assumption holds. If the faithfulness assumption holds, bidirected edges will indicate the existence of latent variables, so a latent variable search like FCI should be run.
- See Also:
 
- 
searchRuns PC starting with a commplete graph over the given list of nodes, using the given independence test and knowledge and returns the resultant graph. The returned graph will be a CPDAG if the independence information is consistent with the hypothesis that there are no latent common causes. It may, however, contain cycles or bidirected edges if this assumption is not born out, either due to the actual presence of latent common causes, or due to statistical errors in conditional independence judgments.All the given nodes must be in the domatein of the given conditional independence test. - Parameters:
- nodes- The sublist of nodes to search over.
- Returns:
- The search graph.
- See Also:
 
- 
searchRuns the search using a particular implementation of the fast adjacency search (FAS), over the given sublist of nodes.- Parameters:
- fas- The fast adjacency search to use.
- nodes- The sublist of nodes.
- Returns:
- The result graph
- See Also:
 
- 
getElapsedTimepublic long getElapsedTime()Returns the elapsed time of the search, in milliseconds.- Returns:
- this time.
 
- 
getAdjacenciesReturns The edges of the searched graph.- Returns:
- This set.
 
- 
getNonadjacenciesReturns the non-adjacencies of the searched graph.- Returns:
- This set.
 
- 
getNumIndependenceTestspublic int getNumIndependenceTests()Returns the number of independence tests performed in the search.- Returns:
- This number.
 
- 
getNodesReturns the nodes of the search graph.- Returns:
- This list.
 
- 
setVerbosepublic void setVerbose(boolean verbose) Sets whether verbose output should be given.- Parameters:
- verbose- True iff the case.
 
- 
setStablepublic void setStable(boolean stable) Sets whether the stable adjacency search should be used.- Parameters:
- stable- True iff the case.
 
- 
setUseMaxPpublic void setUseMaxP(boolean useMaxP) Sets whether the max p method should be used in the adjacency searc h.- Parameters:
- useMaxP- iff the case.
 
- 
setMaxPPathLengthpublic void setMaxPPathLength(int maxPPathLength) Sets the maximum path length for the PC heuristic.- Parameters:
- maxPPathLength- this length.
 
 
-