Package edu.cmu.tetrad.search.test
Class Kci
java.lang.Object
edu.cmu.tetrad.search.test.Kci
- All Implemented Interfaces:
IndependenceTest
Gives an implementation of the Kernal Independence Test (KCI) by Kun Zhang, which is a general test of conditional
independence. The reference is here:
Zhang, K., Peters, J., Janzing, D., and Schölkopf, B. (2012). Kernel-based conditional independence test and application in causal discovery. arXiv preprint arXiv:1202.3775.
Please see that paper, especially Theorem 4 and Proposition 5.
Using optimal kernel bandwidths suggested by Bowman and Azzalini (1997):
Bowman, A. W., and Azzalini, A. (1997). Applied smoothing techniques for data analysis: the kernel approach with S-Plus illustrations (Vol. 18). OUP Oxford.
- Version:
- $Id: $Id
- Author:
- kunzhang, Vineet Raghu on 7/3/2016, josephramsey refactoring 7/4/2018
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence(Node x, Node y, Set<Node> z) Checks the independence between two nodes given a set of conditioning variables.booleandetermines(List<Node> z, Node y) Determines the independence between a set of nodes and a target node.doublegetAlpha()Returns the significance level of the independence test.getCov()Returns the covariance matrix.getData()Returns The data model for the independence test.Returns a list consisting of the dataset for this test.intReturns the sample size.doublegetScore(IndependenceResult result) Returns alpha - p.getVariable(String name) Returns the variable of the given name.Returns the list of variables over which this independence checker is capable of determinining independence relations.indTestSubset(List<Node> vars) Returns an Independence test for a sublist of the variables.booleanReturns the value of the verbose flag.voidsetAlpha(double alpha) Sets the alpha level for the test.voidsetApproximate(boolean approximate) Sets whether the approximate algorithm should be used.voidsetEpsilon(double epsilon) Sets the epsilon.voidsetNumBootstraps(int numBootstraps) Sets the number of bootstraps to do.voidsetThreshold(double threshold) Sets the threshold.voidsetVerbose(boolean verbose) Sets the verbosity of the method.voidsetWidthMultiplier(double widthMultiplier) Sets the width multiplier.toString()Returns a string representation of this test.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.cmu.tetrad.search.IndependenceTest
checkIndependence, determines, getVariableNames
-
Constructor Details
-
Kci
Constructor.- Parameters:
data- The dataset to analyse. Must be continuous.alpha- The alpha value of the test.
-
-
Method Details
-
indTestSubset
Description copied from interface:IndependenceTestReturns an Independence test for a sublist of the variables.- Specified by:
indTestSubsetin interfaceIndependenceTest- Parameters:
vars- The sublist of variables.- Returns:
- a
IndependenceTestobject - Throws:
UnsupportedOperationException- since not implemneted.
-
checkIndependence
Checks the independence between two nodes given a set of conditioning variables.- Specified by:
checkIndependencein interfaceIndependenceTest- Parameters:
x- The first node.y- The second node.z- The set of conditioning variables.- Returns:
- The result of the independence test.
- See Also:
-
getVariables
Returns the list of variables over which this independence checker is capable of determinining independence relations.- Specified by:
getVariablesin interfaceIndependenceTest- Returns:
- This list.
-
getVariable
Returns the variable of the given name.- Specified by:
getVariablein interfaceIndependenceTest- Parameters:
name- aStringobject representing the name of the variable to retrieve- Returns:
- the Node object representing the variable with the given name
-
determines
Determines the independence between a set of nodes and a target node.- Parameters:
z- The set of nodes representing the conditioning variables.y- The target node.- Returns:
- True if the conditioning variables z are independent of the target node y, false otherwise.
-
getAlpha
public double getAlpha()Returns the significance level of the independence test.- Specified by:
getAlphain interfaceIndependenceTest- Returns:
- This alpha.
-
setAlpha
public void setAlpha(double alpha) Sets the alpha level for the test.- Specified by:
setAlphain interfaceIndependenceTest- Parameters:
alpha- The alpha level to be set.
-
toString
Returns a string representation of this test.- Specified by:
toStringin interfaceIndependenceTest- Overrides:
toStringin classObject- Returns:
- This string.
-
getData
Returns The data model for the independence test.- Specified by:
getDatain interfaceIndependenceTest- Returns:
- This data.
- See Also:
-
getCov
Returns the covariance matrix.- Specified by:
getCovin interfaceIndependenceTest- Returns:
- The covariance matrix.
-
getDataSets
Returns a list consisting of the dataset for this test.- Specified by:
getDataSetsin interfaceIndependenceTest- Returns:
- This dataset in a list.
-
getSampleSize
public int getSampleSize()Returns the sample size.- Specified by:
getSampleSizein interfaceIndependenceTest- Returns:
- This size.
-
getScore
Returns alpha - p.- Parameters:
result- aIndependenceResultobject- Returns:
- This number.
-
setApproximate
public void setApproximate(boolean approximate) Sets whether the approximate algorithm should be used.- Parameters:
approximate- True, if so.
-
setWidthMultiplier
public void setWidthMultiplier(double widthMultiplier) Sets the width multiplier.- Parameters:
widthMultiplier- This multipler.
-
setNumBootstraps
public void setNumBootstraps(int numBootstraps) Sets the number of bootstraps to do.- Parameters:
numBootstraps- This number.
-
setThreshold
public void setThreshold(double threshold) Sets the threshold.- Parameters:
threshold- This number.
-
setEpsilon
public void setEpsilon(double epsilon) Sets the epsilon.- Parameters:
epsilon- This number.
-
isVerbose
public boolean isVerbose()Returns the value of the verbose flag.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- The value of the verbose flag.
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbosity of the method.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- True if verbosity is enabled, false otherwise.
-