Package edu.cmu.tetrad.search.test
Class IndTestFisherZ
java.lang.Object
edu.cmu.tetrad.search.test.IndTestFisherZ
- All Implemented Interfaces:
EffectiveSampleSizeSettable
,IndependenceTest
,RowsSettable
public final class IndTestFisherZ
extends Object
implements IndependenceTest, EffectiveSampleSizeSettable, RowsSettable
Checks conditional independence of variable in a continuous data set using Fisher's Z test. See Spirtes, Glymour, and
Scheines, "Causation, Prediction and Search," 2nd edition, page 94.
- Version:
- $Id: $Id
- Author:
- josephramsey, Frank Wimberly
-
Constructor Summary
ConstructorsConstructorDescriptionIndTestFisherZ
(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).IndTestFisherZ
(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.IndTestFisherZ
(Matrix data, List<Node> variables, double alpha) Constructs a new Fisher Z independence test with the listed arguments. -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence
(Node x, Node y, Set<Node> z) Determines whether variable x _||_ y | z given a list of conditioning variables z.boolean
determines
(List<Node> z, Node x) Determines if a given Node x is determined by a list of Nodes z.double
getAlpha()
Gets the model significance level.double
getBic()
Returns the BIC score for this test.getCov()
Returns the correlation matrix being analyzed.getData()
Returns the data set being analyzed.Returns the (singleton) list of datasets being analyzed.double
Returns the p-value for x _||_ y | z.getRows()
Returns the rows used in the test.int
Returns the sample size.getVariable
(String name) Returns the variable with the given name.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.indTestSubset
(List<Node> vars) Creates a new independence test instance for a subset of the variables.boolean
Returns true iff verbose output should be printed.void
setAlpha
(double alpha) Sets the significance level at which independence judgments should be made.void
setEffectiveSampleSize
(int effectiveSampleSize) Sets the sample size to use for the independence test, which may be different from the sample size of the data set or covariance matrix.void
Allows the user to set which rows are used in the test.void
setUsePseudoinverse
(boolean usePseudoinverse) Sets whether or not to use the pseudoinverse method for determining independence.void
setVariables
(List<Node> variables) Sets the variables to a new list of the same size.void
setVerbose
(boolean verbose) Sets whether verbose output should be printed.toString()
Returns a string representation of the Fisher Z independence test.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, getVariableNames
-
Constructor Details
-
IndTestFisherZ
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 containing only continuous columns.alpha
- The alpha level of the test.
-
IndTestFisherZ
Constructs a new Fisher Z independence test with the listed arguments.- Parameters:
data
- A 2D continuous data set with no missing values.variables
- A list of variables, a subset of the variables ofdata
.alpha
- The alpha level of the test.
-
IndTestFisherZ
Constructs a new independence test that will determine conditional independence facts using the given correlation matrix and the given significance level.- Parameters:
covMatrix
- The covariance matrix.alpha
- The alpha level of the test.
-
-
Method Details
-
indTestSubset
Creates a new independence test instance for a subset of the variables.- Specified by:
indTestSubset
in interfaceIndependenceTest
- Parameters:
vars
- The sublist of variables.- Returns:
- a
IndependenceTest
object - See Also:
-
checkIndependence
Determines whether variable x _||_ y | z given a list of conditioning variables z.- Specified by:
checkIndependence
in interfaceIndependenceTest
- Parameters:
x
- aNode
objecty
- aNode
objectz
- aSet
object- Returns:
- a
IndependenceResult
object - See Also:
-
getPValue
public double getPValue(Node x, Node y, Set<Node> z) throws org.apache.commons.math3.linear.SingularMatrixException Returns the p-value for x _||_ y | z.- Parameters:
x
- The first node.y
- The second node.z
- The set of conditioning variables.- Returns:
- The p-value.
- Throws:
org.apache.commons.math3.linear.SingularMatrixException
- If a singularity occurs when invering a matrix.
-
getBic
public double getBic()Returns the BIC score for this test.- Returns:
- The BIC score.
-
getAlpha
public double getAlpha()Gets the model significance level.- Specified by:
getAlpha
in interfaceIndependenceTest
- Returns:
- This alpha.
-
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 interfaceIndependenceTest
- Parameters:
alpha
- This level.
-
getVariables
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.- Specified by:
getVariables
in interfaceIndependenceTest
- Returns:
- This list.
-
setVariables
-
getVariable
Returns the variable with the given name.- Specified by:
getVariable
in interfaceIndependenceTest
- Parameters:
name
- aString
object- Returns:
- This variable.
-
getData
Returns the data set being analyzed.- Specified by:
getData
in interfaceIndependenceTest
- Returns:
- This data.
- See Also:
-
getCov
Returns the correlation matrix being analyzed.- Specified by:
getCov
in interfaceIndependenceTest
- Returns:
- This correlation matrix.
-
getDataSets
Returns the (singleton) list of datasets being analyzed.- Specified by:
getDataSets
in interfaceIndependenceTest
- Returns:
- these datasets.
-
getSampleSize
public int getSampleSize()Returns the sample size.- Specified by:
getSampleSize
in interfaceIndependenceTest
- Returns:
- This size.
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int effectiveSampleSize) Sets the sample size to use for the independence test, which may be different from the sample size of the data set or covariance matrix. If not set, the sample size of the data set or covariance matrix is used.- Specified by:
setEffectiveSampleSize
in interfaceEffectiveSampleSizeSettable
- Parameters:
effectiveSampleSize
- The sample size to use.
-
isVerbose
public boolean isVerbose()Returns true iff verbose output should be printed.- Specified by:
isVerbose
in interfaceIndependenceTest
- Returns:
- True, if so.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output should be printed.- Specified by:
setVerbose
in interfaceIndependenceTest
- Parameters:
verbose
- True, if so.
-
toString
Returns a string representation of the Fisher Z independence test. The string includes the value of alpha.- Specified by:
toString
in interfaceIndependenceTest
- Overrides:
toString
in classObject
- Returns:
- A string representing the Fisher Z independence test.
-
determines
Determines if a given Node x is determined by a list of Nodes z.- Parameters:
z
- the list of Nodesx
- the Node to check if it is determined- Returns:
- true if x is determined by z, false otherwise
- Throws:
UnsupportedOperationException
- if the operation is not supported
-
getRows
Returns the rows used in the test.- Specified by:
getRows
in interfaceRowsSettable
- Returns:
- The rows used in the test.
-
setRows
Allows the user to set which rows are used in the test. Otherwise, all rows are used, except those with missing values.- Specified by:
setRows
in interfaceRowsSettable
- Parameters:
rows
- The rows to use for the test. Can be null.
-
setUsePseudoinverse
public void setUsePseudoinverse(boolean usePseudoinverse) Sets whether or not to use the pseudoinverse method for determining independence.- Parameters:
usePseudoinverse
- true to use the pseudoinverse method, false otherwise.
-