Draw MCMC samples from a model posterior using the No-U-Turn (NUTS) sampler with dual averaging.
sample_tmb_nuts(
iter,
fn,
gr,
init,
warmup = floor(iter/2),
chain = 1,
thin = 1,
seed = NULL,
control = NULL
)
The number of samples to draw.
A function that returns the log of the posterior density.
A function that returns a vector of gradients of the log of
the posterior density (same as fn
).
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., obj$par
) for all chains.
The number of warmup iterations.
The chain number, for printing only.
The thinning rate to apply to samples. Typically not used with NUTS.
The random seed to use.
A list to control the sampler. See details for further use.
This function implements algorithm 6 of Hoffman and Gelman
(2014), which includes adaptive step sizes (eps
) via an
algorithm called dual averaging. It also includes an adaptation scheme
to tune a diagonal mass matrix (metric) during warmup.
These fn
and gr
functions must have Jacobians already
applied if there are transformations used.
Hoffman and Gelman (2014). The No-U-Turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. J. Mach. Learn. Res. 15:1593-1623.
sample_tmb