Sets up an HMC/NUTS configuration via nimbleHMC, compiles the MCMC, runs it, and returns basic diagnostics.
Arguments
- build_fn
A function that builds the model and returns at least a list with components
modelandconf.- niter, nburnin, thin
Integers; MCMC iterations, burn-in, and thinning.
- monitors
Character vector of node names to monitor.
- nchains
Integer; number of chains to run.
- out_dir
Character or
NULL; if notNULL, figures are saved there.
Value
A list with elements:
- conf
The configured MCMC configuration.
- res
Raw run output (samples, runtime, …).
- diag_tbl
A data frame of diagnostics (e.g., R-hat, ESS/s).
Examples
if (FALSE) { # \dontrun{
out <- configure_hmc_safely(
build_fn = my_build_fn, niter = 2000, nburnin = 1000, thin = 1,
monitors = c("beta[1]", "sigma"), nchains = 4, out_dir = "outputs"
)
out$diag_tbl
} # }