Run MCMC either with or without parallel tempering turned on.
Minimum inputs include a data object, a data.frame of parameters, a
log-likelihood function and a log-prior function. Produces an object of
class drjacoby_output
, which contains all MCMC output along with
some diagnostics and a record of inputs.
run_mcmc( data, df_params, misc = list(), loglike, logprior, burnin = 1000, samples = 10000, rungs = 1, chains = 5, beta_manual = NULL, alpha = 1, target_acceptance = 0.44, cluster = NULL, coupling_on = TRUE, pb_markdown = FALSE, save_data = TRUE, save_hot_draws = FALSE, silent = FALSE )
data | a named list of numeric data values. When using C++ likelihood
and/or prior these values are treated internally as doubles, so while
integer and Boolean values can be used, keep in mind that these will be
recast as doubles in the likelihood (i.e. |
---|---|
df_params | a data.frame of parameters (see |
misc | optional list object passed to likelihood and prior. This can be useful for passing values that are not strictly data, for example passing a lookup table to the prior function. |
loglike, logprior | the log-likelihood and log-prior functions used in the MCMC. Can either be passed in as R functions (not in quotes), or as character strings naming compiled C++ functions (in quotes). |
burnin | the number of burn-in iterations. Automatic tuning of proposal standard deviations is only active during the burn-in period. |
samples | the number of sampling iterations. |
rungs | the number of temperature rungs used in the parallel tempering
method. By default, \(\beta\) values are equally spaced between 0 and 1,
i.e. \(\beta[i]=\) |
chains | the number of independent replicates of the MCMC to run. If a
|
beta_manual | vector of manually defined \(\beta\) values used in the
parallel tempering approach. If defined, this overrides the spacing defined
by |
alpha | the likelihood for the ith heated chain is raised to the power \(\beta[i]^\alpha\), meaning we can use the \(\alpha\) parameter to concentrate rungs towards the start or the end of the temperature scale. |
target_acceptance | Target acceptance rate. Should be between 0 and 1. Default of 0.44, set as optimum for unvariate proposal distributions. |
cluster | option to pass in a cluster environment, allowing chains to be run in parallel (see package "parallel"). |
coupling_on | whether to implement Metropolis-coupling over temperature
rungs. The option of deactivating coupling has been retained for general
interest and debugging purposes only. If this parameter is |
pb_markdown | whether to run progress bars in markdown mode, meaning they are only updated when they reach 100% to avoid large amounts of output being printed to markdown files. |
save_data | if |
save_hot_draws | if |
silent | whether to suppress all console output. |
Note that both data
and misc
are passed into
log-likelihood/log-prior functions *by reference*. This means if you modify
these objects inside the functions then any changes will persist.