Class Ccd

java.lang.Object
edu.cmu.tetrad.search.Ccd
All Implemented Interfaces:
IGraphSearch

public final class Ccd extends Object implements IGraphSearch
Cyclic Causal Discovery (CCD) after Richardson.

Richardson, T. S. (2013). A discovery algorithm for directed cyclic graphs. arXiv:1302.3599.

See also Chapter 7 of: Glymour & Cooper (1999), Computation, Causation, and Discovery.

Input: a conditional independence oracle/test for data from a directed cyclic model (DCG). Output: a cyclic PAG (with underline/dotted-underline annotations) representing the Markov equivalence class.

Note: Background knowledge is supported as forbidden directed edges only. Required edges are intentionally ignored (and should not be supplied) to avoid forcing orientations not justified by CCD.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a Ccd object with the given independence test.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the current independence test being used.
    boolean
    Determines whether the R1 orientation rule is set to be applied during the search process.
    Executes the CCD search algorithm to infer a causal graph based on statistical independence tests.
    void
    setApplyR1(boolean applyR1)
    Sets whether the R1 orientation rule should be applied during the search process.
    void
    setDepth(int depth)
    Sets the depth parameter, which may affect the algorithm's behavior during its operation.
    void
    Set background knowledge (forbidden edges).
    void
    Sets the independence test to be used during the algorithm's execution.
    void
    setVerbose(boolean verbose)
    Sets whether verbose output should be enabled for the current process.

    Methods inherited from class java.lang.Object

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

    • Ccd

      public Ccd(IndependenceTest test)
      Constructs a Ccd object with the given independence test.
      Parameters:
      test - the IndependenceTest to be used within the CCD algorithm. If the test is not an instance of CachingIndependenceTest, a caching wrapper will be applied to the provided test. Must not be null.
      Throws:
      NullPointerException - if the provided test is null.
  • Method Details

    • search

      public Graph search() throws InterruptedException
      Executes the CCD search algorithm to infer a causal graph based on statistical independence tests. The algorithm applies a series of steps, including adjacency search, orientation rules, and edge propagation, while taking into account background knowledge (if provided) and specific algorithm configurations (e.g., depth). A verbose logging option is available for detailed execution monitoring.

      The resulting graph is modified with orientations and additional structures based on statistical properties and algorithmic rules. These modifications include reoriented endpoints, the addition of non-collider and collider triples, and propagation of orientation changes to ensure consistency with the underlying causal structure. A final step attempts to direct edges where permissible according to the background knowledge.

      Specified by:
      search in interface IGraphSearch
      Returns:
      the inferred causal graph as a Graph object after applying the CCD search algorithm.
      Throws:
      InterruptedException - if the process is interrupted during execution.
    • getTest

      public IndependenceTest getTest()
      Retrieves the current independence test being used.
      Specified by:
      getTest in interface IGraphSearch
      Returns:
      the current IndependenceTest instance.
    • setTest

      public void setTest(IndependenceTest test)
      Sets the independence test to be used during the algorithm's execution. The provided test must have the same variable set as the current test. A caching wrapper will be applied to the test if it is not already cached.
      Specified by:
      setTest in interface IGraphSearch
      Parameters:
      test - the new independence test to be set. Must not be null and must have the same variable set as the existing test.
      Throws:
      NullPointerException - if the provided test is null.
      IllegalArgumentException - if the variable set of the new test differs from the variable set of the current test.
    • isApplyR1

      public boolean isApplyR1()
      Determines whether the R1 orientation rule is set to be applied during the search process.
      Returns:
      true if the R1 orientation rule is enabled; false otherwise.
    • setApplyR1

      public void setApplyR1(boolean applyR1)
      Sets whether the R1 orientation rule should be applied during the search process.
      Parameters:
      applyR1 - a boolean indicating whether to apply the R1 rule. If true, the R1 rule will be applied; otherwise, it will not.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets whether verbose output should be enabled for the current process.
      Parameters:
      verbose - a boolean indicating whether verbose output is enabled. If true, detailed logs or messages may be printed. If false, minimal or no verbose output will be shown.
    • setDepth

      public void setDepth(int depth)
      Sets the depth parameter, which may affect the algorithm's behavior during its operation.
      Parameters:
      depth - an integer representing the depth limit or level of recursion to be applied. A higher value typically increases the scope or complexity taken into account.
    • setKnowledge

      public void setKnowledge(Knowledge knowledge)
      Set background knowledge (forbidden edges). Required edges are not supported.
      Parameters:
      knowledge - the knowledge to be set