Package edu.cmu.tetrad.search
Class RlcdCore
java.lang.Object
edu.cmu.tetrad.search.RlcdCore
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 ClassesModifier and TypeClassDescriptionstatic final classRepresents the output of the initial stage (stage 1) of a structure learning algorithm. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyGinOrientations(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.buildCpdagFromConstraints(List<Node> vars, RlcdCore.Stage1Output s1) Constructs a CPDAG (Completed Partially Directed Acyclic Graph) from the given variables and constraints.org.ejml.data.DMatrixRMajcrossCov(CovarianceMatrix cov, int[] A, int[] B) Computes the cross-covariance matrix for the specified subsets of variables.intnumericalRank(org.ejml.data.DMatrixRMaj M, double tau) Computes the numerical rank of a given matrix using a specified singular value threshold.stage1Structure(CovarianceMatrix cov, int N) Executes the first stage of the RLCD structure learning algorithm.booleantestRankLE(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.
-
Constructor Details
-
RlcdCore
public RlcdCore()Default constructor for theRlcdCoreclass. Initializes a new instance of theRlcdCoreclass 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
Constructs a deep copy of the givenRlcdCoreinstance.- Parameters:
core- TheRlcdCoreinstance to be copied. It serves as the source from which the newRlcdCoreobject is created, replicating its state and configuration.
-
RlcdCore
Constructs an instance of the RlcdCore algorithm.- Parameters:
p- An instance ofRlcdParamsencapsulating all the essential parameters for the RLCD algorithm, such as alpha level, stage 1 method, and rank test configurations.knowledge- An optionalKnowledgeobject that allows specifying known causal relations or constraints. Ifnull, a new emptyKnowledgeinstance is created.verbose- A boolean flag indicating whether to enable verbose logging during the execution of the algorithm.
-
-
Method Details
-
stage1Structure
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
Stage1Outputcontaining the generated structure constraints, including required edges, prohibited edges, and collider/non-collider information.
-
buildCpdagFromConstraints
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 ofStage1Outputcontaining constraints on edges (must-have, must-not-have) and collider/non-collider constraints.- Returns:
- An instance of
Graphrepresenting the constructed CPDAG after incorporating the given constraints.
-
applyGinOrientations
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
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.
-