MCMC_CMR: An adaptive Markov chain Monte Carlo sampler for estimating...

Description Usage Arguments Value

View source: R/MCMC_CMR.R

Description

After generating a model using make_BayesCMR, this function will sample the posterior. Default settings work relatively well for smaller models, but output needs to be checked for convergence (and more iterations are often necessary for models with many parameters). The sampler uses a covariance scaling to achieve good mixing. First half of the iterations are burning, and continually the proposals widths are tuned. The covariance structure of the samples in this burnin phase is used for proposals in the latter half.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
MCMC_CMR(
  cmrModel,
  niter = 10000,
  nthin = 10,
  vmin = 1e-05,
  draweps = niter/noblc,
  noblc = 100,
  x0 = NULL,
  cvstp = (2.38/(sqrt(cmrModel$npar)))^2 * diag(1, cmrModel$npar),
  adapt = TRUE
)

Arguments

cmrModel

is a CMR_model generated using make_BayesCMR

niter

is number of iterations. Defaults to niter = 1e3. Default is generally only sufficient for models with only mean rates and no drivers.

nthin

sets the thinning, i.e. samples for each nthin iterations are stored as output. Defaults to nthin = 10.

vmin

sets the minimum and initial standard deviation of the normal proposals.

draweps

number of iterations between each update of the proposal covariance matrix. Defaults to draweps = niter/100.

cvstp

Covariance structure for proposal. This is tuned during burnin phase. Defaults to (2.38/(sqrt(cmrModel$npar)))^2*diag(vmin,cmrModel$npar))

adapt

Adapt the covariance proposals during first half?

x_init

Potential initial values for the chain. If not provided the initial mean rates are optimized using the probability density function and all other parameters set to 0.

Value

A CMR_fit structure with $Chain for samples, $Probs for posterior probabilities, $Accept with number of accepted proposals in each block, $Model is the CMR_model supplied as input, $Covs is the proposal covariance structure used in the last half of the chain.


josteist/Compadre documentation built on June 3, 2021, 1:02 p.m.