Package edu.cmu.tetrad.search.test
Class IndTestBasisFunctionBlocks
java.lang.Object
edu.cmu.tetrad.search.test.IndTestBasisFunctionBlocks
- All Implemented Interfaces:
RawMarginalIndependenceTest,IndependenceTest,EffectiveSampleSizeSettable
public class IndTestBasisFunctionBlocks
extends Object
implements IndependenceTest, RawMarginalIndependenceTest, EffectiveSampleSizeSettable
IndTestBasisFunctionBlocks - Builds a per-variable truncated basis expansion (via Embedding) - Constructs the blocks
mapping (original var -> list of embedded column indices) - Delegates CI testing to IndTestBlocks over those blocks
CONTRACT: 'blocks' maps each ORIGINAL variable index v (0..V-1) to the list of embedded column indices in the embedded matrix produced here.
-
Constructor Summary
ConstructorsConstructorDescriptionIndTestBasisFunctionBlocks(DataSet raw, int degree, int basisType) Constructs an instance of IndTestBasisFunctionBlocks. -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence(Node x, Node y, Set<Node> z) Checks for statistical independence between two given variables (nodes), conditioned on a set of other variables.doublecomputePValue(double[] x, double[] y) Computes the p-value for the statistical test of marginal independence between the two given variables represented by the input arrays.doublecomputePValue(double[] x, double[][] Y) Default multivariate fallback: run BFIT on each column of Y and combine with Fisher.doublegetAlpha()Retrieves the alpha value currently set for this instance.Retrieves the list of blocks, where each block is represented as a list of integers.getData()Retrieves the original dataset represented by this instance.intReturns the effective sample size.org.ejml.simple.SimpleMatrixRetrieves the embedded data matrix corresponding to the transformed or processed data based on the configuration of this instance.Retrieves the list of nodes (variables) associated with this instance.booleanIndicates whether this instance is operating in verbose mode.voidsetAlpha(double alpha) Sets the alpha value used as a threshold or parameter for statistical tests or computations.voidsetEffectiveSampleSize(int nEff) Sets the effective sample size, or -1 if the actual sample size should be used.voidsetVerbose(boolean verbose) Sets the verbosity mode for this instance.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.cmu.tetrad.search.test.IndependenceTest
checkIndependence, determines, getCov, getDataSets, getSampleSize, getVariable, getVariableNames, indTestSubset, toString
-
Constructor Details
-
IndTestBasisFunctionBlocks
Constructs an instance of IndTestBasisFunctionBlocks. This class is designed to perform independence tests based on basis function transformations of the provided dataset, using specified degree and basis type.- Parameters:
raw- the input dataset, which provides the raw data to be analyzed. Cannot be null.degree- the degree of the basis function transformation. Must be a non-negative integer.basisType- the type of basis functions to use for transformations (e.g., polynomial, Fourier, etc.). This value determines the embedding style and configuration specifics.- Throws:
IllegalArgumentException- if the raw dataset is null or if the degree is negative.
-
-
Method Details
-
checkIndependence
Checks for statistical independence between two given variables (nodes), conditioned on a set of other variables.- Specified by:
checkIndependencein interfaceIndependenceTest- Parameters:
x- the first variable (node) to test for independencey- the second variable (node) to test for independencez- the set of conditioning variables (nodes) for the independence test- Returns:
- an IndependenceResult containing details about the test result, including whether the variables are independent, the p-value, and the significance level used
-
getVariables
Retrieves the list of nodes (variables) associated with this instance. The nodes returned are exactly the ones used internally by the delegate, ensuring identity consistency and preventing "unknown node" issues.- Specified by:
getVariablesin interfaceIndependenceTest- Returns:
- a list of nodes representing the variables
-
getData
Retrieves the original dataset represented by this instance.- Specified by:
getDatain interfaceIndependenceTest- Returns:
- the underlying data as a
DataModelobject
-
isVerbose
public boolean isVerbose()Indicates whether this instance is operating in verbose mode. Verbose mode allows for detailed output or logging to assist in debugging or monitoring execution.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- true if verbose mode is enabled; false otherwise
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbosity mode for this instance. Enabling verbosity allows for more detailed output or logging during execution.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- true to enable verbose output, false to disable it
-
computePValue
Description copied from interface:RawMarginalIndependenceTestComputes the p-value for the statistical test of marginal independence between the two given variables represented by the input arrays.- Specified by:
computePValuein interfaceRawMarginalIndependenceTest- Parameters:
x- the first variable, represented as an array of doublesy- the second variable, represented as an array of doubles- Returns:
- the computed p-value for the test of marginal independence
- Throws:
InterruptedException- if the computation is interrupted
-
computePValue
Default multivariate fallback: run BFIT on each column of Y and combine with Fisher. If you later add a true multivariate BFIT, override this to call it directly.- Specified by:
computePValuein interfaceRawMarginalIndependenceTest- Parameters:
x- the first variable (scalar), represented as an array of doubles of length nY- the multivariate variable, represented as a 2D array of shape [n][m] (n samples, m variables)- Returns:
- the computed p-value for the test of independence
- Throws:
InterruptedException- if the computation is interrupted
-
getAlpha
public double getAlpha()Retrieves the alpha value currently set for this instance. The alpha value is typically used as a threshold or parameter in statistical tests or computations.- Specified by:
getAlphain interfaceIndependenceTest- Returns:
- the alpha value, which is a double strictly between 0 and 1
-
setAlpha
public void setAlpha(double alpha) Sets the alpha value used as a threshold or parameter for statistical tests or computations. The alpha value must be within the range (0, 1), exclusive.- Specified by:
setAlphain interfaceIndependenceTest- Parameters:
alpha- the desired alpha value, strictly between 0 and 1- Throws:
IllegalArgumentException- if alpha is less than or equal to 0 or greater than or equal to 1
-
getBlocks
Retrieves the list of blocks, where each block is represented as a list of integers. These blocks may correspond to partitions or groupings derived from the data or configuration.- Returns:
- a list of blocks, with each block being a list of integers
-
getEmbeddedData
public org.ejml.simple.SimpleMatrix getEmbeddedData()Retrieves the embedded data matrix corresponding to the transformed or processed data based on the configuration of this instance.- Returns:
- the embedded data matrix as a SimpleMatrix object
-
getEffectiveSampleSize
public int getEffectiveSampleSize()Description copied from interface:EffectiveSampleSizeSettableReturns the effective sample size.- Specified by:
getEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Returns:
- the effective sample size
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int nEff) Description copied from interface:EffectiveSampleSizeSettableSets the effective sample size, or -1 if the actual sample size should be used.- Specified by:
setEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Parameters:
nEff- the effective sample size
-