Class IndTestFisherZ

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

public final class IndTestFisherZ extends Object implements IndependenceTest
Checks conditional independence of variable in a continuous data set using Fisher's Z test. See Spirtes, Glymour, and Scheines, "Causation, Prediction and Search," 2nd edition, page 94.
Author:
Joseph Ramsey, Frank Wimberly adapted IndTestCramerT for Fisher's Z
  • Constructor Details

    • IndTestFisherZ

      public IndTestFisherZ(DataSet dataSet, double alpha)
      Constructs a new Independence test which checks independence facts based on the correlation matrix implied by the given data set (must be continuous). The given significance level is used.
      Parameters:
      dataSet - A data set containing only continuous columns.
      alpha - The alpha level of the test.
    • IndTestFisherZ

      public IndTestFisherZ(Matrix data, List<Node> variables, double alpha)
      Constructs a new Fisher Z independence test with the listed arguments.
      Parameters:
      data - A 2D continuous data set with no missing values.
      variables - A list of variables, a subset of the variables of data.
      alpha - The significance cutoff level. p values less than alpha will be reported as dependent.
    • IndTestFisherZ

      public IndTestFisherZ(ICovarianceMatrix covMatrix, double alpha)
      Constructs a new independence test that will determine conditional independence facts using the given correlation matrix and the given significance level.
  • Method Details

    • indTestSubset

      public IndependenceTest indTestSubset(List<Node> vars)
      Creates a new independence test instance for a subset of the variables.
      Specified by:
      indTestSubset in interface IndependenceTest
      Returns:
      an Independence test for a subset of the variables.
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, List<Node> z)
      Determines whether variable x is independent of variable y given a list of conditioning variables z.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - the one variable being compared.
      y - the second variable being compared.
      z - the list of conditioning variables.
      Returns:
      true iff x _||_ y | z.
      Throws:
      RuntimeException - if a matrix singularity is encountered.
    • getPValue

      public double getPValue()
      Returns:
      the probability associated with the most recently computed independence test.
    • getPValue

      public double getPValue(Node x, Node y, List<Node> z) throws org.apache.commons.math3.linear.SingularMatrixException
      Throws:
      org.apache.commons.math3.linear.SingularMatrixException
    • getBic

      public double getBic()
    • getAlpha

      public double getAlpha()
      Gets the getModel significance level.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      the significance level of the independence test.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level at which independence judgments should be made. Affects the cutoff for partial correlations to be considered statistically equal to zero.
      Specified by:
      setAlpha in interface IndependenceTest
    • getVariables

      public List<Node> getVariables()
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      the list of variables over which this independence checker is capable of determinine independence relations-- that is, all the variables in the given graph or the given data set.
    • setVariables

      public void setVariables(List<Node> variables)
    • getVariable

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

      public List<String> getVariableNames()
      Specified by:
      getVariableNames in interface IndependenceTest
      Returns:
      the list of variable varNames.
    • determines

      public boolean determines(List<Node> z, Node x) throws UnsupportedOperationException
      If isDeterminismAllowed(), deters to IndTestFisherZD; otherwise throws UnsupportedOperationException.
      Specified by:
      determines in interface IndependenceTest
      Returns:
      true if y is determined the variable in z.
      Throws:
      UnsupportedOperationException
    • getData

      public DataSet getData()
      Specified by:
      getData in interface IndependenceTest
      Returns:
      the data set being analyzed.
    • toString

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

      public ICovarianceMatrix getCov()
      Specified by:
      getCov in interface IndependenceTest
    • getDataSets

      public List<DataSet> getDataSets()
      Specified by:
      getDataSets in interface IndependenceTest
    • getSampleSize

      public int getSampleSize()
      Specified by:
      getSampleSize in interface IndependenceTest
    • getCovMatrices

      public List<Matrix> getCovMatrices()
      Specified by:
      getCovMatrices in interface IndependenceTest
    • getScore

      public double getScore()
      Description copied from interface: IndependenceTest
      A score that is higher with more likely models.
      Specified by:
      getScore in interface IndependenceTest
    • isVerbose

      public boolean isVerbose()
      Specified by:
      isVerbose in interface IndependenceTest
    • setVerbose

      public void setVerbose(boolean verbose)
      Specified by:
      setVerbose in interface IndependenceTest