Package edu.cmu.tetrad.search.test
Class IndTestGSquare
java.lang.Object
edu.cmu.tetrad.search.test.IndTestGSquare
- All Implemented Interfaces:
EffectiveSampleSizeSettable,IndependenceTest,RowsSettable
public final class IndTestGSquare
extends Object
implements IndependenceTest, EffectiveSampleSizeSettable, RowsSettable
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 G 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 is
equivalent to the formulation on page 142 of Fienberg.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIndTestGSquare(DataSet dataSet, double alpha) Constructs a new independence checker to check conditional independence facts for discrete data using a g square test. -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence(Node x, Node y, Set<Node> _z) Determines whether variable x is independent of variable y given a list of conditioning varNames z.booleandetermines(Set<Node> _z, Node x) Determines whether variable x is independent of a set of variables _z.doublegetAlpha()Gets the getModel significance level.getData()Returns the data.doubleReturns the p value associated with the most recent call of isIndependent.getRows()Retrieves the list of rows to use for the test.Return the list of variables over which this independence checker is capable of determining independence relations-- that is, all the variables in the given graph or the given data set.indTestSubset(List<Node> vars) Performs an independence test on a subset of variables.booleanReturns whether verbose output is enabled or not.voidsetAlpha(double alpha) Sets the significance level at which independence judgments should be made.voidsetCellTableType(ChiSquareTest.CellTableType cellTableType) Sets the cell table type.voidsetDeterminationP(double determinationP) Sets the threshold for making judgments of determination.voidsetEffectiveSampleSize(int sampleSize) Sets the sample size if the sample size of the data or covariance matrix is not the sample size that the test should use.voidsetMinCountPerCell(double minCountPerCell) The minimum number of counts per conditional table for chi-square for that table and its degrees of freedom to be included in the overall chi-square and degrees of freedom.voidSets the list of rows to use for the test.voidsetVerbose(boolean verbose) Sets the verbose flag to enable or disable verbose output.toString()Returns a String representation of this test.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.cmu.tetrad.search.IndependenceTest
checkIndependence, getCov, getDataSets, getSampleSize, getVariable, getVariableNames
-
Constructor Details
-
IndTestGSquare
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
Performs an independence test on a subset of variables.- Specified by:
indTestSubsetin interfaceIndependenceTest- Parameters:
vars- the subset of variables to perform the test on- Returns:
- the result of the independence test for the subset of variables
- Throws:
IllegalArgumentException- if the subset of variables is empty
-
getPValue
public double getPValue()Returns the p value associated with the most recent call of isIndependent.- Returns:
- This p-value.
-
checkIndependence
Determines whether variable x is independent of variable y given a list of conditioning varNames z.- Specified by:
checkIndependencein interfaceIndependenceTest- Parameters:
x- aNodeobjecty- aNodeobject_z- aSetobject- Returns:
- a
IndependenceResultobject
-
getAlpha
public double getAlpha()Gets the getModel significance level.- Specified by:
getAlphain interfaceIndependenceTest- Returns:
- this number.
-
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:
setAlphain interfaceIndependenceTest- Parameters:
alpha- This level.
-
getVariables
Return the list of variables over which this independence checker is capable of determining independence relations-- that is, all the variables in the given graph or the given data set.- Specified by:
getVariablesin interfaceIndependenceTest- Returns:
- This list.
-
toString
Returns a String representation of this test.- Specified by:
toStringin interfaceIndependenceTest- Overrides:
toStringin classObject- Returns:
- This string.
-
determines
Determines whether variable x is independent of a set of variables _z.- Specified by:
determinesin interfaceIndependenceTest- Parameters:
_z- a set of variables to condition onx- the variable to check for independence- Returns:
- true if variable x is independent of _z, false otherwise
- Throws:
NullPointerException- if _z or any element in _z is nullIllegalArgumentException- if any variable in _z or x was not used in the constructor
-
setDeterminationP
public void setDeterminationP(double determinationP) Sets the threshold for making judgments of determination.- Parameters:
determinationP- This threshold.
-
getData
Returns the data.- Specified by:
getDatain interfaceIndependenceTest- Returns:
- This data.
-
isVerbose
public boolean isVerbose()Returns whether verbose output is enabled or not.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- true if verbose output is enabled, false otherwise
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbose flag to enable or disable verbose output.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- true to enable verbose output, false to disable it.
-
setMinCountPerCell
public void setMinCountPerCell(double minCountPerCell) The minimum number of counts per conditional table for chi-square for that table and its degrees of freedom to be included in the overall chi-square and degrees of freedom. Note that this should not be too small, or the chi-square distribution will not be a good approximation to the distribution of the test statistic.- Parameters:
minCountPerCell- The minimum number of counts per conditional table. The default is 1; this must be >= 0.
-
getRows
Retrieves the list of rows to use for the test.- Specified by:
getRowsin interfaceRowsSettable- Returns:
- The list of rows to use for the test.
-
setRows
Sets the list of rows to use for the test.- Specified by:
setRowsin interfaceRowsSettable- Parameters:
rows- The list of rows to use for the test.- Throws:
IllegalArgumentException- if any of the rows are out of bounds
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int sampleSize) Sets the sample size if the sample size of the data or covariance matrix is not the sample size that the test should use.- Specified by:
setEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Parameters:
sampleSize- The sample size to use.
-
setCellTableType
Sets the cell table type.- Parameters:
cellTableType- The cell table type.
-