Package edu.cmu.tetrad.search
Class MarkovCheck
java.lang.Object
edu.cmu.tetrad.search.MarkovCheck
Checks whether a graph is Markov given a data set. First, a list of m-separation predictions are made for each pair
of variables in the graph given the parents of one of the variables. One list (for Markov) is for where the
m-separation holds and another list (for dependency checks) where the m-separation does not hold. Then the
predictions are tested against the data set using the independence test. For the Markov test, since an independence
test yielding p-values should be Uniform under the null hypothesis, these p-values are tested for Uniformity using
the Kolmogorov-Smirnov test. Also, a fraction of dependent judgments is returned, which should equal the alpha level
of the independence test if the test is Uniform under the null hypothesis. For the Faithfulness test, the p-values
are tested for Uniformity using the Kolmogorov-Smirnov test; these should be dependent. Also, a fraction of dependent
judgments is returned.
Knowledge may be supplied to the Markov check. This knowledge is used to specify independence and conditioning ranges. For facts of the form X _||_ Y | Z, X and Y should be in the last tier of the knowledge, and Z should be in previous tiers. Additional forbidden or required edges are not allowed.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Stores the set of m-separation facts and the set of m-connection facts for a graph, for the global check.static final record
A single record for the results of the Markov check. -
Constructor Summary
ConstructorsConstructorDescriptionMarkovCheck
(Graph graph, IndependenceTest independenceTest, ConditioningSetType setType) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Generates all results, for both the Markov and dependency checks, for each node in the graph given the parents of that node.Returns the set of independence facts used in the Markov check, for dseparation and dconnection separately.double
getAndersonDarlingA2
(boolean indep) Returns the Anderson-Darling A^2 statistic for the given list of results.double
getAndersonDarlingA2Star
(boolean indep) Returns the Anderson-Darling A^2* statistic for the given list of results.double
getAndersonDarlingP
(boolean indep) Returns the Anderson-Darling p-value for the given list of results.double
getBinomialP
(boolean indep) Returns the Binomial p-value for the given list of results.Returns the nodes that are possible Z1,...,Zn for X _||_ Y | Z1,...,Zn.double
getFractionDependent
(boolean indep) Returns the fraction of dependent judgments for the given list of results.Returns the nodes that are possible X and Y for X _||_ Y | Z1,...,Zn.Returns the independence test being used.Returns the knowledge object for the Markov checker.double
getKsPValue
(boolean indep) Returns the Kolmorogov-Smirnov p-value for the given list of results.Generates the results for the given set of independence facts as a single record.Returns the Markov check record as a string.double
getMinBeta
(Node x, Node y) Calculates the minimum IDA beta value for a given causal relationship between two nodes.int
getNumTests
(boolean indep) Returns the number of tests for the given list of results.getPValues
(List<IndependenceResult> results) Returns the list of p-values for the given list of results.getResults
(boolean indep) After the generateResults method has been called, this method returns the results for the Markov or dependency check, depending on the value of the indep parameter.Returns type of conditioning sets to use in the Markov check.getVariable
(String name) Returns the variable with the given name.Returns the variables of the independence test.boolean
isCpdag()
Checks whether the given graph is a CPDAG (Completed Partially Directed Acyclic Graph).void
setKnowledge
(Knowledge knowledge) Sets the knowledge object for the Markov checker.void
setParallelized
(boolean parallelized) True if the checks should be parallelized.void
setPercentResample
(double percentResample) Sets the percentage of all samples to use when resampling for each conditional independence test.void
setSetType
(ConditioningSetType setType) Sets the type of conditioning sets to use in the Markov check.
-
Constructor Details
-
MarkovCheck
Constructor. Takes a graph and an independence test over the variables of the graph.- Parameters:
graph
- The graph.independenceTest
- The test over the variables of the graph.setType
- The type of conditioning sets to use in the Markov check.
-
-
Method Details
-
getAllSubsetsIndependenceFacts
Returns the set of independence facts used in the Markov check, for dseparation and dconnection separately.- Returns:
- The set of independence facts used in the Markov check, for dseparation and dconnection separately.
-
getMinBeta
Calculates the minimum IDA beta value for a given causal relationship between two nodes.- Parameters:
x
- the cause nodey
- the effect node- Returns:
- the minimum IDA beta value
- Throws:
IllegalArgumentException
- if the graph is not a CPDAG (partially directed acyclic graph)
-
getVariables
public List<Node> getVariables(List<Node> graphNodes, List<Node> independenceNodes, List<Node> conditioningNodes) Returns the variables of the independence test. -
generateResults
public void generateResults()Generates all results, for both the Markov and dependency checks, for each node in the graph given the parents of that node. These results are stored in the resultsIndep and resultsDep lists. This should be called before any of the result methods. Note that only results for X _||_ Y | Z1,...,Zn are generated, where X and Y are in the independenceNodes list and Z1,...,Zn are in the conditioningNodes list.- See Also:
-
getSetType
Returns type of conditioning sets to use in the Markov check.- Returns:
- The type of conditioning sets to use in the Markov check.
- See Also:
-
setSetType
Sets the type of conditioning sets to use in the Markov check.- Parameters:
setType
- The type of conditioning sets to use in the Markov check.- See Also:
-
setParallelized
public void setParallelized(boolean parallelized) True if the checks should be parallelized. (Not always a good idea.)- Parameters:
parallelized
- True if the checks should be parallelized.
-
getResults
After the generateResults method has been called, this method returns the results for the Markov or dependency check, depending on the value of the indep parameter.- Parameters:
indep
- True for the Markov results, false for the dependency results.- Returns:
- The results for the Markov or dependency check.
-
getPValues
Returns the list of p-values for the given list of results.- Parameters:
results
- The results.- Returns:
- Their p-values.
-
getFractionDependent
public double getFractionDependent(boolean indep) Returns the fraction of dependent judgments for the given list of results.- Parameters:
indep
- True for the Markov results, false for the dependency results.- Returns:
- The fraction of dependent judgments for this condition.
-
getKsPValue
public double getKsPValue(boolean indep) Returns the Kolmorogov-Smirnov p-value for the given list of results.- Parameters:
indep
- True for the Markov results, false for the dependency results.- Returns:
- The Kolmorogov-Smirnov p-value for this condition.
-
getAndersonDarlingA2
public double getAndersonDarlingA2(boolean indep) Returns the Anderson-Darling A^2 statistic for the given list of results.- Parameters:
indep
- True if for implied independencies, false if for implied dependencies.- Returns:
- The Anderson-Darling A^2 statistic for the given list of results.
-
getAndersonDarlingA2Star
public double getAndersonDarlingA2Star(boolean indep) Returns the Anderson-Darling A^2* statistic for the given list of results.- Parameters:
indep
- True if for implied independencies, false if for implied dependencies.- Returns:
- The Anderson-Darling A^2* statistic for the given list of results.
-
getAndersonDarlingP
public double getAndersonDarlingP(boolean indep) Returns the Anderson-Darling p-value for the given list of results.- Parameters:
indep
- True if for implied independencies, false if for implied dependencies.- Returns:
- The Anderson-Darling p-value for the given list of results.
-
getBinomialP
public double getBinomialP(boolean indep) Returns the Binomial p-value for the given list of results.- Parameters:
indep
- True if for implied independencies, false if for implied dependencies.- Returns:
- The Binomial p-value for the given list of results.
-
getNumTests
public int getNumTests(boolean indep) Returns the number of tests for the given list of results.- Parameters:
indep
- True if for implied independencies, false if for implied dependencies.- Returns:
- The number of tests for the given list of results.
-
getVariable
Returns the variable with the given name.- Parameters:
name
- The name of the variables.- Returns:
- The variable with the given name.
-
getIndependenceTest
Returns the independence test being used.- Returns:
- This test.
-
setPercentResample
public void setPercentResample(double percentResample) Sets the percentage of all samples to use when resampling for each conditional independence test.- Parameters:
percentResample
- The percentage of all samples to use when resampling for each conditional independence test.
-
getKnowledge
Returns the knowledge object for the Markov checker. This knowledge object should contain the tier knowledge for the Markov checker. The last tier contains the possible X and Y for X _||_ Y | Z1,...,Zn, and the previous tiers contain the possible Z1,...,Zn for X _||_ Y | Z1,...,Zn. Additional forbidden or required edges are ignored.- Returns:
- The knowledge object.
-
setKnowledge
Sets the knowledge object for the Markov checker. The knowledge object should contain the tier knowledge for the Markov checker. The last tier contains the possible X and Y for X _||_ Y | Z1,...,Zn, and the previous tiers contain the possible Z1,...,Zn for X _||_ Y | Z1,...,Zn. Additional forbidden or required edges are ignored.- Parameters:
knowledge
- The knowledge object.
-
getMarkovCheckRecord
Generates the results for the given set of independence facts as a single record.- Returns:
- The Markov check record.
- See Also:
-
getMarkovCheckRecordString
Returns the Markov check record as a string.- Returns:
- The Markov check record as a string.
- See Also:
-
getIndependenceNodes
Returns the nodes that are possible X and Y for X _||_ Y | Z1,...,Zn.- Returns:
- The nodes that are possible X and Y for X _||_ Y | Z1,...,Zn.
-
getConditioningNodes
Returns the nodes that are possible Z1,...,Zn for X _||_ Y | Z1,...,Zn.- Returns:
- The nodes that are possible Z1,...,Zn for X _||_ Y | Z1,...,Zn.
-
isCpdag
public boolean isCpdag()Checks whether the given graph is a CPDAG (Completed Partially Directed Acyclic Graph).- Returns:
- true if the graph is a CPDAG, false otherwise
-