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.boolean
determines
(List<Node> z, Node y) Returns true if y is determined the variable in z.double
getAlpha()
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.int
Returns the sample size.double
getScore
(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.boolean
Returns true if verbose output is printed.void
setAlpha
(double alpha) Sets the significance level.void
setApproximate
(boolean approximate) Sets whether the approximate algorithm should be used.void
setEpsilon
(double epsilon) Sets the epsilon.void
setNumBootstraps
(int numBootstraps) Sets the number of bootstraps to do.void
setThreshold
(double threshold) Sets the threshold.void
setVerbose
(boolean verbose) Sets whether verbose output is printed.void
setWidthMultiplier
(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, wait
Methods 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:IndependenceTest
Returns an Independence test for a sublist of the variables.- Specified by:
indTestSubset
in 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:
checkIndependence
in 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:
getVariables
in interfaceIndependenceTest
- Returns:
- This list.
-
getVariable
Returns the variable by the given name.- Specified by:
getVariable
in 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:
getAlpha
in interfaceIndependenceTest
- Returns:
- This alpha.
-
setAlpha
public void setAlpha(double alpha) Sets the significance level.- Specified by:
setAlpha
in interfaceIndependenceTest
- Parameters:
alpha
- This alpha.
-
toString
Returns a string representation of this test.- Specified by:
toString
in interfaceIndependenceTest
- Overrides:
toString
in classObject
- Returns:
- This string.
-
getData
Returns The data model for the independence test.- Specified by:
getData
in interfaceIndependenceTest
- Returns:
- This data.
- See Also:
-
getCov
Description copied from interface:IndependenceTest
Returns the covariance matrix.- Specified by:
getCov
in interfaceIndependenceTest
- Returns:
- This matrix.
- Throws:
UnsupportedOperationException
- Method not implemented.
-
getDataSets
Returns a list consisting of the dataset for this test.- Specified by:
getDataSets
in interfaceIndependenceTest
- Returns:
- This dataset in a list.
-
getSampleSize
public int getSampleSize()Returns the sample size.- Specified by:
getSampleSize
in 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:
isVerbose
in interfaceIndependenceTest
- Returns:
- True, if so.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output is printed.- Specified by:
setVerbose
in interfaceIndependenceTest
- Parameters:
verbose
- True, if so.
-