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 Details

    • IndTestBlocksTs

      public IndTestBlocksTs(BlockSpec blockSpec)
      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

      public List<Node> getVariables()
      Retrieves the list of variable nodes associated with this instance.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      a new list containing the variable nodes.
    • getData

      public DataModel getData()
      Retrieves the data model associated with the current block specification.
      Specified by:
      getData in interface IndependenceTest
      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:
      isVerbose in interface IndependenceTest
      Returns:
      true if verbose mode is enabled; false otherwise
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbose mode for this instance.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True, if so.
    • getAlpha

      public double getAlpha()
      Retrieves the significance level (alpha) for the independence test.
      Specified by:
      getAlpha in interface IndependenceTest
      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:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - This level.
    • getEffectiveSampleSize

      public int getEffectiveSampleSize()
      Retrieves the effective sample size for the independence test.
      Specified by:
      getEffectiveSampleSize in interface EffectiveSampleSizeSettable
      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:
      setEffectiveSampleSize in interface EffectiveSampleSizeSettable
      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

      public BlockSpec getBlockSpec()
      Retrieves the block specification associated with this instance.
      Specified by:
      getBlockSpec in interface BlockTest
      Returns:
      the BlockSpec instance representing the current block specification.
    • checkIndependence

      public IndependenceResult checkIndependence(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. The method uses ranks to determine independence, with the process involving random splits and trials to enhance reliability.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - the first node being tested for independence
      y - the second node being tested for independence
      z - the set of conditioning nodes
      Returns:
      an IndependenceResult object containing the outcome of the independence test, including whether the two nodes are independent given the conditioning set