sample_tmb_hmc {adnuts} | R Documentation |
Draw MCMC samples from a model posterior using a static HMC sampler.
Description
Draw MCMC samples from a model posterior using a static HMC sampler.
Usage
sample_tmb_hmc(
iter,
fn,
gr,
init,
L,
eps,
warmup = floor(iter/2),
seed = NULL,
chain = 1,
thin = 1,
control = NULL
)
Arguments
iter |
The number of samples to draw. |
fn |
A function that returns the log of the posterior density. |
gr |
A function that returns a vector of gradients of the log of
the posterior density (same as |
init |
A list of lists containing the initial parameter
vectors, one for each chain or a function. It is strongly
recommended to initialize multiple chains from dispersed
points. A of NULL signifies to use the starting values
present in the model (i.e., |
L |
The number of leapfrog steps to take. The NUTS algorithm does
not require this as an input. If |
eps |
The step size. If a numeric value is passed, it will be used
throughout the entire chain. A |
warmup |
The number of warmup iterations. |
seed |
The random seed to use. |
chain |
The chain number, for printing only. |
thin |
The thinning rate to apply to samples. Typically not used with NUTS. |
control |
A list to control the sampler. See details for further use. |
Details
This function implements algorithm 5 of Hoffman and Gelman
(2014), which includes adaptive step sizes (eps
) via an
algorithm called dual averaging.
Value
A list containing samples ('par') and algorithm details such as step size adaptation and acceptance probabilities per iteration ('sampler_params').
References
Neal, R. M. (2011). MCMC using Hamiltonian dynamics. Handbook of Markov Chain Monte Carlo.
Hoffman and Gelman (2014). The No-U-Turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. J. Mach. Learn. Res. 15:1593-1623.
Hoffman and Gelman (2014). The No-U-Turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. J. Mach. Learn. Res. 15:1593-1623.