MCMC_fit_1.1: First level wrapper function for the MCMC algorithm.

Description Usage Arguments Details Value See Also

View source: R/mcmc_wrapper_2.R View source: R/mcmc_wrapper_script.R

Description

Function to provide MCMC (Adaptive Metropolis within Gibbs) fits to all data subsets from a given data frame. No return value - all relevant outputs are saved as .csv files. Brief desription:

Usage

1
2
3
4
5
6
MCMC_fit_1.1(top_dir, all_data, output_file = NULL, file_strains, param_table,
  iterations = 1000, opt_freq = 50, thin = 50, burnin = 100,
  adaptive_period = 1, nchain = 1, popt = 0.44, group = NULL,
  lower_plot_bound = 0, upper_plot_bound = 15, LIKELIHOOD_FUNCTION = NULL,
  MODEL_FUNCTION = NULL, VERBOSE = FALSE, infection_times = NULL,
  SKIP_ZEROES = FALSE)

Arguments

top_dir

location of the top level directory to work in

all_data

data frame of the data to be fit. Should be of the form "group", "strain", "variable", "value", where variable is the numeric time point and value is the titre level

output_file

(OPTIONAL) - should be a text file to output model fitting printouts

param_table

the data.frame version of the parameter table read in from the .csv file above. See 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

group

the name of the current group under investigation. Mostly just used to create a directory for the group specific results

lower_plot_bound

lowest value to be plotted ont he y axis for model trajectory. Defaults to 0

upper_plot_bound

highest value to be plotted ont he y axis for model trajectory. Defaults to 15

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

flag for additional output. Defaults to FALSE

infection_times

an optional vector of infection event labels and times to be plotted on the model graph

SKIP_ZEROES

optional flag indicating whether or not all zero value groups should be skipped. Defaults to FALSE

Details

Firstly, sets up number of cores to be used. If only one chain, then parallelises the strains. If more than one chain, puts each chain on a different core instead. Checks for any all-zero data, and removes these from further analysis. Goes through each group in the data frame and creates a new directory for each. Gets the number of strains to be fitted and goes through each one (parallel or sequentially depending on number of cores)

Value

returns nothing!

See Also

MCMC_fit_1.2


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