Package edu.cmu.tetrad.search
Class TwoStep
java.lang.Object
edu.cmu.tetrad.search.TwoStep
Deprecated.
Two-Step algorithm (linear, non-Gaussian disturbances; cycles allowed). Orientation: B[i,j] != 0 means edge j -> i.
Step 1: Sparse mask via (Adaptive) Lasso on Xi ~ X\i (Gram form over covariance). Penalty uses paper-style scaling when normalizeLossByN=true: lambda * (ln N)/2. Step 2: ICA (FastICA) to get A, align (Hungarian) so diag(A)=1, B0 = I - A^{-1}. Project to mask, refine with constrained OLS (covariance), pairwise BIC cleanup, then strict two-cycle breaker (optional).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDeprecated.The Result class encapsulates the output of the TwoStep algorithm's search process. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.ejml.simple.SimpleMatrixgetLastA()Deprecated.Retrieves the last calculated matrix A.static org.ejml.simple.SimpleMatrixmaskFromUndirected(Graph skeleton, List<Node> vars) Deprecated.Constructs a mask matrix from an undirected graph, indicating the adjacency relationships between a given list of nodes.Deprecated.Performs a search operation over the given dataset to analyze dependencies, refine coefficients, and build a directed graph representation.voidsetAdaptiveGamma(double gamma) Deprecated.Sets the value of the adaptive gamma parameter used in the two-step regression process.voidsetBreakTwoCyclesEnabled(boolean enabled) Deprecated.Enables or disables the breaking of two-cycle constraints in the processing.voidsetCoefThreshold(double t) Deprecated.Sets the coefficient threshold value for the regression process.voidsetCondWarnThreshold(double thr) Deprecated.Sets the condition warning threshold value used in the processing.voidsetExternalMask(org.ejml.simple.SimpleMatrix mask) Deprecated.Sets an external mask for use in the current object.voidsetFastIcaAlgorithm(int alg) Deprecated.Sets the FastICA algorithm type to be used in the Independent Component Analysis (ICA) procedure.voidsetFastIcaAlpha(double a) Deprecated.Sets the alpha parameter for the FastICA (Independent Component Analysis) process.voidsetFastIcaFunction(int f) Deprecated.Sets the FastICA function type to be used within the Independent Component Analysis (ICA) process.voidsetFastIcaRowNorm(boolean flag) Deprecated.Sets whether row normalization is applied in the FastICA (Independent Component Analysis) process.voidsetIcaMaxIter(int n) Deprecated.Sets the maximum number of iterations for the ICA (Independent Component Analysis) process.voidsetIcaTol(double t) Deprecated.Sets the tolerance value for the ICA (Independent Component Analysis) process.voidsetLambda(double lambda) Deprecated.Sets the value of the regularization parameter lambda.voidsetMaskThreshold(double t) Deprecated.Sets the mask threshold value used in the two-step regression process.voidsetNormalizeLossByN(boolean flag) Deprecated.If true, Step-1 uses lambdaEff = lambda * (ln N)/2 (paper-style).voidsetRandomSeed(long seed) Deprecated.Sets the random seed for reproducibility in the algorithm's processes.voidsetTwoCycleMinAbs(double minAbs) Deprecated.Sets the minimum absolute value threshold for breaking two-cycle constraints in the processing.voidsetUseAdaptiveLasso(boolean flag) Deprecated.Sets whether the adaptive lasso method should be used in the two-step regression process.voidsetVerbose(boolean v) Deprecated.Sets whether verbose output is enabled for the process.
-
Constructor Details
-
TwoStep
public TwoStep()Deprecated.Default constructor for the TwoStep class. This constructor initializes an instance of the TwoStep class without setting any specific properties or configurations.
-
-
Method Details
-
maskFromUndirected
Deprecated.Constructs a mask matrix from an undirected graph, indicating the adjacency relationships between a given list of nodes. The resulting matrix is symmetric with off-diagonal elements set to 1.0 for adjacent nodes and 0.0 otherwise.- Parameters:
skeleton- the undirected graph representing the structure of the relationships.vars- the list of nodes for which the adjacency matrix is to be created.- Returns:
- a symmetric mask matrix where an entry (i, j) is set to 1.0 if there is an adjacency between nodes vars[i] and vars[j], and 0.0 otherwise. The diagonal elements of the matrix are set to zero.
-
setLambda
public void setLambda(double lambda) Deprecated.Sets the value of the regularization parameter lambda.- Parameters:
lambda- the new value for the regularization parameter
-
setNormalizeLossByN
public void setNormalizeLossByN(boolean flag) Deprecated.If true, Step-1 uses lambdaEff = lambda * (ln N)/2 (paper-style).- Parameters:
flag- If normalized
-
setUseAdaptiveLasso
public void setUseAdaptiveLasso(boolean flag) Deprecated.Sets whether the adaptive lasso method should be used in the two-step regression process.- Parameters:
flag- If true, enables the use of the adaptive lasso; otherwise, disables it.
-
setAdaptiveGamma
public void setAdaptiveGamma(double gamma) Deprecated.Sets the value of the adaptive gamma parameter used in the two-step regression process.- Parameters:
gamma- the value to set for the adaptive gamma parameter
-
setMaskThreshold
public void setMaskThreshold(double t) Deprecated.Sets the mask threshold value used in the two-step regression process.- Parameters:
t- the value to set for the mask threshold
-
setCoefThreshold
public void setCoefThreshold(double t) Deprecated.Sets the coefficient threshold value for the regression process. This value affects regularization and the breaking of two-cycle constraints.- Parameters:
t- the new value to set for the coefficient threshold. It also ensures that the minimum absolute value for two-cycle checking is at least this threshold.
-
setIcaMaxIter
public void setIcaMaxIter(int n) Deprecated.Sets the maximum number of iterations for the ICA (Independent Component Analysis) process. This parameter controls how many iterations the algorithm can perform before stopping.- Parameters:
n- the maximum number of iterations to allow for the ICA process
-
setIcaTol
public void setIcaTol(double t) Deprecated.Sets the tolerance value for the ICA (Independent Component Analysis) process. This value determines the convergence criterion, defining the minimum change required between iterations for the algorithm to stop.- Parameters:
t- the tolerance value to set for the ICA process
-
setRandomSeed
public void setRandomSeed(long seed) Deprecated.Sets the random seed for reproducibility in the algorithm's processes.- Parameters:
seed- the value of the random seed to set
-
setVerbose
public void setVerbose(boolean v) Deprecated.Sets whether verbose output is enabled for the process.- Parameters:
v- true to enable verbose output; false to disable it.
-
setCondWarnThreshold
public void setCondWarnThreshold(double thr) Deprecated.Sets the condition warning threshold value used in the processing. The threshold defines a boundary beyond which a condition is flagged for further attention.- Parameters:
thr- the threshold value to set for the condition warning
-
setFastIcaAlgorithm
public void setFastIcaAlgorithm(int alg) Deprecated.Sets the FastICA algorithm type to be used in the Independent Component Analysis (ICA) procedure. This parameter determines the specific algorithmic approach to be applied within the FastICA process.- Parameters:
alg- the integer value representing the specific FastICA algorithm to use
-
setFastIcaFunction
public void setFastIcaFunction(int f) Deprecated.Sets the FastICA function type to be used within the Independent Component Analysis (ICA) process. This function determines the contrast function applied during the execution of the FastICA algorithm.- Parameters:
f- the integer value representing the specific FastICA function to use
-
setFastIcaAlpha
public void setFastIcaAlpha(double a) Deprecated.Sets the alpha parameter for the FastICA (Independent Component Analysis) process. This parameter is typically used to define the non-linearity or contrast function in the FastICA algorithm and influences its convergence and behavior.- Parameters:
a- the value of the FastICA alpha parameter to set
-
setFastIcaRowNorm
public void setFastIcaRowNorm(boolean flag) Deprecated.Sets whether row normalization is applied in the FastICA (Independent Component Analysis) process. Enabling this parameter ensures that the rows of the data are normalized before the ICA computation, which can affect the outcome and convergence of the algorithm.- Parameters:
flag- true to enable row normalization in FastICA; false to disable it.
-
setBreakTwoCyclesEnabled
public void setBreakTwoCyclesEnabled(boolean enabled) Deprecated.Enables or disables the breaking of two-cycle constraints in the processing.- Parameters:
enabled- true to enable the breaking of two-cycle constraints; false to disable it.
-
setTwoCycleMinAbs
public void setTwoCycleMinAbs(double minAbs) Deprecated.Sets the minimum absolute value threshold for breaking two-cycle constraints in the processing. This value ensures that small values below the threshold are ignored when evaluating constraints.- Parameters:
minAbs- the threshold value to set for the minimum absolute value used in two-cycle checking
-
setExternalMask
public void setExternalMask(org.ejml.simple.SimpleMatrix mask) Deprecated.Sets an external mask for use in the current object. The provided mask is sanitized before being assigned, and the external mask usage is enabled.- Parameters:
mask- the mask to be used as the external mask; it is represented as a SimpleMatrix object
-
getLastA
public org.ejml.simple.SimpleMatrix getLastA()Deprecated.Retrieves the last calculated matrix A.- Returns:
- the last instance of the SimpleMatrix referred to as lastA.
-
search
Deprecated.Performs a search operation over the given dataset to analyze dependencies, refine coefficients, and build a directed graph representation.This method utilizes techniques such as standardization, covariance analysis, masked projection, inverse estimation, constrained optimization, and additional cleanup steps to produce a refined result containing both a coefficient matrix and a graph representation.
- Parameters:
data- The dataset to perform the search on. This should include observable variables and their associated data points.- Returns:
- A
Resultobject containing the refined coefficient matrix and the generated graph. The matrix represents the weighted relationships between variables, and the graph represents their directional dependencies. - Throws:
IllegalStateException- If the matrix inversion process fails or other critical computations encounter errors.
-