Class Fask

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

public final class Fask extends Object
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
    Positive ⇒ x→y, Negative ⇒ y→x.

All existing public behavior is preserved.

Author:
Joseph Ramsey
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enumeration representing directional and functional types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Fask(DataSet dataSet, Score score)
    Constructs a new Fask instance with the specified data set and score.
  • Method Summary

    Modifier and Type
    Method
    Description
    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)).
    static double
    cu(double[] x, double[] y, double[] condition)
    E[x y | condition > 0].
    static double
    E(double[] x, double[] y, double[] z)
    E(xy | z>0).
    static double
    leftRightDiff(double[] x, double[] y, int ruleIndex)
    Returns a signed left-right "difference/score" per rule.
    Executes the FASK (Fast Adjacency Skewness) algorithm to search for a causal graph based on the provided dataset, knowledge, and configurations.
    void
    setAlpha(double alpha)
    Sets the significance level (alpha) for the FASK algorithm.
    void
    setCutoff(double alpha)
    Sets the significance level for the FASK algorithm.
    static void
    setDelta(double _delta)
    Set the delta parameter for FASK search.
    void
    setDepth(int depth)
    Sets the depth of the search in the FASK algorithm.
    void
    setExternalGraph(Graph externalGraph)
    Sets the external graph for the FASK algorithm.
    void
    setExtraEdgeThreshold(double extraEdgeThreshold)
    Sets the threshold value for considering extra edges in the FASK algorithm.
    void
    Sets the prior knowledge for the FASK algorithm.
    void
    Sets the left-right scoring method used in the FASK algorithm.
    void
    setUseFasAdjacencies(boolean useFasAdjacencies)
    Sets whether the FASK algorithm should use Fast Adjacency Search (FAS) for determining adjacencies.
    void
    setUseSkewAdjacencies(boolean useSkewAdjacencies)
    Configures whether the FASK algorithm should utilize skew adjacencies during its execution.

    Methods inherited from class java.lang.Object

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

    • Fask

      public Fask(DataSet dataSet, Score score)
      Constructs a new Fask instance with the specified data set and score.
      Parameters:
      dataSet - the data set used for the analysis
      score - 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 points
      y - the second array of data points
      condition - 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 points
      y - the second array of data points
      z - 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 points
      y - the second array of data points
      z - 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 X
      y - standardized (recommended) series for Y
      ruleIndex - 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

      public Graph search() throws InterruptedException
      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

      public void setLeftRight(Fask.LeftRight leftRight)
      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

      public void setKnowledge(Knowledge knowledge)
      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

      public void setExternalGraph(Graph externalGraph)
      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.