Package edu.cmu.tetrad.search.test
Class IndTestBlocksTs
java.lang.Object
edu.cmu.tetrad.search.test.IndTestBlocksTs
- All Implemented Interfaces:
BlockTest,IndependenceTest,EffectiveSampleSizeSettable
public class IndTestBlocksTs
extends Object
implements IndependenceTest, EffectiveSampleSizeSettable, BlockTest
Trek-separation block-level CI test (IndTestBlocksTs):
Given blocks X, Y, and conditioning blocks Z1..Zk that correspond to latent factors [X], [Y], [Z1]..[Zk], split each Zi into two nearly-equal parts ZiA, ZiB. Form L = X ⪠Z1A ⪠... ⪠ZkA, R = Y ⪠Z1B ⪠... ⪠ZkB and estimate rank(Σ_{L,R}). Under linear measurement models with n conditioning latents, independence suggests rank(Σ_{L,R}) ⤠2k.
Drop-in replacement matching the public surface of IndTestBlocksLemma10 (no p-values exposed).
This class is an elaboration of the IndTestTrekSep class of Adam Brodie and Peter Spirtes.
- Author:
- Adam Brodie, josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIndTestBlocksTs(BlockSpec blockSpec) Constructs an instance of IndTestBlocksTs using the provided block specification. -
Method Summary
Modifier and TypeMethodDescriptioncheckIndependence(Node x, Node y, Set<Node> z) Evaluates whether two nodes (variables) are independent given a set of conditioning nodes using a block-based conditional independence test.doublegetAlpha()Retrieves the significance level (alpha) for the independence test.Retrieves the block specification associated with this instance.getData()Retrieves the data model associated with the current block specification.intRetrieves the effective sample size for the independence test.Retrieves the list of variable nodes associated with this instance.booleanIndicates whether verbose mode is enabled.voidsetAlpha(double alpha) Sets the significance level (alpha) for the independence test.voidsetEffectiveSampleSize(int effectiveSampleSize) Sets the effective sample size for the independence test.voidsetLeftGetsSmallerHalfWhenOdd(boolean flag) If true and |Zi| is odd, left gets floor(|Zi|/2); otherwise left gets ceil(|Zi|/2).voidsetNumTrials(int t) Sets the number of trials for the independence test.voidsetRandomizeSplits(boolean randomize, long seed) Sets whether to randomize the splits and specifies a seed for randomization.voidsetVerbose(boolean verbose) Sets the verbose 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
-
IndTestBlocksTs
Constructs an instance of IndTestBlocksTs using the provided block specification. Validates the input and initializes various internal properties required for the block-based independence test, including correlation matrix computation, variable mapping, and block configuration. Throws an exception if invalid configurations are detected.- Parameters:
blockSpec- the block specification used for setting up the test. Contains information about the data set, variables, and blocks. Must not be null.- Throws:
IllegalArgumentException- if blockSpec is null or contains invalid configurations such as duplicate nodes, null variables, or invalid block column references.
-
-
Method Details
-
getVariables
Retrieves the list of variable nodes associated with this instance.- Specified by:
getVariablesin interfaceIndependenceTest- Returns:
- a new list containing the variable nodes.
-
getData
Retrieves the data model associated with the current block specification.- Specified by:
getDatain interfaceIndependenceTest- Returns:
- the DataModel instance representing the data set associated with this block specification
-
isVerbose
public boolean isVerbose()Indicates whether verbose mode is enabled.- Specified by:
isVerbosein interfaceIndependenceTest- Returns:
- true if verbose mode is enabled; false otherwise
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbose mode for this instance.- Specified by:
setVerbosein interfaceIndependenceTest- Parameters:
verbose- True, if so.
-
getAlpha
public double getAlpha()Retrieves the significance level (alpha) for the independence test.- Specified by:
getAlphain interfaceIndependenceTest- Returns:
- the significance level (alpha) for the independence test
-
setAlpha
public void setAlpha(double alpha) Sets the significance level (alpha) for the independence test.- Specified by:
setAlphain interfaceIndependenceTest- Parameters:
alpha- This level.
-
getEffectiveSampleSize
public int getEffectiveSampleSize()Retrieves the effective sample size for the independence test.- Specified by:
getEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Returns:
- the effective sample size for the independence test
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int effectiveSampleSize) Sets the effective sample size for the independence test.- Specified by:
setEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Parameters:
effectiveSampleSize- the effective sample size
-
setRandomizeSplits
public void setRandomizeSplits(boolean randomize, long seed) Sets whether to randomize the splits and specifies a seed for randomization.- Parameters:
randomize- a boolean indicating whether the splits should be randomized.seed- a long value specifying the seed for randomization.
-
setNumTrials
public void setNumTrials(int t) Sets the number of trials for the independence test.- Parameters:
t- the number of trials
-
setLeftGetsSmallerHalfWhenOdd
public void setLeftGetsSmallerHalfWhenOdd(boolean flag) If true and |Zi| is odd, left gets floor(|Zi|/2); otherwise left gets ceil(|Zi|/2).- Parameters:
flag- a boolean indicating whether to use the smaller half when |Zi| is odd
-
getBlockSpec
Retrieves the block specification associated with this instance.- Specified by:
getBlockSpecin interfaceBlockTest- Returns:
- the BlockSpec instance representing the current block specification.
-
checkIndependence
Evaluates whether two nodes (variables) are independent given a set of conditioning nodes using a block-based conditional independence test. The method uses ranks to determine independence, with the process involving random splits and trials to enhance reliability.- Specified by:
checkIndependencein interfaceIndependenceTest- Parameters:
x- the first node being tested for independencey- the second node being tested for independencez- the set of conditioning nodes- Returns:
- an
IndependenceResultobject containing the outcome of the independence test, including whether the two nodes are independent given the conditioning set
-