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.
- 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) Returns True if the given independence question is judged true, false if not.booleandetermines(List<Node> z, Node y) Returns true if y is determined the variable in z.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 by 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 true if verbose output is printed.voidsetAlpha(double alpha) Sets the significance level.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 whether verbose output is printed.voidsetWidthMultiplier(double widthMultiplier) Sets the width multiplier.toString()Returns a string representation of this test.Methods inherited from class java.lang.Object
clone, equals, finalize, 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.- Throws:
javax.help.UnsupportedOperationException- Method not implemented.
-
checkIndependence
Returns True if the given independence question is judged true, false if not. The independence question is of the form x _||_ y | z, z = [z1,...,zn], where x, y, z1,...,zn are variables in the list returned by getVariableNames().- Specified by:
checkIndependencein interfaceIndependenceTest- Returns:
- The independence result.
- 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 by the given name.- Specified by:
getVariablein interfaceIndependenceTest- Returns:
- This variable.
-
determines
Returns true if y is determined the variable in z.- Returns:
- True, if so.
-
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 significance level.- Specified by:
setAlphain interfaceIndependenceTest- Parameters:
alpha- This alpha.
-
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
Description copied from interface:IndependenceTestReturns the covariance matrix.- Specified by:
getCovin interfaceIndependenceTest- Returns:
- This matrix.
- Throws:
UnsupportedOperationException- Method not implemented.
-
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.- 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 true if verbose output is printed.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- True, if so.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output is printed.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- True, if so.
-