| Literature DB >> 29795657 |
Cole C Monnahan1,2, Kasper Kristensen3.
Abstract
Statistical inference is a widely-used, powerful tool for learning about natural processes in diverse fields. The statistical software platforms AD Model Builder (ADMB) and Template Model Builder (TMB) are particularly popular in the ecological literature, where they are typically used to perform frequentist inference of complex models. However, both lack capabilities for flexible and efficient Markov chain Monte Carlo (MCMC) integration. Recently, the no-U-turn sampler (NUTS) MCMC algorithm has gained popularity for Bayesian inference through the software Stan because it is efficient for high dimensional, complex hierarchical models. Here, we introduce the R packages adnuts and tmbstan, which provide NUTS sampling in parallel and interactive diagnostics with ShinyStan. The ADMB source code was modified to provide NUTS, while TMB models are linked directly into Stan. We describe the packages, provide case studies demonstrating their use, and contrast performance against Stan. For TMB models, we show how to test the accuracy of the Laplace approximation using NUTS. For complex models, the performance of ADMB and TMB was typically within +/- 50% the speed of Stan. In one TMB case study we found inaccuracies in the Laplace approximation, potentially leading to biased inference. adnuts provides a new method for estimating hierarchical ADMB models which previously were infeasible. TMB users can fit the same model in both frequentist and Bayesian paradigms, including using NUTS to test the validity of the Laplace approximation of the marginal likelihood for arbitrary subsets of parameters. These software developments extend the available statistical methods of the ADMB and TMB user base with no additional effort by the user.Entities:
Mesh:
Year: 2018 PMID: 29795657 PMCID: PMC5967695 DOI: 10.1371/journal.pone.0197954
Source DB: PubMed Journal: PLoS One ISSN: 1932-6203 Impact factor: 3.240
Summary of key functions from R packages.
| Function | Purpose |
|---|---|
| Run NUTS or RWM chains. Options include parallel chains, specification of the mass matrix, and fine tuning of the NUTS algorithm parameters. Returns a list containing samples (samples), NUTS meta data for each iteration (sampler_params), and other information. | |
| Extract samples from fitted object, including flags whether to include warmup samples and the log posterior column. | |
| Launch the interactive diagnostic tool ShinyStan for an ADMB fit for both NUTS and RWM chains. | |
| Extract NUTS trajectory metadata, such as acceptance probabilities, divergences, and tree depths. | |
| A modified pairs plot that works specifically for ADMB fits. Includes option to add a covariance matrix estimated by inverting the Hessian matrix evaluated at the maximum likelihood point, if it exists. | |
| Wrapper to pass TMB model to function |
NUTS is the no-U-turn sampler and RWM is the random walk Metropolis algorithm (the original ADMB algorithm). All functions are from the adnuts package, except tmbstan which is from the tmbstan package.
Fig 1Testing the Laplace approximation of the random effects.
Bayesian integration was performed on the wildflower TMB model with random effects integrated using two “versions”: (1) the Laplace approximation and (2) full MCMC integration via NUTS. Bayesian posterior samples of selected fixed effects (estimated with NUTS) are shown. Columns and rows corresponds to a fixed effect parameter, with the diagonal showing a QQ-plot of the two versions of the model for that parameter, including a 1:1 line in gray. Lower diagonal plots contain pairwise parameter posterior points, with color corresponding to integration version, and larger colored circles the pairwise medians. Posterior rows were randomized to prevent consistent overplotting of one version. Differences in versions suggest the Laplace approximation assumptions are not met. Other fixed effects showed no differences and are left off for clarity.
Fig 2Testing the Laplace approximation integration of the random effects.
Same as for Fig 1 except for three hypervariances and a slope parameter in the swallows model.