Class RlcdCore

java.lang.Object
edu.cmu.tetrad.search.RlcdCore

public class RlcdCore extends Object

Encapsulates RLCD’s heavy lifting:

  • Pull sub-blocks from the covariance matrix.
  • Test block rank ≤ r (fast SVD precheck; hook available for Wilks/CCA).
  • Accumulate must-have / must-not-have edges and collider / non-collider constraints.
  • Build the CPDAG under Zhang rules; respect background knowledge.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Represents the output of the initial stage (stage 1) of a structure learning algorithm.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for the RlcdCore class.
    RlcdCore(RlcdParams p, Knowledge knowledge, boolean verbose)
    Constructs an instance of the RlcdCore algorithm.
    Constructs a deep copy of the given RlcdCore instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Applies GIN (General Independence Network) orientation rules to the given CPDAG (Completed Partially Directed Acyclic Graph) using the specified covariance matrix and sample size.
    Constructs a CPDAG (Completed Partially Directed Acyclic Graph) from the given variables and constraints.
    org.ejml.data.DMatrixRMaj
    crossCov(CovarianceMatrix cov, int[] A, int[] B)
    Computes the cross-covariance matrix for the specified subsets of variables.
    int
    numericalRank(org.ejml.data.DMatrixRMaj M, double tau)
    Computes the numerical rank of a given matrix using a specified singular value threshold.
    Executes the first stage of the RLCD structure learning algorithm.
    boolean
    testRankLE(CovarianceMatrix cov, int[] A, int[] B, int r, String method, double tau, int N, double alpha)
    Tests whether the rank of the cross-covariance matrix extracted from the given covariance matrix is less than or equal to the specified rank threshold using one of the supported methods.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RlcdCore

      public RlcdCore()
      Default constructor for the RlcdCore class. Initializes a new instance of the RlcdCore class without any pre-configured parameters. This constructor does not set any values or state and acts as a placeholder for creating an empty object.
    • RlcdCore

      public RlcdCore(RlcdCore core)
      Constructs a deep copy of the given RlcdCore instance.
      Parameters:
      core - The RlcdCore instance to be copied. It serves as the source from which the new RlcdCore object is created, replicating its state and configuration.
    • RlcdCore

      public RlcdCore(RlcdParams p, Knowledge knowledge, boolean verbose)
      Constructs an instance of the RlcdCore algorithm.
      Parameters:
      p - An instance of RlcdParams encapsulating all the essential parameters for the RLCD algorithm, such as alpha level, stage 1 method, and rank test configurations.
      knowledge - An optional Knowledge object that allows specifying known causal relations or constraints. If null, a new empty Knowledge instance is created.
      verbose - A boolean flag indicating whether to enable verbose logging during the execution of the algorithm.
  • Method Details

    • stage1Structure

      public RlcdCore.Stage1Output stage1Structure(CovarianceMatrix cov, int N)
      Executes the first stage of the RLCD structure learning algorithm. This method processes a covariance matrix to generate constraints that can be used for subsequent stages of causal structure learning. It identifies required and prohibited edges in the graph, and sets up collider and non-collider constraints.
      Parameters:
      cov - The covariance matrix containing the variables and their relationships, used for generating structure constraints.
      N - The sample size corresponding to the covariance matrix, required for statistical tests during constraint generation.
      Returns:
      An instance of Stage1Output containing the generated structure constraints, including required edges, prohibited edges, and collider/non-collider information.
    • buildCpdagFromConstraints

      public Graph buildCpdagFromConstraints(List<Node> vars, RlcdCore.Stage1Output s1)
      Constructs a CPDAG (Completed Partially Directed Acyclic Graph) from the given variables and constraints. The method enforces must-have edges, removes must-not-have edges, applies collider constraints, and orients remaining edges using standard orientation rules as described in Zhang 2008.
      Parameters:
      vars - A list of nodes representing the variables in the graph.
      s1 - An instance of Stage1Output containing constraints on edges (must-have, must-not-have) and collider/non-collider constraints.
      Returns:
      An instance of Graph representing the constructed CPDAG after incorporating the given constraints.
    • applyGinOrientations

      public Graph applyGinOrientations(CovarianceMatrix cov, Graph cpdag, int N)
      Applies GIN (General Independence Network) orientation rules to the given CPDAG (Completed Partially Directed Acyclic Graph) using the specified covariance matrix and sample size. This method serves as a hook for the GIN algorithm to further orient the edges in the CPDAG based on the input parameters and configurations.
      Parameters:
      cov - The covariance matrix containing information about the variables and their relationships, used to inform edge orientations.
      cpdag - The initial CPDAG (Completed Partially Directed Acyclic Graph) to which GIN orientation rules will be applied.
      N - The sample size associated with the covariance matrix, influencing statistical tests during the GIN orientation process.
      Returns:
      The CPDAG after applying the GIN orientation rules, potentially with additional edge orientations performed by the GIN algorithm.
    • testRankLE

      public boolean testRankLE(CovarianceMatrix cov, int[] A, int[] B, int r, String method, double tau, int N, double alpha)
      Tests whether the rank of the cross-covariance matrix extracted from the given covariance matrix is less than or equal to the specified rank threshold using one of the supported methods. The method supports rank determination using either the singular value decomposition (SVD) or other statistical methods like Wilks' lambda test (currently not implemented).
      Parameters:
      cov - The covariance matrix containing the relationships among variables.
      A - An array of indices representing the first variable subset for the cross-covariance calculation.
      B - An array of indices representing the second variable subset for the cross-covariance calculation.
      r - The rank threshold to test against.
      method - The rank testing method to use. Supported methods include "svd".
      tau - The singular value threshold used for numerical rank determination in the SVD method.
      N - The sample size associated with the covariance matrix, used in certain statistical methods (e.g., Wilks).
      alpha - The significance level for the rank test, relevant for statistical methods (e.g., Wilks).
      Returns:
      A boolean value indicating whether the rank test passed. Returns true if the rank is less than or equal to the specified threshold, and false otherwise.
      Throws:
      IllegalArgumentException - If an unknown method is specified.
      UnsupportedOperationException - If the specified method is not implemented.
    • crossCov

      public org.ejml.data.DMatrixRMaj crossCov(CovarianceMatrix cov, int[] A, int[] B)
      Computes the cross-covariance matrix for the specified subsets of variables. The method extracts the relevant entries from the covariance matrix based on the provided index arrays for the two variable subsets.
      Parameters:
      cov - The covariance matrix containing relationships among variables.
      A - An array of indices representing the first variable subset.
      B - An array of indices representing the second variable subset.
      Returns:
      A cross-covariance matrix represented as an instance of DMatrixRMaj, containing the covariances between the variables in subsets A and B.
    • numericalRank

      public int numericalRank(org.ejml.data.DMatrixRMaj M, double tau)
      Computes the numerical rank of a given matrix using a specified singular value threshold. The rank is determined based on the number of singular values greater than the specified threshold.
      Parameters:
      M - The input matrix for which the numerical rank is to be computed.
      tau - The threshold value for singular values. Singular values greater than this threshold are considered significant.
      Returns:
      The numerical rank of the matrix, defined as the count of singular values greater than the threshold.