MCMC_fit_1.2: Second level wrapper for the MCMC fitting procedure. HIGHEST,...

Description Usage Arguments Value See Also

View source: R/mcmc_wrapper_script.R

Description

This is the highest level wrapper function for the MCMC algorithm that can be applied to any generic model, data and likelihood function. Calls another function, MCMC_fit_single to carry out the random walk. This function takes care of formatting the results and carrying out some MCMC diagnostics and plots.

Usage

1
2
3
4
5
MCMC_fit_1.2(temp_dat, param_table, iterations = 1000, opt_freq = 50,
  thin = 1, burnin = 100, adaptive_period = 1, nchain = 1,
  popt = 0.44, filename, LIKELIHOOD_FUNCTION, MODEL_FUNCTION,
  VERBOSE = FALSE, PARALLEL = FALSE, OPTIM_PARAMS = FALSE,
  topdir = paste(getwd(), "/tmp/", sep = ""))

Arguments

temp_dat

the data over which to calculate likelihoods

param_table

table of parameter data as specified in load_param_table

iterations

number of iterations for the MCMC algorithm

opt_freq

how frequently the acceptance rate is adapted. Defaults to 50

thin

thinning value for the MCMC chain. Default is 1

burnin

the length of the burn in period. Defaults to 100

adaptive_period

length of the adaptive period. Defaults to 1

nchain

number of chains to run

popt

the desired acceptance rate. Defaults to 0.44

filename

the generic file name/location at which to save plots and diagnostics. Note that the file extension will be appended to this string

LIKELIHOOD_FUNCTION

a valid pointer to an R function which returns a single, log likelihood of the data given the current parameters

MODEL_FUNCTION

a valid pointer to an R function which is used to evaluate the model for the current set of parameters

VERBOSE

boolean flag for additional output. Defaults to FALSE

PARALLEL

OPTIONAL boolean flag indicating if each MCMC chain should be run in parallel using doPar. Defaults to FALSE

OPTIM_PARAMS

OPTIONAL boolean flag indicating if optim should be used to find the "best fit" parameters. Otherwise the maximum likelihood parameters from the MCMC chain will be used. Defaults to FALSE

topdir

the top level directory where the MCMC chains will be saved. By default, a tmp folder will be created in the home folder

Value

returns a list containing a vector of the maximum likelihood parameters, the time points of the fitted data, and a list of the MCMC chain files

See Also

MCMC_fit_single


jameshay218/mcmcJH documentation built on May 18, 2019, 11:20 a.m.