run_metropolis_MCMC: Adaptive Metropolis-within-Gibbs Random Walk Algorithm.

Description Usage Arguments Value See Also

View source: R/OLD.R

Description

The Adaptive Metropolis-within-Gibbs algorithm. Given a starting point and the necessary MCMC parameters as set out below, performs a random-walk of the posterior space to produce an MCMC chain that can be used to generate MCMC density and iteration plots. The algorithm undergoes an adaptive period, where it changes the step size of the random walk for each parameter to approach the desired acceptance rate, popt. After this, a burn in period is established, and the algorithm then uses proposalfunction to explore the parameter space, recording the value and posterior value at each step. The MCMC chain is saved in blocks as a .csv file at the location given by filename.

Usage

1
2
3
run_metropolis_MCMC(data = NULL, ts, parTab, mcmcPars, filename,
  mvrPars = NULL, incDat = NULL, peakTimes = NULL, allPriors = NULL,
  truePars = NULL, version = "normal")

Arguments

data

the microcephaly data against which the likelihood is calculated

ts

vector of times to solve the ODE model over

parTab

a table of parameter data used for information such as bounds and prior function pointers.

mcmcPars

a named vector with parameters for the MCMC procedure. Iterations, popt, opt_freq, thin, burnin, adaptive_period and save_block.

filename

the full filepath at which the MCMC chain should be saved. "_chain.csv" will be appended to the end of this, so filename should have no file extensions

mvrPars

a list of parameters if using a multivariate proposal. Must contain an initial covariance matrix, weighting for adapting cov matrix, and an initial scaling parameter (0-1)

incDat

optional data frame of incidence data if including incidence data in the likelihood function

peakTimes

optional parameter - data frame of peak times for Zika incidence for each state

allPriors

user function of prior for model parameters. Should take values, names and local from parTab

version

usually just leave this as "normal". I've added a "forecast" version which expects parameters to do with the lack of second wave.

Value

a list with: 1) full file path at which the MCMC chain is saved as a .csv file; 2) the last used covarianec matrix; 3) the last used scale size

See Also

posterior_complex_buckets, proposalfunction


jameshay218/zikaProj documentation built on Jan. 9, 2020, 7:26 p.m.