Class ScoreIndTest

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

public class ScoreIndTest extends Object implements IndependenceTest
Gives a way of interpreting a score as an independence test. The contract is that the score returned will be negative for independence and positive for dependence; this simply reports these differences.
Version:
$Id: $Id
Author:
josephramsey
  • Constructor Details

    • ScoreIndTest

      public ScoreIndTest(Score score)

      Constructor for ScoreIndTest.

      Parameters:
      score - a Score object
    • ScoreIndTest

      public ScoreIndTest(Score score, DataModel data)

      Constructor for ScoreIndTest.

      Parameters:
      score - a Score object
      data - a DataModel object
  • Method Details

    • indTestSubset

      public ScoreIndTest indTestSubset(List<Node> vars)
      Tests the independence between variables in a given sublist.
      Specified by:
      indTestSubset in interface IndependenceTest
      Parameters:
      vars - The sublist of variables to test independence.
      Returns:
      The result of the independence test.
    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> z) throws InterruptedException
      Checks the independence between two nodes given a set of additional nodes.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - The first node
      y - The second node
      z - The set of additional nodes
      Returns:
      The result of the independence test
      Throws:
      InterruptedException - If the process is interrupted during the execution.
    • getVariables

      public List<Node> getVariables()
      Returns the list of variables over which this independence checker is capable of determinining independence relations.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      This list.
    • getVariable

      public Node getVariable(String name)
      Retrieves the Node object with the specified name.
      Specified by:
      getVariable in interface IndependenceTest
      Parameters:
      name - The name of the Node object to retrieve.
      Returns:
      The Node object with the specified name, or null if not found.
    • determines

      public boolean determines(List<Node> z, Node y)
      Determines the result of an independence test between a set of variables and a target variable.
      Parameters:
      z - The set of variables to test for independence.
      y - The target variable to test against.
      Returns:
      The result of the independence test.
    • isPValueAProbability

      public boolean isPValueAProbability()
      Returns false: the value this test reports in the p-value slot is a score difference (negative for independence, positive for dependence), not a probability, so SMALLER values mean stronger evidence of independence. Callers ranking sepsets by strength must reverse their comparison accordingly.
      Specified by:
      isPValueAProbability in interface IndependenceTest
      Returns:
      False, always.
    • calibrationActive

      public boolean calibrationActive()
      Returns true just in case calibrated p-value reporting has been requested AND the wrapped score can supply it in its current configuration.
      Returns:
      True if calibrated p-values are being reported.
    • setCalibratePValues

      public void setCalibratePValues(boolean calibratePValues)
      Sets whether this test reports a calibrated p-value in the p-value slot of its results, in place of the raw local score difference. Off by default.

      The accept/reject decision is NOT affected: independence is judged by the sign of the local score difference either way, so a search run with this on returns the same graph. What changes is what the test REPORTS: with calibration on, IndependenceResult.getPValue() is a probability that is asymptotically Uniform(0, 1) under the null, getAlpha() is the level at which the score's sign rule operates, and isPValueAProbability() is true -- which together make the p-value-distribution diagnostics of the Markov check (Anderson-Darling, KS, Fisher, binomial) well defined for a score-based test. The raw score difference remains available from IndependenceResult.getScore().

      Requesting this when the wrapped score cannot supply it (it does not implement ProvidesCalibratedPValue, or does but is configured with a non-zero structure prior) is a no-op: calibrationActive() stays false and the test behaves exactly as before.

      Parameters:
      calibratePValues - Whether to report calibrated p-values.
    • getAlpha

      public double getAlpha()
      Returns the significance level of the independence test.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      This level.
      Throws:
      UnsupportedOperationException - if there is no significance level.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the significance level for the independence test.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - The level of significance to be set.
    • getData

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

      public ICovarianceMatrix getCov()
      Returns the covariance matrix.
      Specified by:
      getCov in interface IndependenceTest
      Returns:
      This matrix.
    • getDataSets

      public List<DataSet> getDataSets()
      Description copied from interface: IndependenceTest
      Returns the datasets for this test
      Specified by:
      getDataSets in interface IndependenceTest
      Returns:
      these datasets.
      Throws:
      UnsupportedOperationException - since not implemented.
    • getSampleSize

      public int getSampleSize()
      Returns the sample size.
      Specified by:
      getSampleSize in interface IndependenceTest
      Returns:
      This size.
    • getWrappedScore

      public Score getWrappedScore()
      Returns the score object that this test wraps.
      Returns:
      This score object.
      See Also:
    • isVerbose

      public boolean isVerbose()
      Returns a boolean indicating whether verbose output is enabled.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      true if verbose output is enabled, false otherwise
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets whether verbose output is enabled or not.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - true if verbose output is enabled, false otherwise
    • toString

      public String toString()
      Returns a string representation of the object.
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
      Returns:
      A string representing the object.
    • 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.

      Delegates to the wrapped score: this test has exactly the missing-data support of its score.

      Specified by:
      getMissingValueSupport in interface IndependenceTest
      Returns:
      This support level.