Description Usage Arguments Value See Also Examples
The sampler samples Bayesian Networks (ie models).
1 2 3 4 5 | BNSampler(data, initial, prior, return = "network",
logScoreFUN = logScoreMultDirFUN(),
logScoreParameters = list(hyperparameters = "bdeu"),
constraint = NULL, statistics = list(nEdges = nEdges),
maxNumberParents = NULL, verbose = F, keepTape = F)
|
data |
The data. |
initial |
An object of class 'bn'. The starting value of the MCMC. |
prior |
EITHER A function that returns the prior
score of the supplied bn. OR A list of functions of the
same length as |
return |
Either "network" or "contingency". |
logScoreFUN |
A list of four elements:
For
Multinomial-Dirichlet models,
|
logScoreParameters |
A list of parameters that are passed to logScoreFUN. |
constraint |
A matrix of dimension ncol(data) x ncol(data) giving constraints to the sample space. The (i, j) element is:
The diagonal of constraint must be all 0. |
statistics |
A named list of functions which should
be applied to the current network after each step. Each
function should accept an object of class |
maxNumberParents |
Integer of length 1. The maximum
number of parents of any node. The default value, which
is used for |
verbose |
A logical of length 1, indicating whether verbose output should be printed. |
keepTape |
A logical of length 1, indicating whether
a full log ( |
A function, which when called draws the next sample of the MCMC.
draw
. BNSamplerMJ
,
BNSamplerPT
, BNGibbsSampler
.
Example priors priorGraph
,
priorUniform
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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)
initial <- empty(3, "bn")
prior <- priorUniform(initial)
sampler <- BNSampler(data = x, initial = initial, prior = prior)
samples <- draw(sampler, n = 100, burnin = 10)
x <- bnpostmcmc(sampler, samples)
ep(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.