Skip to contents

Summary

adnuts (pronounced A-D NUTS like A-D MB) provides a wrapper for performing Bayesian analyses using the no-U-turn (NUTS) algorithm (Hoffman and Gelman 2014) for TMB (Kristensen et al. 2016) and ADMB (Fournier et al. 2012) models.

For TMB models the NUTS algorithm is in the Stan software (Carpenter et al. 2017) and linked through the StanEstimators R package. adnuts implements the sparse NUTS (SNUTS) algorithm of (Monnahan et al. in prep) by decorrelating and descaling the posterior distribution prior to passing to Stan. For models with high correlations and sparse precision matrices, SNUTS can substantially improve sampling efficiency. Importantly, it works for TMB and RTMB models, and can be run on models from existing packages.

Basic usage for a TMB or RTMB object obj is shown as follows, with a more in depth article on the website.

fit <- sample_snuts(obj)
print(fit)
plot(fit)
pairs(fit, order='slow')
post <- as.data.frame(fit)
launch_shinytmb(fit)

ADMB models contain the algorithm code internally, but this package provides the user a convenient environment to run and diagnose Markov chains, and make inference. Development for ADMB models is frozen but should maintain backwards compatibility in the near future. This package aims to give ADMB models similar functionality to the software Stan and rstan in particular (Carpenter et al. 2017; Stan Development Team 2017).

Assuming a valid ADMB model located in directory path has been built and optimized successfully, then

fit <- sample_nuts(model='simple', path=path)
print(fit)
plot(fit)
pairs(fit, order='slow')
post <- as.data.frame(fit)
launch_shinyadmb(fit)

History

The package has undergone several shifts in focus. Initially, it was developed to provide a NUTS implementation in R for models where the log-density and log-density gradient could be written as R functions (e.g., TMB). However, the tmbstan package was developed and became the preferred option for TMB users, so the focus switched to ADMB models and TMB functionality was de-emphasized. In 2025, with the development of SNUTS, the primary focus of adnuts was shifted back to TMB models via the SNUTS approach.

References

Carpenter, B., A. Gelman, M. D. Hoffman, D. Lee, B. Goodrich, M. Betancourt, A. Riddell, J. Q. Guo, P. Li, and A. Riddell. 2017. “Stan: A Probabilistic Programming Language.” Journal of Statistical Software 76 (1): 1–29.
Fournier, D. A., H. J. Skaug, J. Ancheta, J. Ianelli, A. Magnusson, M. N. Maunder, A. Nielsen, and J. Sibert. 2012. “AD Model Builder: Using Automatic Differentiation for Statistical Inference of Highly Parameterized Complex Nonlinear Models.” Optimization Methods & Software 27 (2): 233–49.
Hoffman, M. D., and A. Gelman. 2014. “The No-u-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo.” Journal of Machine Learning Research 15 (1): 1593–623.
Kristensen, Kasper, Anders Nielsen, Casper W. Berg, Hans Skaug, and Bradley M. Bell. 2016. “TMB: Automatic Differentiation and Laplace Approximation.” Journal of Statistical Software 70 (5): 21.
Monnahan, C. C., Thorson J. T., K. Kristensen, and B. Carpenter. in prep. “Leveraging Sparsity to Improve No-u-Turn Sampling Efficiency for Hierarchical Bayesian Models.” arXiv Preprint, in prep.
Stan Development Team. 2017. “Stan Modeling Language Users Guide and Reference Manual, Version 2.17.0.”