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.boolean
determines
(List<Node> z, Node y) Determines the independence between a set of nodes and a target node.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 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.boolean
Returns the value of the verbose flag.void
setAlpha
(double alpha) Sets the alpha level for the test.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 the verbosity of the method.void
setWidthMultiplier
(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, 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.- Returns:
- a
IndependenceTest
object - Throws:
UnsupportedOperationException
- since not implemneted.
-
checkIndependence
Checks the independence between two nodes given a set of conditioning variables.- Specified by:
checkIndependence
in 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:
getVariables
in interfaceIndependenceTest
- Returns:
- This list.
-
getVariable
Returns the variable of the given name.- Specified by:
getVariable
in interfaceIndependenceTest
- Parameters:
name
- aString
object 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:
getAlpha
in interfaceIndependenceTest
- Returns:
- This alpha.
-
setAlpha
public void setAlpha(double alpha) Sets the alpha level for the test.- Specified by:
setAlpha
in interfaceIndependenceTest
- Parameters:
alpha
- The alpha level to be set.
-
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
Returns the covariance matrix.- Specified by:
getCov
in interfaceIndependenceTest
- Returns:
- The covariance matrix.
-
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.- Parameters:
result
- aIndependenceResult
object- 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:
isVerbose
in interfaceIndependenceTest
- Returns:
- The value of the verbose flag.
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbosity of the method.- Specified by:
setVerbose
in interfaceIndependenceTest
- Parameters:
verbose
- True if verbosity is enabled, false otherwise.
-