Class IdaCheck

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

public class IdaCheck extends Object
This calculates total effects and absolute total effects for an PDAG G for all pairs distinct (x, y) of variables, where the total effect is obtained by regressing y on x ∪ S and reporting the regression coefficient. Here, S ranges over sets consisting of possible parents of x in G--that is, a set consisting of the parents of x in G plus some combination of the neighbors for x in G, and excluding any children of x in G. Absolute total effects are calculated as the abolute values of the total effects; the minimum values for these across possible parent sets is reported as suggested in this paper:

Maathuis, Marloes H., Markus Kalisch, and Peter Bühlmann. "Estimating high-dimensional intervention effects from observational data." The Annals of Statistics 37.6A (2009): 3133-3164.

Additionally, if a linear SEM model is supplied over the same variables, a minimum squared distance is calculated of each coefficient in this IM from the interval of total effects (min to max) for the pair (x, y) for each directed edge x->y in the SEM IM. If the true total effect falls within the interval [min, max], we give a distance of 0; otherwise, we give the distance to the nearest endpoint. This distance is then squared.

We also report the averages of each statistic across all pairs of distinct nodes in the dataset.

IMPORTANT PERFORMANCE NOTE (2026-01): This class used to be frequently instantiated by UI editors that start with an empty table. In that context, precomputing effects for all O(p^2) pairs in the constructor made the UI slow to open.

Version:
$Id: $Id
Author:
josephramsey
See Also:
  • Constructor Details

    • IdaCheck

      public IdaCheck(Graph graph, DataSet dataSet, SemIm trueSemIm)
      Constructs a new IDA check for the given PDAG and data set.
      Parameters:
      graph - the PDAG.
      dataSet - the data set.
      trueSemIm - the true SEM IM. May be null; if null, no SEM-based checks will be performed.
  • Method Details

    • setIdaType

      public void setIdaType(Ida.IDA_TYPE idaType)
      Sets the IDA (Intervention Distribution Approximation) type for the current instance. This method updates the current IDA type and recalculates the results for total effects and absolute total effects as needed.
      Parameters:
      idaType - the IDA type to be set. Must not be null. Valid values are defined in Ida.IDA_TYPE.
      Throws:
      NullPointerException - if idaType is null.
    • getTrueTotalEffect

      public double getTrueTotalEffect(OrderedPair<Node> pair)
      Calculates the true total effect between two nodes in the graph.
      Parameters:
      pair - the ordered pair of nodes for which the total effect is calculated.
      Returns:
      the true total effect between the two nodes.
    • getNodes

      public List<Node> getNodes()
      Returns a list of nodes.
      Returns:
      the list of nodes.
    • getOrderedPairs

      public List<OrderedPair<Node>> getOrderedPairs()
      Retrieves a list of OrderedPair objects representing all possible pairs of distinct nodes in the graph.
      Returns:
      a list of OrderedPair objects.
    • getMinTotalEffect

      public double getMinTotalEffect(Node x, Node y)
      Gets the minimum total effect value between two nodes.
      Parameters:
      x - the first node.
      y - the second node.
      Returns:
      the minimum total effect value between the two nodes.
      Throws:
      IllegalArgumentException - if the nodes x and y are the same.
    • getMaxTotalEffect

      public double getMaxTotalEffect(Node x, Node y)
      Returns the maximum total effect value between two nodes.
      Parameters:
      x - the first node.
      y - the second node.
      Returns:
      the maximum total effect value between the two nodes.
      Throws:
      IllegalArgumentException - if the nodes x and y are the same.
    • getIdaMinEffect

      public double getIdaMinEffect(Node x, Node y)
      Gets the signed minimum absolute total effect value between two nodes.
      Parameters:
      x - the first node.
      y - the second node.
      Returns:
      the signed minimum absolute total effect value between the two nodes.
      Throws:
      IllegalArgumentException - if the nodes x and y are the same.
    • getSquaredDistance

      public double getSquaredDistance(OrderedPair<Node> pair)
      Calculates the squared distance of the true total effect to the [min, max] IDA effect range of the given (x, y) node pair, for x predicting y. If the true effect falls within [min, max], the method returns 0. Otherwise, the squared distance to the nearest endpoint of the [min, max] range is returned.

      If no IDA effects are available for this pair, returns Double.NaN.

      Parameters:
      pair - the pair of nodes.
      Returns:
      the squared distance between the two nodes.
    • getAverageSquaredDistance

      public double getAverageSquaredDistance(List<OrderedPair<Node>> pairs)
      Returns the average of the squared distances between the true total effects and the IDA effect ranges the list of node pairs indicated.
      Parameters:
      pairs - the list of node pairs.
      Returns:
      the average of the squared distances between the true total effects and the IDA effect ranges.
    • getSquaredMinTrueDistance

      public double getSquaredMinTrueDistance(OrderedPair<Node> pair)
      Returns the squared difference between the minimum total effect and the true total effect for the given pair of nodes. If no IDA effects are available for this pair, returns Double.NaN.
      Parameters:
      pair - the pair of nodes.
      Returns:
      the squared difference between the minimum total effect and the true total effect.
    • getAvgMinSquaredDiffEstTrue

      public double getAvgMinSquaredDiffEstTrue(List<OrderedPair<Node>> pairs)
      Returns the average of the squared differences between the minimum total effects and the true total effects for the list of node pairs indicated.
      Parameters:
      pairs - the list of node pairs.
      Returns:
      the average of the squared differences between the minimum total effects and the true total effects.
    • getSquaredMaxTrueDist

      public double getSquaredMaxTrueDist(OrderedPair<Node> pair)
      Returns the squared difference between the maximum total effect and the true total effect for the given pair of nodes. If no IDA effects are available for this pair, returns Double.NaN.
      Parameters:
      pair - the pair of nodes.
      Returns:
      the squared difference between the maximum total effect and the true total effect.
    • getAvgMaxSquaredDiffEstTrue

      public double getAvgMaxSquaredDiffEstTrue(List<OrderedPair<Node>> pairs)
      Returns the average of the squared differences between the maximum total effects and the true total effects for the list of node pairs indicated.
      Parameters:
      pairs - the list of node pairs.
      Returns:
      the average of the squared differences between the maximum total effects and the true total effects.
    • recompute

      public void recompute(List<OrderedPair<Node>> currentPairs)
      Recomputes the total effects and absolute total effects for all ordered pairs of nodes in the graph. The method utilizes the current IDA type, which can be either regular or optimal depending on the "show optimal IDA" flag.

      This method clears any previously computed effects and recalculates them using the current state of the graph and IDA configuration.

      Parameters:
      currentPairs - The list of ordered pairs for which effects should be recomputed.
    • getGraph

      public Graph getGraph()
      Returns a copy of the graph associated with this instance.

      This preserves the original behavior (returning a copy), but caches the copy so repeated calls do not repeatedly copy the graph.

      Returns:
      a copy of the graph.