biips_pimh_init: Create a PIMH object.

Description Usage Arguments Value See Also Examples

View source: R/pimh.r

Description

The function biips_pimh_init initializes the Particle Independent Metropolis-Hastings (PIMH) algorithm.

The PIMH algorithm provides MCMC samples of the variables in variable_names, using a SMC algorithm as proposal distribution in an independent Metropolis-Hastings (MH) algorithm.

Usage

1
biips_pimh_init(model, variable_names)

Arguments

model

biips model object as returned by biips_model.

variable_names

character vector. The names of the unobserved variables to monitor. Names can contain subset indices which must define a valid subset of the variables of the model, e.g.: c('var1', 'var2[1]', 'var3[1:10]', 'var4[1, 5:10, 3]').

Value

The function biips_pimh_init returns an object of class pimh which can be used to generate samples from the posterior distribution of the monitored variables in variable_names.

An object of class pimh is a list of functions that share a common environment. These functions are meant for internal purpose only. They are used to query information on the current state of the algorithm.

model()

Get the biips model object.

variable_names()

Get a character vector with the names of the monitored variables.

sample(sample)

Get and set the current sample.

log_marg_like(log_marg_like)

Get and set the current value of the log marginal likelihood.

See Also

biips_model, biips_pimh_update, biips_pimh_samples

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
modelfile <- system.file('extdata', 'hmm.bug', package = 'rbiips')
stopifnot(nchar(modelfile) > 0)
cat(readLines(modelfile), sep = '\n')

data <- list(tmax = 10, p = c(.5, .5), logtau_true = log(1), logtau = log(1))
model <- biips_model(modelfile, data)

n_part <- 50
obj_pimh <- biips_pimh_init(model, c('x', 'c[2:10]'))  # Initialize
is.pimh(obj_pimh)
out_pimh_burn <- biips_pimh_update(obj_pimh, 100, n_part)  # Burn-in
out_pimh <- biips_pimh_samples(obj_pimh, 100, n_part)  # Samples

biips/rbiips documentation built on Nov. 28, 2020, 2:12 p.m.