draw: Draw samples from a MCMC sampler.

Description Usage Arguments See Also Examples

View source: R/mcmc.R

Description

Draws samples from an MCMC sampler. The length of the run can be specified either by the number of samples to be drawn, or the length of time that the sampler runs.

Usage

1
2
  draw(sampler, n = F, time = F, burnin = 0, thin = 1,
    verbose = T)

Arguments

sampler

A sampler object

n

The number of samples to draw. Set this to FALSE if using the time argument.

time

The number of seconds to spend drawing samples. Set this to FALSE if using the n argument.

burnin

The number of samples to discard from the beginning of the sample.

thin

The frequency with which samples should be kept. eg for thin = 3, every third sample will be kept.

verbose

A logical. Should a progress bar be displayed?

See Also

drawSamplesByTime, drawSamplesByStepCount. BNSampler, BNGibbsSampler, BNSamplerMJ

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(310)
x1 <- factor(c(1, 1, 0, 1))
x2 <- factor(c(0, 1, 0, 1))
dat <- data.frame(x1 = x1, x2 = x2)

prior <- function(net) 1
initial <- bn(c(), c())

sampler <- BNSampler(dat, initial, prior)
samples <- draw(sampler, n = 5)

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