Class IndTestChiSquare

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

public final class IndTestChiSquare extends Object implements IndependenceTest
Checks the conditional independence X _||_ Y | S, where S is a set of discrete variable, and X and Y are discrete variable not in S, by applying a conditional Chi Square test. A description of such a test is given in Fienberg, "The Analysis of Cross-Classified Categorical Data," 2nd edition. The formula for degrees of freedom used in this test are equivalent to the formulation on page 142 of Fienberg.
Author:
Joseph Ramsey
See Also:
  • Constructor Details

    • IndTestChiSquare

      public IndTestChiSquare(DataSet dataSet, double alpha)
      Constructs a new independence checker to check conditional independence facts for discrete data using a g square test.
      Parameters:
      dataSet - the discrete data set.
      alpha - the significance level of the tests.
  • Method Details

    • indTestSubset

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

      public double getXSquare()
      Returns:
      the G Square value.
    • getDf

      public int getDf()
      Returns:
      degrees of freedom associated with the most recent call of isIndependent
    • getPValue

      public double getPValue()
      Returns:
      the p value associated with the most recent call of isIndependent.
    • 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 varNames 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 varNames.
      Returns:
      true iff x _||_ y | z.
    • determines

      public boolean determines(List<Node> z, Node x1)
      Specified by:
      determines in interface IndependenceTest
      Parameters:
      z - The list of variables z1,...,zn with respect to which we want to know whether z determines x oir z.
      x1 - The one variable whose determination by z we want to know.
      Returns:
      true if it is estimated that z determines x or z determines y.
    • getAlpha

      public double getAlpha()
      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
      Parameters:
      alpha - the new significance level.
    • 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.
    • getVariableNames

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

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

      public String toString()
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
    • getData

      public DataSet getData()
      Specified by:
      getData in interface IndependenceTest
      Returns:
      The data model for the independence 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
    • getFacts

      public HashSet<IndependenceFact> getFacts()
    • isVerbose

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

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