IDEAS home Printed from https://ideas.repec.org/a/jss/jstsof/v075i07.html
   My bibliography  Save this article

Just Another Gibbs Additive Modeler: Interfacing JAGS and mgcv

Author

Listed:
  • Wood, Simon N.

Abstract

The BUGS language offers a very flexible way of specifying complex statistical models for the purposes of Gibbs sampling, while its JAGS variant offers very convenient R integration via the rjags package. However, including smoothers in JAGS models can involve some quite tedious coding, especially for multivariate or adaptive smoothers. Further, if an additive smooth structure is required then some care is needed, in order to centre smooths appropriately, and to find appropriate starting values. R package mgcv implements a wide range of smoothers, all in a manner appropriate for inclusion in JAGS code, and automates centring and other smooth setup tasks. The purpose of this note is to describe an interface between mgcv and JAGS, based around an R function, jagam, which takes a generalized additive model (GAM) as specified in mgcv and automatically generates the JAGS model code and data required for inference about the model via Gibbs sampling. Although the auto-generated JAGS code can be run as is, the expectation is that the user would wish to modify it in order to add complex stochastic model components readily specified in JAGS. A simple interface is also provided for visualisation and further inference about the estimated smooth components using standard mgcv functionality. The methods described here will be un-necessarily inefficient if all that is required is fully Bayesian inference about a standard GAM, rather than the full flexibility of JAGS. In that case the BayesX package would be more efficient.

