Class GSquareTest

java.lang.Object
edu.cmu.tetrad.search.test.GSquareTest

public final class GSquareTest extends Object

Performs conditional independence tests of discrete data using the G Square method. Degrees of freedom are calculated as in Fienberg (2007), this reference:

Fienberg, S. E. (2007). The analysis of cross-classified categorical data. Springer Science & Business Media.

Author:
Frank Wimberly original version, josephramsey revision 10/01
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Stores the parameters of the result returned by the G Square test and its p-value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GSquareTest(DataSet dataSet, double alpha)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    calcGSquare(int[] testIndices)
    Calculates g square for a conditional crosstabulation table for independence question 0 _||_ 1 | 2, 3, ...max by summing up g square and degrees of freedom for each conditional table in turn, where rows or columns that consist entirely of zeros have been removed.
    double
     
    Returns the cell table for this test.
    Returns the dataset used for this test.
    int[]
    Returns the dimensions of the variables, in order.
    boolean
    isDetermined(int[] testIndices, double p)
    Returns a judgement of whether the variables index by 'testIndices' determine the variable index by 'p'.
    void
    setAlpha(double alpha)
    Sets the significance level to be used for tests.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GSquareTest

      public GSquareTest(DataSet dataSet, double alpha)
      Constructor
      Parameters:
      dataSet - The discrete dataset for which test results are requested.
      alpha - The alpha sigificance level cutoff.
  • Method Details

    • calcGSquare

      public GSquareTest.Result calcGSquare(int[] testIndices)
      Calculates g square for a conditional crosstabulation table for independence question 0 _||_ 1 | 2, 3, ...max by summing up g square and degrees of freedom for each conditional table in turn, where rows or columns that consist entirely of zeros have been removed.
      Parameters:
      testIndices - The indices of the test result needed, in order. So for the above, [0 1 2 3...max].
      Returns:
      the test result.
      See Also:
    • getDims

      public int[] getDims()
      Returns the dimensions of the variables, in order.
      Returns:
      These dimensions, as an int[] array. For instance, if the array is [2 3], then the first variable has 2 categories and second variable has 3 categories.
    • getCellTable

      public CellTable getCellTable()
      Returns the cell table for this test.
      Returns:
      This table.
      See Also:
    • getAlpha

      public double getAlpha()
      Returns:
      the getModel significance level being used for tests.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level to be used for tests.
      Parameters:
      alpha - The alpha significance level of the test.
    • getDataSet

      public DataSet getDataSet()
      Returns the dataset used for this test.
      Returns:
      This dataset.
    • isDetermined

      public boolean isDetermined(int[] testIndices, double p)
      Returns a judgement of whether the variables index by 'testIndices' determine the variable index by 'p'.
      Parameters:
      testIndices - The indices of the conditioning variables.
      p - The index of the child variable.
      Returns:
      True if the conditioning variables determine the child variable.