Package edu.cmu.tetrad.search.test
Class IndTestGSquare
java.lang.Object
edu.cmu.tetrad.search.test.IndTestGSquare
- All Implemented Interfaces:
IndependenceTest,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 are
equivalent to the formulation on page 142 of Fienberg.
- 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) Returns a judgment whether the variables in z determine x.doublegetAlpha()Gets the getModel significance level.getData()Returns the data.doubleReturns the p value associated with the most recent call of isIndependent.getRows()Returns the rows used 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) Creates a new IndTestGSquare for a sublist of the variables.booleanReturns True if verbose output is printed.voidsetAlpha(double alpha) Sets the significance level at which independence judgments should be made.voidsetDeterminationP(double determinationP) Sets the threshold for making judgments of determination.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 rows to use for the test.voidsetVerbose(boolean verbose) Sets whether verbose output is printed.toString()Returns a String representation of this test.Methods inherited from class java.lang.Object
clone, equals, finalize, 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
Creates a new IndTestGSquare for a sublist of the variables.- Specified by:
indTestSubsetin interfaceIndependenceTest- Parameters:
vars- This sublist.
-
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- the one variable being compared.y- the second variable being compared._z- the list of conditioning varNames.- Returns:
- True iff x _||_ y | z.
- See Also:
-
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- the new significance 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
Returns a judgment whether the variables in z determine x.- Specified by:
determinesin interfaceIndependenceTest- Parameters:
_z- The list of variables z1,...,zn with respect to which we want to know whether z determines x oir z.x- 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.
-
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.
- See Also:
-
isVerbose
public boolean isVerbose()Returns True if verbose output is printed.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- True, if so.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output is printed.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- True, if so.
-
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
Returns the rows used for the test. If null, all rows are used.- Specified by:
getRowsin interfaceRowsSettable- Returns:
- The rows used for the test. Can be null.
-
setRows
Sets the rows to use for the test. If null, all rows are used.- Specified by:
setRowsin interfaceRowsSettable- Parameters:
rows- The rows to use for the test. Can be null.
-