Package edu.cmu.tetrad.search
Class Fask
java.lang.Object
edu.cmu.tetrad.search.Fask
Implements the FASK (Fast Adjacency Skewness) algorithm.
Exposes both boolean LR decisions (for backward compatibility) and a new signed "difference/score" API so upstream algorithms (e.g., FCI-FASK) can choose thresholds or compare competing rules:
- leftRightDiff(x, y, ruleIndex) → double:
- ruleIndex = 1: FASK1 score
- ruleIndex = 2: FASK2 score (corrExp(x,y|x) − corrExp(x,y|y))
- ruleIndex = 3: RSKEW (Hyvärinen–Smith robust skew) score
- ruleIndex = 4: SKEW (Hyvärinen–Smith skew) score
- ruleIndex = 5: TANH (Hyvärinen–Smith tanh) score
All existing public behavior is preserved.
- Author:
- Joseph Ramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enumeration representing directional and functional types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecorrExp(double[] x, double[] y, double[] z) corrExp(x,y|z) = E(xy|z>0) / sqrt(E(x^2|z>0) E(y^2|z>0)).static doublecu(double[] x, double[] y, double[] condition) E[x y | condition > 0].static doubleE(double[] x, double[] y, double[] z) E(xy | z>0).static doubleleftRightDiff(double[] x, double[] y, int ruleIndex) Returns a signed left-right "difference/score" per rule.search()Executes the FASK (Fast Adjacency Skewness) algorithm to search for a causal graph based on the provided dataset, knowledge, and configurations.voidsetAlpha(double alpha) Sets the significance level (alpha) for the FASK algorithm.voidsetCutoff(double alpha) Sets the significance level for the FASK algorithm.static voidsetDelta(double _delta) Set the delta parameter for FASK search.voidsetDepth(int depth) Sets the depth of the search in the FASK algorithm.voidsetExternalGraph(Graph externalGraph) Sets the external graph for the FASK algorithm.voidsetExtraEdgeThreshold(double extraEdgeThreshold) Sets the threshold value for considering extra edges in the FASK algorithm.voidsetKnowledge(Knowledge knowledge) Sets the prior knowledge for the FASK algorithm.voidsetLeftRight(Fask.LeftRight leftRight) Sets the left-right scoring method used in the FASK algorithm.voidsetUseFasAdjacencies(boolean useFasAdjacencies) Sets whether the FASK algorithm should use Fast Adjacency Search (FAS) for determining adjacencies.voidsetUseSkewAdjacencies(boolean useSkewAdjacencies) Configures whether the FASK algorithm should utilize skew adjacencies during its execution.
-
Constructor Details
-
Fask
Constructs a new Fask instance with the specified data set and score.- Parameters:
dataSet- the data set used for the analysisscore- the scoring method utilized for evaluating the data
-
-
Method Details
-
cu
public static double cu(double[] x, double[] y, double[] condition) E[x y | condition > 0].- Parameters:
x- the first array of data pointsy- the second array of data pointscondition- the condition array- Returns:
- the expected value of the product of x and y given the condition
-
corrExp
public static double corrExp(double[] x, double[] y, double[] z) corrExp(x,y|z) = E(xy|z>0) / sqrt(E(x^2|z>0) E(y^2|z>0)).- Parameters:
x- the first array of data pointsy- the second array of data pointsz- the condition array- Returns:
- the correlation expectation of x and y given z
-
E
public static double E(double[] x, double[] y, double[] z) E(xy | z>0).- Parameters:
x- the first array of data pointsy- the second array of data pointsz- the condition array- Returns:
- the expected value of the product of x and y given z
-
leftRightDiff
public static double leftRightDiff(double[] x, double[] y, int ruleIndex) Returns a signed left-right "difference/score" per rule. Positive ⇒ x→y, Negative ⇒ y→x.- Parameters:
x- standardized (recommended) series for Xy- standardized (recommended) series for YruleIndex- 1=FASK1, 2=FASK2, 3=RSKEW, 4=SKEW, 5=TANH- Returns:
- signed left-right score
-
setDelta
public static void setDelta(double _delta) Set the delta parameter for FASK search.- Parameters:
_delta- The new delta value to be set for the FASK algorithm.
-
search
Executes the FASK (Fast Adjacency Skewness) algorithm to search for a causal graph based on the provided dataset, knowledge, and configurations.The method first standardizes the dataset and initializes a preliminary graph structure with either an external graph or through a Fast Adjacency Search (FAS) with a scoring method. It then iteratively examines pairs of variables to determine potential causal edges based on various scoring rules, adjacency conditions, and provided prior knowledge. The final graph includes directed and potentially bidirected edges based on the algorithm's logic.
- Returns:
- A causal graph inferred by the FASK algorithm, where nodes represent variables and edges denote the presence and direction of inferred causal relationships.
- Throws:
InterruptedException- if the execution is interrupted during the search process.
-
setLeftRight
Sets the left-right scoring method used in the FASK algorithm.- Parameters:
leftRight- the left-right scoring method to be used, represented by the Fask.LeftRight enum
-
setCutoff
public void setCutoff(double alpha) Sets the significance level for the FASK algorithm.- Parameters:
alpha- the significance level, must be between 0.0 and 1.0
-
setDepth
public void setDepth(int depth) Sets the depth of the search in the FASK algorithm.- Parameters:
depth- the depth of the search, must be non-negative
-
setAlpha
public void setAlpha(double alpha) Sets the significance level (alpha) for the FASK algorithm. This parameter determines the threshold used in statistical tests within the algorithm, and must be a value between 0.0 and 1.0.- Parameters:
alpha- the significance level, must be between 0.0 and 1.0
-
setKnowledge
Sets the prior knowledge for the FASK algorithm. This knowledge represents constraints or background information that can guide or restrict the causal discovery process.- Parameters:
knowledge- the prior knowledge object to be used in the algorithm
-
setExternalGraph
Sets the external graph for the FASK algorithm. This graph can serve as an initial structure or provide constraints for further causal discovery during the algorithm's execution.- Parameters:
externalGraph- the external graph to be used, represented as a Graph object
-
setExtraEdgeThreshold
public void setExtraEdgeThreshold(double extraEdgeThreshold) Sets the threshold value for considering extra edges in the FASK algorithm.- Parameters:
extraEdgeThreshold- the threshold value to be set for extra edges, where a lower value might result in more potential extra edges being considered in the analysis, while a higher value might be more restrictive
-
setUseFasAdjacencies
public void setUseFasAdjacencies(boolean useFasAdjacencies) Sets whether the FASK algorithm should use Fast Adjacency Search (FAS) for determining adjacencies. This configuration influences how the initial graph structure is constructed during the algorithm's execution.- Parameters:
useFasAdjacencies- a boolean indicating whether to use FAS adjacencies. If true, FAS is used to determine adjacencies during the graph search process; if false, an alternative approach may be employed.
-
setUseSkewAdjacencies
public void setUseSkewAdjacencies(boolean useSkewAdjacencies) Configures whether the FASK algorithm should utilize skew adjacencies during its execution. Skew adjacencies, if enabled, influence the process by considering relationships determined through the skewness of data distributions.- Parameters:
useSkewAdjacencies- a boolean indicating whether to use skew adjacencies. If true, skewness-based adjacencies are considered as part of the graph construction process; if false, they are excluded.
-