mcmc: Metropolis-Hastings Simulation

Description Usage Arguments Value Examples

View source: R/mcmc.R

Description

Perform Metropolis-Hastings simulation over space of directed acyclic graphs.

Usage

1
2
3
4
mcmc(start.nw, dataset, reporter, Nsim = 1000, burn = 0.1, verbose = TRUE,
  trace = FALSE, score = BICbnnet, whitelist = NULL, blacklist = NULL,
  lprior = log.prior, move.score = NULL, move.lprior = NULL,
  move.proposals = NULL)

Arguments

start.nw

Starting network

dataset

Data frame with observations

reporter

Statistic to be generated

Nsim

Number of simulations

burn

Proportion of simulations to be used as a burn-in

verbose

If TRUE then report messanges and plots will be given

trace

If TRUE then all reporter values are given, not just the average

score

A function to calculate BIC

whitelist

For move proposal, 2-column matrix or data.frame with compulsory edges (vertices as numbers)

blacklist

For move proposal, 2-column matrix or data.frame with forbidden edges (vertices as numbers)

lprior

Log of prior distribution of acyclic directed graph

move.score

A function to adjust the score to addition / removal / reversal of an edge

move.lprior

A function to adjust the log-prior to addition / removal / reversal of an edge

move.proposals

A function to adjust the proposals to addition / removal / reversal of an edge

Value

Either average or all reporter values based on trace settings.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
rg <- tabu(gaussian.test)
nw <- import.bnlearn(rg)

number.of.edges <- function(nw) sum(nw$adjmat)
ne.dist <- mcmc(nw, gaussian.test, number.of.edges, verbose=FALSE, trace=TRUE)
table(do.call("c", ne.dist$trace)[101:1000]) / 900

all.edges <- function(nw) nw$adjmat
A <- mcmc(nw, gaussian.test, all.edges, verbose=FALSE, trace=FALSE)
strength.plot(export.bnlearn(nw), matrix2strength(A, nw$nodes))

simecek/mhnet documentation built on May 29, 2019, 10:01 p.m.