Class Kci

java.lang.Object
edu.cmu.tetrad.search.test.Kci
All Implemented Interfaces:
IndependenceTest

public class Kci extends Object implements 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 Details

    • Kci

      public Kci(DataSet data, double alpha)
      Constructor.
      Parameters:
      data - The dataset to analyse. Must be continuous.
      alpha - The alpha value of the test.
  • Method Details

    • indTestSubset

      public IndependenceTest indTestSubset(List<Node> vars)
      Description copied from interface: IndependenceTest
      Returns an Independence test for a sublist of the variables.
      Specified by:
      indTestSubset in interface IndependenceTest
      Parameters:
      vars - The sublist of variables.
      Throws:
      javax.help.UnsupportedOperationException - Method not implemented.
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> z)
      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 interface IndependenceTest
      Returns:
      The independence result.
      See Also:
    • getVariables

      public List<Node> getVariables()
      Returns the list of variables over which this independence checker is capable of determinining independence relations.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      This list.
    • getVariable

      public Node getVariable(String name)
      Returns the variable by the given name.
      Specified by:
      getVariable in interface IndependenceTest
      Returns:
      This variable.
    • determines

      public boolean determines(List<Node> z, Node y)
      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 interface IndependenceTest
      Returns:
      This alpha.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - This alpha.
    • toString

      public String toString()
      Returns a string representation of this test.
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
      Returns:
      This string.
    • getData

      public DataModel getData()
      Returns The data model for the independence test.
      Specified by:
      getData in interface IndependenceTest
      Returns:
      This data.
      See Also:
    • getCov

      public ICovarianceMatrix getCov()
      Description copied from interface: IndependenceTest
      Returns the covariance matrix.
      Specified by:
      getCov in interface IndependenceTest
      Returns:
      This matrix.
      Throws:
      UnsupportedOperationException - Method not implemented.
    • getDataSets

      public List<DataSet> getDataSets()
      Returns a list consisting of the dataset for this test.
      Specified by:
      getDataSets in interface IndependenceTest
      Returns:
      This dataset in a list.
    • getSampleSize

      public int getSampleSize()
      Returns the sample size.
      Specified by:
      getSampleSize in interface IndependenceTest
      Returns:
      This size.
    • getScore

      public double getScore(IndependenceResult result)
      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 interface IndependenceTest
      Returns:
      True, if so.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets whether verbose output is printed.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True, if so.