Class IndTestCramerT

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

public final class IndTestCramerT extends Object implements IndependenceTest
Checks conditional independence for continuous variables using Cramer's T-test formula (Cramer, Mathematical Methods of Statistics (1951), page 413).
Version:
$Id: $Id
Author:
josephramsey
  • Constructor Details

    • IndTestCramerT

      public IndTestCramerT(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 with all continuous columns.
      alpha - the alpha level of the test.
    • IndTestCramerT

      public IndTestCramerT(CorrelationMatrix covMatrix, double alpha)
      Constructs a new independence test that will determine conditional independence facts using the given correlation matrix and the given significance level.
      Parameters:
      covMatrix - a CorrelationMatrix object
      alpha - a double
    • IndTestCramerT

      public IndTestCramerT(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.
      Parameters:
      covMatrix - a ICovarianceMatrix object
      alpha - a double
  • Method Details

    • indTestSubset

      public IndependenceTest indTestSubset(List<Node> vars)
      This method performs an independence test based on a given sublist of variables.
      Specified by:
      indTestSubset in interface IndependenceTest
      Parameters:
      vars - The sublist of variables to perform the independence test on.
      Returns:
      An IndependenceTest object representing the results of the test.
      Throws:
      IllegalArgumentException - If the sublist of variables is empty or contains variables that are not original variables.
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> _z)
      Checks the independence between two nodes given a set of conditioning nodes.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - The first node.
      y - The second node.
      _z - The set of conditioning nodes.
      Returns:
      The result of the independence check.
      Throws:
      NullPointerException - If _z is null or contains null elements.
      IllegalArgumentException - If the submatrix contains missing values.
      RuntimeException - If the submatrix is singular or the p-value is undefined.
      See Also:
    • getPValue

      public double getPValue()
      Calculates the p-value for the independence test. The p-value is calculated by integrating the probability density function (pdf) over the range of storedR (absolute value) to 1.0 with 100 intervals, and then multiplying the result by 2.0.
      Returns:
      the p-value for the independence test.
    • getAlpha

      public double getAlpha()

      Getter for the field alpha.

      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      the getModel significance level.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level for the independence test.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - The significance level, must be between 0.0 and 1.0 (inclusive).
      Throws:
      IllegalArgumentException - If the significance level is out of range.
    • getVariables

      public List<Node> getVariables()
      Retrieves the list of variables used in the independence test.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      A list of Node objects representing the variables used in the test.
    • determines

      public boolean determines(List<Node> z, Node x) throws UnsupportedOperationException
      Determines whether the given variables are conditionally independent.
      Parameters:
      z - The set of conditioning nodes.
      x - The target node.
      Returns:
      true if the variables are conditionally independent, false otherwise.
      Throws:
      UnsupportedOperationException - If a matrix operation fails.
    • getData

      public DataSet getData()
      Retrieves the dataset used in the independence test.
      Specified by:
      getData in interface IndependenceTest
      Returns:
      The dataset used in the independence test.
      See Also:
    • toString

      public String toString()
      Returns a string representation of the object.
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
      Returns:
      A string representation of the object.
    • isVerbose

      public boolean isVerbose()
      Determines if verbose output is enabled or disabled.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      true if verbose output is enabled, false otherwise.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbose flag to determine if verbose output should be enabled or disabled.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True if the verbose output should be enabled, false otherwise.