Class EdgePriorScore

java.lang.Object
edu.cmu.tetrad.search.score.EdgePriorScore
All Implemented Interfaces:
Score

public class EdgePriorScore extends Object implements Score
Wraps a Score and adds an independent Bernoulli prior on each adjacency.

Placing an independent prior on each unordered pair {i, j}, with the adjacency present with probability p_ij, gives (up to an additive constant that does not depend on the graph)

  log P(G) = sum over adjacencies {i,j} in G of beta_ij,   beta_ij = log(p_ij / (1 - p_ij)).
On the 2 log L scale that SemBicScore lives on, twice the log-posterior is therefore the score plus 2 * sum(beta_ij) over present adjacencies, and this class adds the local share of that term:
  s'(Y | S) = s(Y | S) + 2 * sum over X in S of beta_XY.

The effect on the local decision is exactly a per-edge rebate on the BIC penalty: adding X to the parents of Y is accepted iff

  -n log(1 - r^2_{XY.S}) > lambda log(n) - 2 beta_XY,
so a prior favouring the edge (beta > 0) lowers the toll and a prior against it raises the toll. This is the classical structure prior of Heckerman, Geiger and Chickering (1995), specialised to per-pair rather than uniform log-odds.

Two properties are preserved, and both matter. First, decomposability: in a DAG each adjacency is oriented exactly one way, so beta_XY is charged to exactly one local score, the child's, and nothing is double counted. Second, score equivalence: the prior is a function of the skeleton only, and all DAGs in a Markov equivalence class share a skeleton, so the prior term is constant within a class. BOSS's permutation search and FGES's forward and backward phases are therefore unaffected in their correctness arguments. Both properties fail for priors on oriented edges, which is why EdgePriors refuses an asymmetric matrix. Genuinely directional prior information belongs in background knowledge, not here.

Scale. The factor of 2 assumes the delegate is on the 2 log L scale with penalty lambda k log(n) per parameter, as SemBicScore is. A delegate carrying a different constant multiple of log L needs beta rescaled by the same constant; the invariant to match is the lambda log(n) toll per added parent.

Author:
josephramsey
See Also:
  • Constructor Details

    • EdgePriorScore

      public EdgePriorScore(Score score, EdgePriors priors)
      Constructs a prior-adjusted score.
      Parameters:
      score - The score to wrap; typically a SemBicScore.
      priors - Prior log-odds, keyed by variable name. Resolved against score.getVariables() here, once, so that the caller's matrix ordering is irrelevant.
      Throws:
      IllegalStateException - If priors does not hold log-odds.
      IllegalArgumentException - If priors mentions variables the score does not have.
  • Method Details

    • localScore

      public double localScore(int node, int... parents)
      Returns the local score of a node given its parents, with the prior term added.
      Specified by:
      localScore in interface Score
      Parameters:
      node - The node.
      parents - The parents.
      Returns:
      The score.
    • localScoreDiff

      public double localScoreDiff(int x, int y, int[] z) throws InterruptedException
      Returns the score difference for adding x to the parents of y given z.

      Overridden rather than inherited so that the delegate's own optimised difference is used where it has one. The result is identical to the interface default applied to localScore(int, int...): every beta term for the parents in z cancels between the two local scores, leaving exactly 2 beta_xy.

      Specified by:
      localScoreDiff in interface Score
      Parameters:
      x - A node.
      y - The node.
      z - A set of nodes.
      Returns:
      The score difference.
      Throws:
      InterruptedException - If the operation is interrupted.
    • localScoreDiff

      public double localScoreDiff(int x, int y)
      Returns the score difference for adding x to the parents of y with no other parents.
      Specified by:
      localScoreDiff in interface Score
      Parameters:
      x - A node.
      y - The node.
      Returns:
      The score difference.
    • getVariables

      public List<Node> getVariables()
      Returns the variables of the score.
      Specified by:
      getVariables in interface Score
      Returns:
      This list.
    • getSampleSize

      public int getSampleSize()
      Returns the sample size of the data.
      Specified by:
      getSampleSize in interface Score
      Returns:
      This size.
    • isEffectEdge

      public boolean isEffectEdge(double bump)
      Returns true iff the edge between x and y is an effect edge.
      Specified by:
      isEffectEdge in interface Score
      Parameters:
      bump - The bump.
      Returns:
      True iff so.
    • getMaxDegree

      public int getMaxDegree()
      Returns the max degree.
      Specified by:
      getMaxDegree in interface Score
      Returns:
      The max degree.
    • determines

      public boolean determines(List<Node> z, Node y)
      Returns true iff the score determines the edge between the given nodes.
      Specified by:
      determines in interface Score
      Parameters:
      z - The set of nodes.
      y - The node.
      Returns:
      True iff so.
    • getWrappedScore

      public Score getWrappedScore()
      Returns the wrapped score.
      Returns:
      The delegate.
    • toString

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