Class EdgePriorTest

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

public class EdgePriorTest extends Object implements IndependenceTest
Wraps an IndependenceTest and gives each pair of variables its own significance level, alpha_ij = w_ij * alpha, by testing the weighted p-value p_ij / w_ij against a common alpha.

The pair (x, y) is fixed across every conditioning set that could delete the adjacency, so w_xy is well defined for the whole sequence of tests on that pair, and the threshold does not depend on the order in which pairs or conditioning sets are visited. PC-Stable's order-independence is therefore preserved.

Direction of the effect. PC removes an edge when it fails to reject independence, that is when p > alpha. A larger threshold makes rejection easier and so protects the edge; a smaller one makes deletion easier. Hence w_xy > 1 shields an edge from deletion and w_xy < 1 accelerates it. Note which way round this is before choosing weights: if the failure mode being addressed is under-deletion, the useful weights are below one.

Two calibrations, both supported through EdgePriors. Either derive w_ij from prior log-odds via EdgePriors.toWeightsViaBicBridge(double, int, double), which matches the per-edge threshold that a prior-adjusted SEM BIC would use for the same edge and so puts the score-based and constraint-based algorithms on one prior scale; or supply weights directly and call EdgePriors.normalizedToMeanOne(), which is the Genovese-Roeder-Wasserman formulation and carries an error-control guarantee for any fixed mean-one weights. The bridge needs a trustworthy lambda log(n); the GRW route mentions no n at all. For summary-statistic data, prefer GRW.

What the bridge does not do. The BIC bridge equates a per-decision threshold. It does not equate procedures. PC deletes an edge on finding any separating set, which at conditioning depth 3 over a hundred nodes is a minimum taken over on the order of 10^5 tests, whereas a score-based search makes one global choice of parent set. At matched lambda, PC therefore deletes considerably more, and a comparison of tuned operating points across the two families has to carry that caveat.

Author:
josephramsey
See Also:
  • Constructor Details

    • EdgePriorTest

      public EdgePriorTest(IndependenceTest test, EdgePriors priors, double alpha)
      Constructs a prior-adjusted test.
      Parameters:
      test - The test to wrap; typically an IndTestFisherZ.
      priors - P-value weights, keyed by variable name. Resolved against test.getVariables() here, once, so the caller's matrix ordering is irrelevant. Build this once per locus and share it across subsample repeats: the GRW guarantee requires the weights to be fixed across the family of tests, so they must not be rebuilt or renormalised per repeat.
      alpha - The base significance level. Each pair is judged against w_xy * alpha.
      Throws:
      IllegalStateException - If priors does not hold weights.
      IllegalArgumentException - If priors mentions variables the test does not have, or alpha is out of range.
  • Method Details

    • checkIndependence

      public IndependenceResult checkIndependence(Node x, Node y, Set<Node> z) throws InterruptedException
      Checks the independence of x and y given z, judging the weighted p-value against the base alpha.
      Specified by:
      checkIndependence in interface IndependenceTest
      Parameters:
      x - The first variable.
      y - The second variable.
      z - The conditioning set.
      Returns:
      The result, carrying the weighted p-value.
      Throws:
      InterruptedException - If the process is interrupted.
    • weight

      public double weight(Node x, Node y)
      Returns the weight for the unordered pair {x, y}.
      Parameters:
      x - One variable.
      y - The other.
      Returns:
      The weight.
    • getAlpha

      public double getAlpha(Node x, Node y)
      Returns the effective significance level for the unordered pair {x, y}, namely w_xy * alpha, capped at 1.
      Parameters:
      x - One variable.
      y - The other.
      Returns:
      The effective level.
    • getVariables

      public List<Node> getVariables()
      Returns the variables of the test.
      Specified by:
      getVariables in interface IndependenceTest
      Returns:
      This list.
    • getData

      public DataModel getData()
      Returns the data model of the test.
      Specified by:
      getData in interface IndependenceTest
      Returns:
      This data model.
    • isVerbose

      public boolean isVerbose()
      Returns true if this test prints verbose output.
      Specified by:
      isVerbose in interface IndependenceTest
      Returns:
      True if so.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets whether this test prints verbose output.
      Specified by:
      setVerbose in interface IndependenceTest
      Parameters:
      verbose - True if so.
    • getAlpha

      public double getAlpha()
      Returns the base significance level, before per-edge weighting.
      Specified by:
      getAlpha in interface IndependenceTest
      Returns:
      This level.
    • setAlpha

      public void setAlpha(double alpha)
      Not supported. The base alpha is fixed at construction, since the weights were calibrated against it; changing it afterwards would silently rescale every per-edge threshold.
      Specified by:
      setAlpha in interface IndependenceTest
      Parameters:
      alpha - Ignored.
    • getCov

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

      public List<DataSet> getDataSets()
      Returns the datasets of the wrapped test.
      Specified by:
      getDataSets in interface IndependenceTest
      Returns:
      These datasets.
    • determines

      public boolean determines(Set<Node> z, Node y)
      Returns true if y is determined by z, per the wrapped test.
      Specified by:
      determines in interface IndependenceTest
      Parameters:
      z - The conditioning set.
      y - The node.
      Returns:
      True if so.
    • getSampleSize

      public int getSampleSize()
      Returns the sample size of the wrapped test.
      Specified by:
      getSampleSize in interface IndependenceTest
      Returns:
      This size.
    • getWrappedTest

      public IndependenceTest getWrappedTest()
      Returns the wrapped test.
      Returns:
      The delegate.
    • toString

      public String toString()
      Returns a string representation of this test.
      Specified by:
      toString in interface IndependenceTest
      Overrides:
      toString in class Object
      Returns:
      This string.