Description Usage Arguments Value See Also Examples
The function biips_pmmh_init
initializes the Particle Marginal
Metropolis-Hastings (PMMH) algorithm.
The PMMH algorithm is a particle MCMC algorithm using SMC within a MCMC algorithm. It splits the variables in the graphical model into two sets:
The parameters in param_names
are sampled with a MH proposal
(multivariate Gaussian random walk). They must be continuous and must be defined as
single stochastic nodes in the model.
The other latent variables are sampled using a SMC algorithm. They can
be monitored using the latent_names
parameter.
1 2 3 |
model |
|
param_names |
character vector. The names of the variables updated with
MH proposal. The names can contain subset indices which must define a valid
subset of the variables of the model, e.g.: |
latent_names |
character vector. The names of the variables to be updated with SMC proposal that need to be monitored. |
inits |
list of numeric values. Initial values for the parameters
in |
rw_step |
list of numeric values. Random walk standard deviations.
|
transform |
logical. Activate automatic parameters transformation
(default =
so that we apply a random walk on the real-valued transformed vector. |
n_rescale |
integer. Number of iterations for rescaling (default = 400). |
alpha |
real in [0,1]. Tuning parameter of the rescaling (default = 0.99). |
beta |
real in [0,1]. Tuning parameter of the proposal (default = 0.05). |
The function biips_pmmh_init
returns an object of class
pmmh
which can be used to generate samples from the posterior
distribution of the monitored variables in param_names
and
latent_names
.
An object of class pmmh
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 |
param_names() |
Get a character vector with the names of the monitored parameters. |
latent_names() |
Get a character vector with the names of the monitored latents. |
sample_param(sample) |
Get and set the current sample value of the parameters. |
sample_param_tr(sample) |
Get and set the current sample value of the transfromed parameters. |
sample_latent(sample) |
Get and set the current sample value of the latents. |
log_prior(log_prior) |
Get and set the current value of the log prior of the parameters. |
log_marg_like(log_marg_like) |
Get and set the current value of the log marginal likelihood. |
n_iter() |
Get and set the current curent number of iterations. |
n_rescale() |
Get the nb of iterations for rescaling. |
rw_dim() |
Get the dimensions of the parameters. |
rw_len() |
Get the total length of the parameters. |
rw_step() |
Get the random walk standard deviations for the rescaling. |
rw_cov() |
Get the empirical covariance matrix of the samples. |
rw_alpha() |
Get the tuning parameter of the rescaling. |
rw_beta() |
Get the tuning parameter of the proposal. |
rw_transform(sample, funtype = 'transform') |
Applies transformation
function defined by the |
rw_rescale(ar) |
rescales the random walk step to target an optimal acceptance rate. |
rw_learn_cov() |
update the empirical covariance matrix of the samples. |
biips_model
, biips_pmmh_update
,
biips_pmmh_samples
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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))
model <- biips_model(modelfile, data)
n_part <- 50
obj_pmmh <- biips_pmmh_init(model, 'logtau', latent_names = c('x', 'c[2:10]'),
inits = list(logtau = -2)) # Initialize
is.pmmh(obj_pmmh)
out_pmmh_burn <- biips_pmmh_update(obj_pmmh, 100, n_part) # Burn-in
out_pmmh <- biips_pmmh_samples(obj_pmmh, 100, n_part, thin = 1) # Samples
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.