priorGraph: A standard 'graph prior'.

Description Usage Arguments Details Value See Also Examples

View source: R/priors.R

Description

Returns a function that will evaluate the prior of a graph. The prior is

Usage

1
  priorGraph(graph, lambda)

Arguments

graph

The 'prior graph'. A bn.

lambda

A weighting parameter. A numeric of length 1.

Details

f(x) = exp( - lambda * (edges(x) - edges(graph)))

So the prior scores more highly those graphs x that include all the edges in the graph graph; extra edges are penalised; the prior is maximised (not uniquely) at the empty graph.

Value

A function computes the prior score of the supplied graph. This This function is of a suitable form to be used as a prior.

See Also

priorUniform

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x1 <- factor(c("a", "a", "g", "c", "c", "a", "g", "a", "a"))
x2 <- factor(c(2, 2, 4, 3, 1, 4, 4, 4, 1))
x3 <- factor(c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE))
x <- data.frame(x1 = x1, x2 = x2, x3 = x3)

priorgraph <- bn(c(), 1, 2)
prior <- priorGraph(priorgraph, 0.5)

initial <- empty(3, "bn")
sampler <- BNSampler(data = x, initial = initial, prior = prior)
samples <- draw(sampler, n = 100, burnin = 10)

x <- bnpostmcmc(sampler, samples)
ep(x)

rjbgoudie/structmcmc documentation built on Nov. 3, 2020, 3:41 a.m.