Bayesian Generalized Additive Model (Bayesian GAM)
Bayesian Generalized Additive Model · Also known as: Bayesian GAM, BGAM, Bayesian semiparametric regression, Bayesian smooth regression
Bayesian Generalized Additive Models extend the frequentist GAM framework by placing prior distributions over the smooth functions and any additional model parameters. This yields full posterior distributions over each smooth effect, enabling principled uncertainty quantification, automatic smoothness selection via hyperpriors, and seamless integration with hierarchical or mixed-effects structures.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
Use Bayesian GAM when you expect nonlinear relationships between predictors and the outcome, have a non-Gaussian response, and want full uncertainty quantification around each smooth effect rather than just a point estimate. It is especially valuable when sample sizes are moderate, prior information about smoothness is available, or when the model will feed downstream decision-making that requires calibrated uncertainty. It is also well-suited when the model must be embedded in a larger hierarchical structure. Avoid it when the relationship is expected to be genuinely linear and interpretability of additive slopes is paramount; a Bayesian GLM is simpler and faster in that case. Do not use it when computational resources are severely limited: MCMC sampling for GAMs with many smooth terms is substantially slower than frequentist REML estimation.
Strengths & limitations
- Captures nonlinear predictor effects without specifying a parametric form, fitting a wide range of response distributions via the appropriate link function.
- Full posterior distributions over each smooth yield honest credible intervals that propagate uncertainty about smoothness as well as coefficients.
- Smoothness parameters are estimated automatically from the data via hyperpriors, eliminating the need for cross-validation to select the number of knots.
- Integrates naturally into hierarchical and mixed-effects models, allowing random smooth effects across groups.
- Posterior predictive checks provide a built-in mechanism for model criticism and fit assessment.
- MCMC inference is computationally expensive; models with many predictors or large datasets can require hours to sample.
- Interpretation of smooth curves is less direct than linear coefficients; communicating nonlinear effects to non-technical audiences requires careful visualisation.
- Prior choice for smoothing variances and the response distribution can influence estimates in small samples, requiring sensitivity analysis.
- Identifiability constraints must be imposed on smooth terms (sum-to-zero or similar) to avoid confounding with the intercept.
Frequently asked
How does a Bayesian GAM differ from a frequentist GAM fitted by REML?
Frequentist GAMs estimate smooth functions by penalised likelihood and select smoothing parameters via restricted maximum likelihood (REML), producing point estimates and approximate confidence intervals. Bayesian GAMs place priors on the smooth functions and smoothing variances, yielding a full posterior distribution. Bayesian credible intervals account for uncertainty in the smoothing parameters themselves, whereas frequentist confidence intervals typically condition on the estimated smoothing parameter.
What software fits Bayesian GAMs?
The brms R package allows Bayesian GAMs via Stan with a formula interface nearly identical to mgcv. The mgcv package itself can approximate a Bayesian GAM via its Empirical Bayes mode. R-INLA uses integrated nested Laplace approximation for fast approximate Bayesian inference on GAMs. PyMC supports GAM-like models via Gaussian process components.
How do I choose the basis dimension (number of knots)?
Set the basis dimension generously — typically 10 to 20 basis functions per smooth unless the term is expected to be very wiggly. The smoothness prior will shrink the function toward a polynomial of low degree if the data support it. After fitting, run a basis adequacy check (k-check in mgcv) to verify the chosen dimension is not limiting flexibility.
Can a Bayesian GAM handle random effects?
Yes. Random intercepts and slopes for grouped data are a special case of smooth terms with a identity penalty, and Bayesian GAMs in brms or INLA handle them directly in the same model alongside nonlinear smooth terms.
When is INLA preferable to MCMC for Bayesian GAMs?
INLA is much faster and scales better to large datasets, making it practical when MCMC would be prohibitively slow. However, INLA relies on a Laplace approximation that can be inaccurate for highly non-Gaussian or heavy-tailed posteriors. MCMC (via Stan or brms) is more reliable when the posterior is irregular or when exact credible intervals are critical.
Sources
- Wood, S. N. (2017). Generalized Additive Models: An Introduction with R (2nd ed.). CRC Press. ISBN: 9781498728331
- Bürkner, P.-C. (2017). brms: An R Package for Bayesian Multilevel Models Using Stan. Journal of Statistical Software, 80(1), 1–28. DOI: 10.18637/jss.v080.i01 ↗
How to cite this page
ScholarGate. (2026, June 3). Bayesian Generalized Additive Model. ScholarGate. https://scholargate.app/en/statistics/bayesian-generalized-additive-model
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- Bayesian Generalized Linear ModelStatistics↔ compare
- Bayesian Mixed Effects ModelStatistics↔ compare
- Bayesian Multiple linear regressionStatistics↔ compare
- Generalized Additive ModelMachine learning↔ compare