Skip to contents

[Deprecated] Draw MCMC samples from a model posterior using a Random Walk Metropolis (RWM) sampler.

Usage

sample_tmb_rwm(
  iter,
  fn,
  init,
  alpha = 1,
  chain = 1,
  warmup = floor(iter/2),
  thin = 1,
  seed = NULL,
  control = NULL
)

Arguments

iter

The number of samples to draw.

fn

A function that returns the log of the posterior density.

init

Can be either a list containing a vector for each chain, a function which returns a vector of parameters, or NULL which specifies to use the MLE as stored in the admodel.hes file. It is generally recommended to use dispersed initial values to improve diagnostic checks (starting from the same point makes it less likely to find multiple modes).

alpha

The amount to scale the proposal, i.e, Xnew=Xcur+alpha*Xproposed where Xproposed is generated from a mean-zero multivariate normal. Varying alpha varies the acceptance rate.

chain

The chain number, for printing only.

warmup

The number of warmup iterations.

thin

The thinning rate to apply to samples. Typically not used with NUTS.

seed

The random seed to use.

control

A list to control the sampler. See details for further use.

Value

A list containing samples and other metadata.

Details

This algorithm does not yet contain adaptation of alpha so some trial and error may be required for efficient sampling.

References

Metropolis, N., Rosenbluth, A.W., Rosenbluth, M.N., Teller, A.H., Teller, E., 1953. Equation of state calculations by fast computing machines. J Chem Phys. 21:1087-1092.

See also