Class EdgePriorScore
- All Implemented Interfaces:
Score
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 Summary
ConstructorsConstructorDescriptionEdgePriorScore(Score score, EdgePriors priors) Constructs a prior-adjusted score. -
Method Summary
Modifier and TypeMethodDescriptionbooleandetermines(List<Node> z, Node y) Returns true iff the score determines the edge between the given nodes.intReturns the max degree.intReturns the sample size of the data.Returns the variables of the score.Returns the wrapped score.booleanisEffectEdge(double bump) Returns true iff the edge between x and y is an effect edge.doublelocalScore(int node, int... parents) Returns the local score of a node given its parents, with the prior term added.doublelocalScoreDiff(int x, int y) Returns the score difference for adding x to the parents of y with no other parents.doublelocalScoreDiff(int x, int y, int[] z) Returns the score difference for adding x to the parents of y given z.toString()Returns a string representation of this score.Methods inherited from interface Score
append, getMissingValueSupport, getVariable, localScore, localScore
-
Constructor Details
-
EdgePriorScore
Constructs a prior-adjusted score.- Parameters:
score- The score to wrap; typically aSemBicScore.priors- Prior log-odds, keyed by variable name. Resolved againstscore.getVariables()here, once, so that the caller's matrix ordering is irrelevant.- Throws:
IllegalStateException- Ifpriorsdoes not hold log-odds.IllegalArgumentException- Ifpriorsmentions 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:
localScorein interfaceScore- Parameters:
node- The node.parents- The parents.- Returns:
- The score.
-
localScoreDiff
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:
localScoreDiffin interfaceScore- 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:
localScoreDiffin interfaceScore- Parameters:
x- A node.y- The node.- Returns:
- The score difference.
-
getVariables
Returns the variables of the score.- Specified by:
getVariablesin interfaceScore- Returns:
- This list.
-
getSampleSize
public int getSampleSize()Returns the sample size of the data.- Specified by:
getSampleSizein interfaceScore- Returns:
- This size.
-
isEffectEdge
public boolean isEffectEdge(double bump) Returns true iff the edge between x and y is an effect edge.- Specified by:
isEffectEdgein interfaceScore- Parameters:
bump- The bump.- Returns:
- True iff so.
-
getMaxDegree
public int getMaxDegree()Returns the max degree.- Specified by:
getMaxDegreein interfaceScore- Returns:
- The max degree.
-
determines
Returns true iff the score determines the edge between the given nodes.- Specified by:
determinesin interfaceScore- Parameters:
z- The set of nodes.y- The node.- Returns:
- True iff so.
-
getWrappedScore
-
toString
-