Class MsepTest

java.lang.Object
edu.cmu.tetrad.search.test.MsepTest
All Implemented Interfaces:
IndependenceTest

public class MsepTest extends Object implements IndependenceTest

Checks independence facts for variables associated with the nodes in a given graph by checking m-separation facts on the underlying nodes. We use the IndependenceTest interface here so that this m-separation test can be used in place of a statistical conditional independence test in algorithms to provide oracle information.

Author:
josephramsey
  • Constructor Details

    • MsepTest

      public MsepTest(Graph graph)
      Constructor.
      Parameters:
      graph - The graph for which m-separation facts should be checked. This may be a DAG, CPDAG, or PAG. In the latter case, m-separation results will be returned (same algorithm).
    • MsepTest

      public MsepTest(IndependenceFacts facts, List<Node> variables)
      Constructor.
      Parameters:
      facts - Independence facts to be used for direct calculations of m-separation.
      variables - The variables for the facts, if different from those that independenceFacts would return.
      See Also:
    • MsepTest

      public MsepTest(IndependenceFacts facts)
      Constructor.
      Parameters:
      facts - Independence facts to be used for direct calculations of m-separation.
      See Also:
    • MsepTest

      public MsepTest(Graph graph, boolean keepLatents)
      Constructor.
      Parameters:
      graph - The graph for which m-separation facts should be checked. This may be a DAG, CPDAG, or PAG. In the latter case, m-separation results will be returned (same algorithm).
      keepLatents - Whether latent in the graph should be used in conditional independence facts. If the graph is being marginalized, this should be false.
    • MsepTest

      public MsepTest(IndependenceFacts facts, boolean keepLatents)
      Constructor.
      Parameters:
      facts - Independence facts to be used for direct calculations of m-separation.
      keepLatents - Whether latent in the graph should be used in conditional independence facts. If the graph is being marginalized, this should be false.
      See Also:
  • Method Details

    • indTestSubset

      public IndependenceTest indTestSubset(List<Node> vars)
      Returns a test over a subset of the variables.
      Specified by:
      indTestSubset in interface IndependenceTest
      Parameters:
      vars - The sublist of variables.
      Returns:
      This test.
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> z)
      Checks the indicated m-separation fact, msep(x , y | z).
      Specified by:
      checkIndependence in interface IndependenceTest
      Returns:
      An independence result for msep(x, y | z).
      See Also:
    • isMSeparated

      public boolean isMSeparated(Node x, Node y, Set<Node> z)
      Auxiliary method to calculate msep(x, y | z) directly from nodes instead of from variables.
      Returns:
      True, if so.
    • getVariables

      public List<Node> getVariables()
      Return the list of TetradNodes over which this independence checker is capable of determinine independence relations-- that is, all the variables in the given graph or the given data set.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      This list.
    • determines

      public boolean determines(List<Node> z, Node x1)
      Throws:
      UnsupportedOperationException - Since this method is not feasible.
    • getAlpha

      public double getAlpha()
      Returns an alpha level, 0.5. This is an arbitrary nubmer that will help decide whether a pseudo p-value returned by the test represents a dependence or an independence.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      0.5.
    • setAlpha

      public void setAlpha(double alpha)
      Description copied from interface: IndependenceTest
      Sets the significance level.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - This level.
      Throws:
      UnsupportedOperationException - it makes no sense to set an alpha level for a d-separation test away from the default.
      See Also:
    • getVariable

      public Node getVariable(String name)
      Returns the variable with the given name.
      Specified by:
      getVariable in interface IndependenceTest
      Parameters:
      name - The name.
      Returns:
      The variable.
    • getGraph

      public Graph getGraph()
      Returns the underlying graph that is being used to calculate d-separation relationships.
      Returns:
      This graph.
    • toString

      public String toString()
      Returns a string representation of this test.
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
      Returns:
      "M-separation".
    • getData

      public DataSet getData()
      Specified by:
      getData in interface IndependenceTest
      Returns:
      The data model for the independence test, either a DataSet or a CovarianceMatrix.
      Throws:
      UnsupportedOperationException - Method doesn't make sense here.
      See Also:
    • isVerbose

      public boolean isVerbose()
      Returns True just in case verbose output should be printed.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      True, if so.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets whether verbose output should be printed.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True, if so.