sample_pmcmc: Sample PMCMC

View source: R/pmcmc_utils.R

sample_pmcmcR Documentation

Sample PMCMC

Description

Sample from the posterior probability results produced by run_mcmc_chain to select parameter set. For each parmater set sampled, run particle filter with num_particles and sample 1 trajectory

Usage

sample_pmcmc(
  pmcmc_results,
  burnin = 0,
  n_chains,
  log_likelihood = calc_loglikelihood,
  n_trajectories = 10,
  n_particles = 100,
  forecast_days = 0
)

Arguments

pmcmc_results

output of run_mcmc_chain; The results from the PMCMC run – can have mutliple chains.

burnin

integer; Number of iterations to discard from the start of MCMC run. Default = 0

n_chains

number of chains that considered. Should inherent from pmcmc.

log_likelihood

function to calculate log likelihood, must take named parameter vector as input, allow passing of implicit arguments corresponding to the main function arguments. Returns a named list, with entries: - $log_likelihood, a single numeric - $sample_state, a numeric vector corresponding to the state of a single particle, chosen at random, at the final time point for which we have data. If NULL, calculated using the function calc_loglikelihood.

n_trajectories

interger; Number of trajectories to be returned. Integer. Default = 10.

n_particles

integer; Number of particles to be considered in the particle filter. Default = 100

forecast_days

integer; number of days being forecast. Default = 0

Value

trajectories

A 3-dimensional array of trajectories (time, state, tranjectories).

sampled_PMCMC_Results

The parameters chosen when sampling from the pmcmc posteriors

inputs

A list of model inputs.


mrc-ide/squire documentation built on Sept. 10, 2022, 1:11 a.m.