BNGibbsSampler: Gibbs sampler for Bayesian Networks.

Description Usage Arguments Value See Also

View source: R/mcmc-gibbs.R

Description

Create a MCMC sampler for Bayesian Networks. The sampler samples Bayesian Networks (ie models).

Usage

1
2
3
4
5
6
7
8
  BNGibbsSampler(data, initial = empty(ncol(data) - 1),
    prior = NULL, return = "network",
    logScoreFUN = logScoreMultDirFUN(),
    logScoreParameters = list(hyperparameters = "bdeu"),
    constraint = NULL, statistics = list(nEdges = nEdges),
    maxNumberParents = NULL, moveprobs = c(0, 0, 1, 0),
    verbose = F, keepTape = F, parentsTables = NULL,
    scoresParents = NULL)

Arguments

data

The data.

initial

An object of class 'bn'. The starting value of the MCMC.

prior

A list of functions of the same length as initial that returns the local prior score of the corresponding node, given a numeric vector of parents. The default value NULL uses an improper uniform prior.

return

Either "network" or "contingency".

logScoreFUN

A list of four elements:

offline

A function that computes the logScore of a Bayesian Network

online

A function that incrementally computes the logScore of a Bayesian Network

local

A function that computes the local logScore of a Bayesian Network

prepare

A function that prepares the data, and any further pre-computation required by the logScore functions.

For Multinomial-Dirichlet models, logScoreMultDirFUN returns the appropriate list; for Normal models with Zellner g-priors, logScoreNormalFUN returns the appropriate list.

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 1 if the edge i -> j is required -1 if the edge i -> is excluded. 0 if the edge i -> j is not constrained. 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 bn and return a scalar output. Each item in the list must be named so that it can be referred to.

maxNumberParents

Integer of length 1. The maximum number of parents of any node. A NULL value gives the default restriction of 3.

moveprobs

A numeric vector of length 3. Specifies the probability that moves updating the parent sets of 1, 2 and 3 nodes simultaneously. Must sum to 1.

verbose

A logical of length 1, indicating whether verbose output should be printed.

keepTape

A logical of length 1, indicating whether a full log ('tape') of the MCMC sampler should be kept. Enabling this option can be very memory-intensive.

parentsTables

A list of tables of the form returned by enumerateParentsTable()

scoresParents

A list of the form returned by scoreParentsTable()

Value

A function, which when called draws the next sample of the MCMC.

See Also

BNSampler, BNSamplerBigFlips, BNSamplerPT, BNSamplerMJ, BNSamplerGrzeg. Internally uses samplePair and sampleNode.


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