Run a pmcmc sampler

pmcmc(pars, filter, initial = NULL, control = NULL)

Arguments

pars

A pmcmc_parameters object containing information about parameters (ranges, priors, proposal kernel, translation functions for use with the particle filter).

filter

A particle_filter object

initial

Optional initial starting point. If given, it must be compatible with the parameters given in pars, and must be valid against your prior. You can use this to override the initial conditions saved in your pars object. You can provide either a vector of initial conditions, or a matrix with n_chains columns to use a different starting point for each chain.

control

A pmcmc_control object which will control how the MCMC runs, including the number of steps etc.

Value

A mcstate_pmcmc object containing pars

(sampled parameters) and probabilities (log prior, log likelihood and log posterior values for these probabilities). Two additional fields may be present: state (if return_state was TRUE), containing the final state of a randomly selected particle at the end of the simulation, for each step (will be a matrix with as many rows as your state has variables, and as n_steps + 1 columns corresponding to each step). trajectories will include a 3d array of particle trajectories through the simulation (if return_trajectories was TRUE).

Details

This is a basic Metropolis-Hastings MCMC sampler. The filter is run with a set of parameters to evaluate the likelihood. A new set of parameters is proposed, and these likelihoods are compared, jumping with probability equal to their ratio. This is repeated for n_steps proposals.

While this function is called pmcmc and requires a particle filter object, there's nothing special about it for particle filtering. However, we may need to add things in the future that make assumptions about the particle filter, so we have named it with a "p".