Class IndTestCramerT
java.lang.Object
edu.cmu.tetrad.search.work_in_progress.IndTestCramerT
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionIndTestCramerT
(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.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).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. -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence
(Node x, Node y, Set<Node> _z) Checks the independence between two nodes given a set of conditioning nodes.boolean
determines
(List<Node> z, Node x) Determines whether the given variables are conditionally independent.double
getAlpha()
Getter for the fieldalpha
.getData()
Retrieves the dataset used in the independence test.double
Calculates the p-value for the independence test.Retrieves the list of variables used in the independence test.indTestSubset
(List<Node> vars) This method performs an independence test based on a given sublist of variables.boolean
Determines if verbose output is enabled or disabled.void
setAlpha
(double alpha) Sets the significance level for the independence test.void
setVerbose
(boolean verbose) Sets the verbose flag to determine if verbose output should be enabled or disabled.toString()
Returns a string representation of the object.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.cmu.tetrad.search.IndependenceTest
checkIndependence, determines, getCov, getDataSets, getSampleSize, getVariable, getVariableNames
-
Constructor Details
-
IndTestCramerT
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
Constructs a new independence test that will determine conditional independence facts using the given correlation matrix and the given significance level.- Parameters:
covMatrix
- aCorrelationMatrix
objectalpha
- a double
-
IndTestCramerT
Constructs a new independence test that will determine conditional independence facts using the given correlation matrix and the given significance level.- Parameters:
covMatrix
- aICovarianceMatrix
objectalpha
- a double
-
-
Method Details
-
indTestSubset
This method performs an independence test based on a given sublist of variables.- Specified by:
indTestSubset
in interfaceIndependenceTest
- 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
Checks the independence between two nodes given a set of conditioning nodes.- Specified by:
checkIndependence
in interfaceIndependenceTest
- 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 interfaceIndependenceTest
- Returns:
- the getModel significance level.
-
setAlpha
public void setAlpha(double alpha) Sets the significance level for the independence test.- Specified by:
setAlpha
in interfaceIndependenceTest
- 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
Retrieves the list of variables used in the independence test.- Specified by:
getVariables
in interfaceIndependenceTest
- Returns:
- A list of Node objects representing the variables used in the test.
-
determines
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
Retrieves the dataset used in the independence test.- Specified by:
getData
in interfaceIndependenceTest
- Returns:
- The dataset used in the independence test.
- See Also:
-
toString
Returns a string representation of the object.- Specified by:
toString
in interfaceIndependenceTest
- Overrides:
toString
in classObject
- Returns:
- A string representation of the object.
-
isVerbose
public boolean isVerbose()Determines if verbose output is enabled or disabled.- Specified by:
isVerbose
in interfaceIndependenceTest
- 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 interfaceIndependenceTest
- Parameters:
verbose
- True if the verbose output should be enabled, false otherwise.
-