Class IndTestProbabilistic

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

public class IndTestProbabilistic extends Object implements IndependenceTest
Uses BCInference by Cooper and Bui to calculate probabilistic conditional independence judgments.
Version:
$Id: $Id
Author:
josephramsey 3/2014
  • Constructor Details

    • IndTestProbabilistic

      public IndTestProbabilistic(DataSet dataSet)
      Initializes the test using a discrete data sets.
      Parameters:
      dataSet - a DataSet object
  • Method Details

    • indTestSubset

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

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> _z)
      Checks the independence between two variables x and y given a conditioning set z.

      Returns an independence result that states whether x _||_ y | z and what the p-value of the test is.

      In threshold mode the result is deterministic and is cached after the first computation so that repeated queries for the same fact are answered instantly. In randomized mode no caching is performed: each call draws a fresh Bernoulli sample from the posterior probability of independence, which is the source of stochasticity that drives the ensemble search in PagSamplingRfci.

      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - The first variable to test, represented as a Node object.
      y - The second variable to test, represented as a Node object.
      _z - The set of conditioning variables, represented as a Set of Node objects.
      Returns:
      An IndependenceResult object representing the outcome of the independence test.
      See Also:
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Node... z)
      Checks the independence fact in question and returns and independence result.

      Returns an independence result that states whether x _||_ y | z and what the p-value of the test is.

      The posterior probability of independence is cached in H only in threshold mode. In randomized mode the probability is recomputed on every call so that the random draw made below is truly independent across calls for the same fact.

      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - a Node object
      y - a Node object
      z - a Node object
      Returns:
      The independence result.
      See Also:
    • probConstraint

      public double probConstraint(BCInference bci, BCInference.OP op, Node x, Node y, Node[] z, Map<Node,Integer> indices)
      Returns the probability of the constraint x op y | z.
      Parameters:
      bci - The BCInference object.
      op - The operator.
      x - The first variable.
      y - The second variable.
      z - The conditioning set.
      indices - A map from nodes to their indices.
      Returns:
      The probability.
    • getVariables

      public List<Node> getVariables()
      Returns the list of variables used in this object.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      A List of Node objects representing the variables used.
    • getVariable

      public Node getVariable(String name)
      Retrieves the Node object that matches the given name from the list of nodes.
      Specified by:
      getVariable in interface IndependenceTest
      Parameters:
      name - The name of the variable to retrieve.
      Returns:
      The Node object matching the given name, or null if no match is found.
    • determines

      public boolean determines(Set<Node> z, Node y)
      Determines whether a given set of nodes, z, determines another node, y.
      Specified by:
      determines in interface IndependenceTest
      Parameters:
      z - A Set of nodes representing the conditioning set.
      y - The node for which determination is checked.
      Returns:
      true if z determines y, false otherwise.
    • getAlpha

      public double getAlpha()
      Returns the alpha parameter for the probabilistic test.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      The alpha parameter.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the alpha parameter for the probabilistic test.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - The alpha parameter to set.
    • getData

      public DataModel getData()
      Returns the data model associated with this instance.
      Specified by:
      getData in interface IndependenceTest
      Returns:
      The data model.
    • getH

      public Map<IndependenceFact, Double> getH()
      Returns a map from independence facts to their posterior probabilities of independence. Only facts evaluated in threshold mode are present; randomized-mode calls do not populate this map.
      Returns:
      A defensive copy of the map.
    • getPosterior

      public double getPosterior()
      Returns the posterior probability of the last independence test.
      Returns:
      The posterior probability.
    • isVerbose

      public boolean isVerbose()
      Returns the verbose flag indicating whether verbose output should be printed.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      The verbose flag.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbose flag indicating whether verbose output should be printed.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - true if verbose output should be printed, false otherwise.
    • setThreshold

      public void setThreshold(boolean threshold)
      Sets whether the independence test should be thresholded (true) or randomized (false).
      Parameters:
      threshold - true if the independence test should be thresholded, false if it should be randomized.
    • setCutoff

      public void setCutoff(double cutoff)
      Sets the cutoff for the independence test.
      Parameters:
      cutoff - the cutoff for the independence test.
    • setPriorEquivalentSampleSize

      public void setPriorEquivalentSampleSize(double priorEquivalentSampleSize)
      Sets the prior equivalent sample size for the independence test. The prior equivalent sample size is a parameter used in the calculation of the test statistic. A higher sample size will make the test more conservative, while a lower sample size will make the test more liberal.
      Parameters:
      priorEquivalentSampleSize - the prior equivalent sample size to set
    • getMissingValueSupport

      public MissingValueSupport getMissingValueSupport()
      Declares what this test can do, natively, with data containing missing values. The default is MissingValueSupport.NONE, meaning that missingness must be handled upstream (e.g., by imputation, or by supplying an EM-estimated covariance matrix if the test consumes one); tests that handle missing values themselves should override this.

      Each test uses only the rows on which x, y, and the conditioning variables are all observed (getRows excludes rows containing the missing-value sentinel for any variable involved), i.e., test-wise deletion, unbiased only under MCAR.

      Specified by:
      getMissingValueSupport in interface IndependenceTest
      Returns:
      MissingValueSupport.TESTWISE.