[Paper Review] Implementing Approximate Bayesian Inference using Adaptive Quadrature: the aghq Package
This paper introduces the aghq R package for approximate Bayesian inference using adaptive Gauss-Hermite quadrature (AGHQ), enabling efficient posterior computation in complex, high-dimensional models—particularly latent Gaussian models and zero-inflated spatial regression—by leveraging the TMB interface for automatic differentiation and Laplace approximation. The method achieves accurate inference with minimal code changes for existing TMB users, demonstrating strong performance across low- and high-dimensional problems including infectious disease and astrostatistical models.
The aghq package for implementing approximate Bayesian inference using adaptive quadrature is introduced. The method and software are described, and use of the package in making approximate Bayesian inferences in several challenging low- and high-dimensional models is illustrated. Examples include an infectious disease model; an astrostatistical model for estimating the mass of the Milky Way; two examples in non-Gaussian model-based geostatistics including one incorporating zero-inflation which is not easily fit using other methods; and a model for zero-inflated, overdispersed count data. The aghq package is especially compatible with the popular TMB interface for automatic differentiation and Laplace approximation, and existing users of that software can make approximate Bayesian inferences with aghq using very little additional code. The aghq package is available from CRAN and complete code for all examples in this paper can be found at https://github.com/awstringer1/aghq-software-paper-code.
Motivation & Objective
- To develop a user-friendly R package for approximate Bayesian inference using adaptive quadrature, especially for models with complex likelihoods and high dimensionality.
- To extend the capabilities of existing TMB-based inference by enabling full posterior approximation through AGHQ, not just Laplace approximation.
- To address challenging models—such as zero-inflated geostatistical and overdispersed count models—that are difficult to fit with standard packages like INLA or MCMC.
- To provide a scalable, efficient alternative to MCMC and other methods for models where exact posterior computation is infeasible.
Proposed method
- Adaptive Gauss-Hermite Quadrature (AGHQ) is used to approximate the marginal likelihood by shifting and scaling quadrature nodes and weights based on the posterior mode and curvature.
- The method integrates with the TMB package, reusing its automatic differentiation and Laplace approximation infrastructure to compute the unnormalized log-posterior and its gradient efficiently.
- The aghq package uses TMB’s MakeADFun to generate a template function that returns the log-marginal likelihood under Laplace approximation, which is then passed to aghq::marginal_laplace_tmb for AGHQ refinement.
- For high-dimensional models, multiple AGHQ evaluations with increasing quadrature points recover the marginal Laplace approximation, improving accuracy without excessive computational cost.
- The approach supports models with latent Gaussian processes, zero-inflation, and overdispersion by modeling the likelihood as a mixture of point masses and binomial components.
- The implementation is designed to be backward-compatible with existing TMB code, requiring minimal changes to add approximate Bayesian inference.
Experimental results
Research questions
- RQ1Can adaptive quadrature be effectively used to approximate the marginal likelihood in high-dimensional, non-Gaussian models where MCMC is computationally prohibitive?
- RQ2How does AGHQ-based inference compare to MCMC, INLA, and MCML in terms of accuracy and computational efficiency for complex spatial and count models?
- RQ3To what extent can the aghq package extend the scope of TMB-based inference beyond Laplace approximation to enable full Bayesian posterior inference?
- RQ4Can AGHQ handle zero-inflated and overdispersed count data models that are not compatible with INLA or standard GLMMs?
- RQ5What is the computational cost of AGHQ relative to MCMC when achieving comparable posterior coverage and point estimates?
Key findings
- For the Loa loa infectious disease model, AGHQ produced posterior intervals for $ ho$ (spatial range) of 45.4 to 87.5 km, closely matching MCMC (48.4 to 95.8 km), with significantly faster runtime (195 seconds vs. 2520 seconds).
- In the zero-inflated geostatistical binomial model, AGHQ successfully estimated both transmission ($p$) and suitability ($ ho$) probabilities, which were intractable with INLA due to non-latent-Gaussian structure.
- The aghq package achieved runtime of 36.2 seconds for MCML and 42.7 seconds for INLA, while AGHQ completed in 195 seconds, demonstrating a favorable trade-off between accuracy and speed.
- AGHQ with multiple quadrature points recovered the marginal Laplace approximation, enabling scalable inference in high-dimensional latent Gaussian models.
- The method achieved accurate posterior estimates for the Milky Way mass model and overdispersed count data, where other methods failed or required extensive tuning.
- The integration with TMB allowed AGHQ to be applied with minimal code changes, enabling rapid prototyping and inference in complex hierarchical models.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.