Suggested Citation

  • Wood, Simon N., 2016. "Just Another Gibbs Additive Modeler: Interfacing JAGS and mgcv," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 75(i07).
  • Handle: RePEc:jss:jstsof:v:075:i07
    DOI: http://hdl.handle.net/10.18637/jss.v075.i07
    as

    Download full text from publisher

    File URL: https://www.jstatsoft.org/index.php/jss/article/view/v075i07/v75i07.pdf
    Download Restriction: no

    File URL: https://www.jstatsoft.org/index.php/jss/article/downloadSuppFile/v075i07/mgcv_1.8-16.tar.gz
    Download Restriction: no

    File URL: https://www.jstatsoft.org/index.php/jss/article/downloadSuppFile/v075i07/v75i07.R
    Download Restriction: no

    File URL: https://www.jstatsoft.org/index.php/jss/article/downloadSuppFile/v075i07/sitka.jags
    Download Restriction: no

    File URL: https://libkey.io/http://hdl.handle.net/10.18637/jss.v075.i07?utm_source=ideas
    LibKey link: if access is restricted and if your library uses this service, LibKey will redirect you to where you can use your library subscription to access this item
    ---><---

    References listed on IDEAS

    as
    1. Crainiceanu, Ciprian M. & Ruppert, David & Wand, Matthew P., 2005. "Bayesian Analysis for Penalized Spline Regression Using WinBUGS," Journal of Statistical Software, Foundation for Open Access Statistics, vol. 14(i14).
    2. Simon N. Wood, 2004. "Stable and Efficient Multiple Smoothing Parameter Estimation for Generalized Additive Models," Journal of the American Statistical Association, American Statistical Association, vol. 99, pages 673-686, January.
    3. Ruppert,David & Wand,M. P. & Carroll,R. J., 2003. "Semiparametric Regression," Cambridge Books, Cambridge University Press, number 9780521785167.
    4. Ludwig Fahrmeir & Stefan Lang, 2001. "Bayesian inference for generalized additive mixed models based on Markov random field priors," Journal of the Royal Statistical Society Series C, Royal Statistical Society, vol. 50(2), pages 201-220.
    5. Ruppert,David & Wand,M. P. & Carroll,R. J., 2003. "Semiparametric Regression," Cambridge Books, Cambridge University Press, number 9780521780506.
    6. Mark Girolami & Ben Calderhead, 2011. "Riemann manifold Langevin and Hamiltonian Monte Carlo methods," Journal of the Royal Statistical Society Series B, Royal Statistical Society, vol. 73(2), pages 123-214, March.
    7. Inyoung Kim & Noah D. Cohen & Raymond J. Carroll, 2003. "Semiparametric Regression Splines in Matched Case-Control Studies," Biometrics, The International Biometric Society, vol. 59(4), pages 1158-1169, December.
    Full references (including those not matched with items on IDEAS)

    Citations

    Citations are extracted by the CitEc Project, subscribe to its RSS feed for this item.
    as


    Cited by:

    1. Chen, Kefei & O'Leary, Rebecca A. & Evans, Fiona H., 2019. "A simple and parsimonious generalised additive model for predicting wheat yield in a decision support tool," Agricultural Systems, Elsevier, vol. 173(C), pages 140-150.
    2. Stoner, Oliver & Economou, Theo, 2020. "An advanced hidden Markov model for hourly rainfall time series," Computational Statistics & Data Analysis, Elsevier, vol. 152(C).
    3. Anna Vážná & Jana Vignerová & Marek Brabec & Jan Novák & Bohuslav Procházka & Antonín Gabera & Petr Sedlak, 2022. "Influence of COVID-19-Related Restrictions on the Prevalence of Overweight and Obese Czech Children," IJERPH, MDPI, vol. 19(19), pages 1-14, September.
    4. Oliver Stoner & Gavin Shaddick & Theo Economou & Sophie Gumy & Jessica Lewis & Itzel Lucio & Giulia Ruggeri & Heather Adair‐Rohani, 2020. "Global household energy model: a multivariate hierarchical approach to estimating trends in the use of polluting and clean fuels for cooking," Journal of the Royal Statistical Society Series C, Royal Statistical Society, vol. 69(4), pages 815-839, August.
    5. Simon N. Wood, 2020. "Inference and computation with generalized additive models and their extensions," TEST: An Official Journal of the Spanish Society of Statistics and Operations Research, Springer;Sociedad de Estadística e Investigación Operativa, vol. 29(2), pages 307-339, June.
    6. Francesco Brizzi & Paul J. Birrell & Martyn T. Plummer & Peter Kirwan & Alison E. Brown & Valerie C. Delpech & O. Noel Gill & Daniela Angelis, 2019. "Extending Bayesian back-calculation to estimate age and time specific HIV incidence," Lifetime Data Analysis: An International Journal Devoted to Statistical Methods and Applications for Time-to-Event Data, Springer, vol. 25(4), pages 757-780, October.
    7. Shaun R. Seaman & Pantelis Samartsidis & Meaghan Kall & Daniela De Angelis, 2022. "Nowcasting COVID‐19 deaths in England by age and region," Journal of the Royal Statistical Society Series C, Royal Statistical Society, vol. 71(5), pages 1266-1281, November.
    8. Oliver Stoner & Alba Halliday & Theo Economou, 2023. "Correcting delayed reporting of COVID‐19 using the generalized‐Dirichlet‐multinomial method," Biometrics, The International Biometric Society, vol. 79(3), pages 2537-2550, September.
    9. Oliver Stoner & Theo Economou, 2020. "Multivariate hierarchical frameworks for modeling delayed reporting in count data," Biometrics, The International Biometric Society, vol. 76(3), pages 789-798, September.

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Klein, Nadja & Denuit, Michel & Lang, Stefan & Kneib, Thomas, 2013. "Nonlife Ratemaking and Risk Management with Bayesian Additive Models for Location, Scale and Shape," LIDAM Discussion Papers ISBA 2013045, Université catholique de Louvain, Institute of Statistics, Biostatistics and Actuarial Sciences (ISBA).
    2. Morteza Amini & Mahdi Roozbeh & Nur Anisah Mohamed, 2024. "Separation of the Linear and Nonlinear Covariates in the Sparse Semi-Parametric Regression Model in the Presence of Outliers," Mathematics, MDPI, vol. 12(2), pages 1-17, January.
    3. Daniel Melser, 2017. "Residential Real Estate, Risk, Return and Home Characteristics: Evidence from Sydney 2002-14," ERES eres2017_296, European Real Estate Society (ERES).
    4. Schmidt, Rouven & Kneib, Thomas, 2023. "Multivariate distributional stochastic frontier models," Computational Statistics & Data Analysis, Elsevier, vol. 187(C).
    5. Marra, Giampiero & Radice, Rosalba, 2017. "Bivariate copula additive models for location, scale and shape," Computational Statistics & Data Analysis, Elsevier, vol. 112(C), pages 99-113.
    6. Nadja Klein & Thomas Kneib & Giampiero Marra & Rosalba Radice & Slawa Rokicki & Mark E. McGovern, 2018. "Mixed Binary-Continuous Copula Regression Models with Application to Adverse Birth Outcomes," CHaRMS Working Papers 18-06, Centre for HeAlth Research at the Management School (CHaRMS).
    7. Rasheed A. Adeyemi & Temesgen Zewotir & Shaun Ramroop, 2016. "Semiparametric Multinomial Ordinal Model to Analyze Spatial Patterns of Child Birth Weight in Nigeria," IJERPH, MDPI, vol. 13(11), pages 1-22, November.
    8. Øystein Sørensen & Anders M. Fjell & Kristine B. Walhovd, 2023. "Longitudinal Modeling of Age-Dependent Latent Traits with Generalized Additive Latent and Mixed Models," Psychometrika, Springer;The Psychometric Society, vol. 88(2), pages 456-486, June.
    9. Maike Hohberg & Francesco Donat & Giampiero Marra & Thomas Kneib, 2021. "Beyond unidimensional poverty analysis using distributional copula models for mixed ordered‐continuous outcomes," Journal of the Royal Statistical Society Series C, Royal Statistical Society, vol. 70(5), pages 1365-1390, November.
    10. Giampiero Marra & Rosalba Radice & Till Bärnighausen & Simon N. Wood & Mark E. McGovern, 2017. "A Simultaneous Equation Approach to Estimating HIV Prevalence With Nonignorable Missing Responses," Journal of the American Statistical Association, Taylor & Francis Journals, vol. 112(518), pages 484-496, April.
    11. Julie Vercelloni & M Julian Caley & Mohsen Kayal & Samantha Low-Choy & Kerrie Mengersen, 2014. "Understanding Uncertainties in Non-Linear Population Trajectories: A Bayesian Semi-Parametric Hierarchical Approach to Large-Scale Surveys of Coral Cover," PLOS ONE, Public Library of Science, vol. 9(11), pages 1-9, November.
    12. Nadja Klein & Michel Denuit & Stefan Lang & Thomas Kneib, 2013. "Nonlife Ratemaking and Risk Management with Bayesian Additive Models for Location, Scale and Shape," Working Papers 2013-24, Faculty of Economics and Statistics, Universität Innsbruck.
    13. Simon N. Wood, 2020. "Inference and computation with generalized additive models and their extensions," TEST: An Official Journal of the Spanish Society of Statistics and Operations Research, Springer;Sociedad de Estadística e Investigación Operativa, vol. 29(2), pages 307-339, June.
    14. Paciorek, Christopher J., 2007. "Computational techniques for spatial logistic regression with large data sets," Computational Statistics & Data Analysis, Elsevier, vol. 51(8), pages 3631-3653, May.
    15. Marra, Giampiero & Wyszynski, Karol, 2016. "Semi-parametric copula sample selection models for count responses," Computational Statistics & Data Analysis, Elsevier, vol. 104(C), pages 110-129.
    16. Marra, Giampiero & Radice, Rosalba, 2013. "Estimation of a regression spline sample selection model," Computational Statistics & Data Analysis, Elsevier, vol. 61(C), pages 158-173.
    17. Nicole H. Augustin & Stefan Lang & Monica Musio & Klaus Von Wilpert, 2007. "A spatial model for the needle losses of pine‐trees in the forests of Baden‐Württemberg: an application of Bayesian structured additive regression," Journal of the Royal Statistical Society Series C, Royal Statistical Society, vol. 56(1), pages 29-50, January.
    18. Takuma Yoshida, 2016. "Asymptotics and smoothing parameter selection for penalized spline regression with various loss functions," Statistica Neerlandica, Netherlands Society for Statistics and Operations Research, vol. 70(4), pages 278-303, November.
    19. Cui, Xia & Zhao, Weihua & Lian, Heng & Liang, Hua, 2019. "Pursuit of dynamic structure in quantile additive models with longitudinal data," Computational Statistics & Data Analysis, Elsevier, vol. 130(C), pages 42-60.
    20. Simon N. Wood, 2006. "Low-Rank Scale-Invariant Tensor Product Smooths for Generalized Additive Mixed Models," Biometrics, The International Biometric Society, vol. 62(4), pages 1025-1036, December.

    More about this item

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:jss:jstsof:v:075:i07. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F. Baum (email available below). General contact details of provider: http://www.jstatsoft.org/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.