Class SepsetsMaxP

java.lang.Object
edu.cmu.tetrad.search.utils.SepsetsMaxP
All Implemented Interfaces:
SepsetProducer

public class SepsetsMaxP extends Object implements SepsetProducer
The class SepsetsMaxP implements the SepsetProducer interface and provides methods for generating sepsets based on a given graph and an independence test. It also allows for checking conditional independencies and calculating p-values for statistical tests.

This class tries to maximize the p-value of the independence test result when selecting sepsets.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SepsetsMaxP(Graph graph, IndependenceTest independenceTest, int depth)
    Constructs a SepsetsMaxP object with the given graph, independence test, and depth.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the Directed Acyclic Graph (DAG) produced by the Sepset algorithm.
    double
    getPValue(Node a, Node b, Set<Node> sepset)
    Retrieves the p-value from the result of an independence test between two nodes, given a set of separating nodes.
    double
    Calculates the score for the given Sepsets object.
    getSepset(Node i, Node k, int depth)
    Retrieves the sepset (separating set) between two nodes which contains a set of nodes.
    getSepsetContaining(Node i, Node k, Set<Node> s, int depth)
    Retrieves a sepset (separating set) between two nodes containing a set of nodes containing the nodes in s, or null if no such sepset is found.
    Retrieves the variables used in the independence test.
    boolean
    isIndependent(Node a, Node b, Set<Node> sepset)
    Determines if two nodes are independent given a set of separating nodes.
    boolean
    isUnshieldedCollider(Node i, Node j, Node k, int depth)
    Determines if a node is an unshielded collider between two other nodes.
    boolean
    Returns whether the object is in verbose mode.
    void
    setGraph(Graph graph)
    Sets the graph for the SepsetsMaxP object.
    void
    setVerbose(boolean verbose)
    Sets the verbosity level for this object.

    Methods inherited from class java.lang.Object

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

    • SepsetsMaxP

      public SepsetsMaxP(Graph graph, IndependenceTest independenceTest, int depth)
      Constructs a SepsetsMaxP object with the given graph, independence test, and depth.
      Parameters:
      graph - The graph representing the causal relationships between nodes.
      independenceTest - The independence test used to determine the conditional independence between variables.
      depth - The depth of the sepsets search.
  • Method Details

    • getSepset

      public Set<Node> getSepset(Node i, Node k, int depth)
      Retrieves the sepset (separating set) between two nodes which contains a set of nodes. If no such sepset is found, it returns null.
      Specified by:
      getSepset in interface SepsetProducer
      Parameters:
      i - The first node.
      k - The second node.
      depth - The depth of the search.
      Returns:
      The sepset between the two nodes containing the specified set of nodes.
    • getSepsetContaining

      public Set<Node> getSepsetContaining(Node i, Node k, Set<Node> s, int depth)
      Retrieves a sepset (separating set) between two nodes containing a set of nodes containing the nodes in s, or null if no such sepset is found. If there is no required set of nodes, pass null for the set.
      Specified by:
      getSepsetContaining in interface SepsetProducer
      Parameters:
      i - The first node
      k - The second node
      s - The set of nodes that the sepset must contain
      depth - The depth of the search
      Returns:
      The sepset between the two nodes containing the specified set of nodes
    • isUnshieldedCollider

      public boolean isUnshieldedCollider(Node i, Node j, Node k, int depth)
      Determines if a node is an unshielded collider between two other nodes.
      Specified by:
      isUnshieldedCollider in interface SepsetProducer
      Parameters:
      i - The first node.
      j - The node to check.
      k - The second node.
      depth - The depth of the search.
      Returns:
      true if the node j is an unshielded collider between nodes i and k, false otherwise.
    • isIndependent

      public boolean isIndependent(Node a, Node b, Set<Node> sepset)
      Determines if two nodes are independent given a set of separating nodes.
      Specified by:
      isIndependent in interface SepsetProducer
      Parameters:
      a - The first node
      b - The second node
      sepset - The set of separating nodes
      Returns:
      true if the nodes a and b are independent, false otherwise
    • getPValue

      public double getPValue(Node a, Node b, Set<Node> sepset)
      Retrieves the p-value from the result of an independence test between two nodes, given a set of separating nodes.
      Specified by:
      getPValue in interface SepsetProducer
      Parameters:
      a - The first node
      b - The second node
      sepset - The set of separating nodes
      Returns:
      The p-value from the independence test result
    • setGraph

      public void setGraph(Graph graph)
      Sets the graph for the SepsetsMaxP object.
      Specified by:
      setGraph in interface SepsetProducer
      Parameters:
      graph - The graph to set
    • getScore

      public double getScore()
      Calculates the score for the given Sepsets object.
      Specified by:
      getScore in interface SepsetProducer
      Returns:
      The score calculated based on the result's p-value and the independence test's alpha value.
    • getVariables

      public List<Node> getVariables()
      Retrieves the variables used in the independence test.
      Specified by:
      getVariables in interface SepsetProducer
      Returns:
      A list of Node objects representing the variables used in the independence test.
    • isVerbose

      public boolean isVerbose()
      Returns whether the object is in verbose mode.
      Returns:
      true if the object is in verbose mode, false otherwise
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbosity level for this object. When verbose mode is set to true, additional debugging information will be printed during the execution of this method.
      Specified by:
      setVerbose in interface SepsetProducer
      Parameters:
      verbose - The verbosity level to set. Set to true for verbose output, false otherwise.
    • getDag

      public Graph getDag()
      Retrieves the Directed Acyclic Graph (DAG) produced by the Sepset algorithm.
      Returns:
      The DAG produced by the Sepsets algorithm, or null if the independence test is not an instance of MsepTest.