- Introduced by
- McCullagh & Nelder (GLM framework); Bayesian treatment formalized by Gelman et al.
- Year
- 1989 (GLM); 1995 (Bayesian BDA)
- Type
- Bayesian regression model
- Family
- Regression / GLM
What does it do?
A Bayesian Generalized Linear Model (Bayesian GLM) extends the classical GLM framework by placing prior distributions on the regression coefficients and updating them with data via Bayes' theorem.
This yields a full posterior distribution over parameters rather than single point estimates, enabling richer uncertainty quantification and principled incorporation of prior knowledge for outcomes with an exponential-family likelihood, such as binary, count, and continuous responses.
The intuition behind the method
Classical GLMs give you one best-guess coefficient per predictor. The Bayesian version treats each coefficient as an uncertain quantity with a probability distribution. You start with a prior belief about plausible coefficient values, feed in the data, and Bayes' theorem blends prior and data to form a posterior. The posterior lets you ask not just 'what is the estimate?' but 'how confident are we, and what is the whole range of plausible values?' This is especially valuable in small samples or when domain knowledge is strong enough to constrain estimates.
History
McCullagh and Nelder's 1989 monograph Generalized Linear Models set out the exponential-family framework that unifies linear, logistic, and Poisson regression, and the Bayesian version builds on that framework. Bayesian treatments of these models are covered in depth in Gelman et al.'s Bayesian Data Analysis. Probabilistic programming systems, including BUGS, JAGS, and Stan, later made fitting Bayesian GLMs routine.
When to use it
Choose a Bayesian GLM when you want posterior distributions for coefficients and predictions, when you have prior information that you can justify and encode, when the sample is small or sparse enough that maximum-likelihood estimates become unstable, or when parameter uncertainty must be carried into predictions. It applies to outcomes with an exponential-family likelihood, such as binary, count, and continuous responses. Do not use it when a classical GLM fits adequately and the posterior adds nothing to the question, when computing time is tightly limited, or when the team cannot yet judge priors and MCMC diagnostics. For overdispersed counts, a model with an explicit overdispersion term, such as the Bayesian negative binomial regression page covers, is usually the better starting point. In every case, check the link function and family before fitting, because a Bayesian treatment does not repair a misspecified model.
Limitations and considerations
- Computationally intensive: MCMC sampling can take minutes to hours for large datasets or complex models.
- Results are sensitive to prior choice in small samples; poorly chosen priors can dominate the posterior.
- Requires expertise in prior specification, link-function selection, and MCMC convergence diagnostics (R-hat, effective sample size).
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Produces full posterior distributions, enabling credible intervals, posterior predictive checks, and decision-theoretic summaries.
- Handles small samples more gracefully than frequentist GLMs by borrowing strength from priors.
- Naturally accommodates prior knowledge from previous studies or domain expertise.
- Posterior predictive checks provide a direct way to assess model fit and detect misspecification.
- Within the exponential family, one framework covers binary, count, and continuous outcomes, so the same prior-and-posterior workflow carries over between model types.
Applications
- Logistic (Bernoulli, logit link) models of binary outcomes in small clinical studies, where estimates from earlier phases can be encoded as priors.
- Count models of rare events, such as disease incidence or species abundance in small regions, where sparse cells make maximum-likelihood coefficients unstable.
- Gamma or identity-link models of positive continuous outcomes with few observations, where weakly informative priors keep coefficients on plausible scales.
- Click-through or conversion models with a binomial likelihood, where historical baseline rates can serve as an informative prior on the intercept.
- Forecasting problems that need predictive distributions rather than point predictions, so that posterior predictive intervals carry parameter uncertainty into the forecast.
How it works
How it works
A link function g() connects the linear predictor x'β to the mean μ of the outcome distribution. Common choices are the logit link for binary outcomes, the log link for counts, and the identity link for continuous outcomes.
Formula
g(\mu_i) = \mathbf{x}_i^{\top}\boldsymbol{\beta},\quad \mu_i = E[y_i \mid \mathbf{x}_i]The outcome is assumed to follow an exponential-family distribution — Bernoulli, Poisson, Gamma, Normal, etc. — parameterized by the conditional mean μ. This likelihood measures how probable the observed data are for each candidate β.
Formula
y_i \mid \mathbf{x}_i,\boldsymbol{\beta} \sim \text{ExpFamily}(\mu_i,\phi)Prior distributions are placed on the regression coefficients β, encoding beliefs before seeing the data. A weakly informative Normal(0, 2.5) prior on standardized predictors is a common starting point in practice, though it is a convention rather than a derived optimum. Informative priors can be used when the prior evidence is trustworthy, and their influence should then be checked.
Formula
\boldsymbol{\beta} \sim p(\boldsymbol{\beta})Bayes' theorem combines likelihood and prior: the posterior p(β|y) is proportional to their product. The posterior summarizes all that is known about β after observing the data.
Formula
p(\boldsymbol{\beta} \mid \mathbf{y}) \propto p(\mathbf{y} \mid \boldsymbol{\beta})\, p(\boldsymbol{\beta})Because the posterior rarely has a closed form for non-Gaussian outcomes, inference uses Markov chain Monte Carlo (MCMC) samplers such as Hamiltonian Monte Carlo (Stan/brms) or variational inference. Posterior summaries — means, credible intervals, predictive distributions — replace classical point estimates and p-values.
Common pitfalls
- Using default flat (improper) priors on the coefficient scale without checking whether they produce sensible predictions on the outcome scale.
- Ignoring MCMC convergence diagnostics: high R-hat (> 1.01) or low effective sample size signals unreliable posterior estimates.
- Choosing the wrong link function or family (e.g., Gaussian for a bounded outcome) — Bayesian inference cannot fix a misspecified likelihood.
- Over-interpreting the posterior mean as a point estimate and ignoring the width of credible intervals, especially in small samples.
- Failing to run posterior predictive checks, which may reveal systematic discrepancies between the model and the data.
Frequently asked questions
How is a Bayesian GLM different from a classical GLM?
A classical GLM estimates coefficients by maximum likelihood and reports point estimates with asymptotic confidence intervals. A Bayesian GLM places priors on coefficients and produces a full posterior distribution, giving credible intervals that have direct probability interpretations and allowing incorporation of prior knowledge.
What prior should I use for the regression coefficients?
A common starting point is a weakly informative Normal(0, 2.5) prior on coefficients after standardizing predictors to unit scale. It is a convention, not an optimal choice; it allows realistic effect sizes while discouraging the sampler from exploring implausible regions. If strong prior evidence exists, for example from a previous study, an informative prior can be used, but its influence should be disclosed and sensitivity-tested.
How do I check whether my MCMC chains have converged?
Check the R-hat statistic (a common rule of thumb is below 1.01 for every parameter), the effective sample size (a commonly used guide is at least 400 per parameter), and trace plots, which should look stationary and well mixed, without trends or stuck stretches.
Can I use a Bayesian GLM with large datasets?
Yes, but full MCMC becomes slow for very large n. Alternatives include variational inference (faster, approximate) or subsampling MCMC methods. For very large datasets the likelihood dominates the prior anyway, and a classical GLM with robust standard errors may give nearly identical inference at a fraction of the cost.
Which software fits Bayesian GLMs?
Stan (via the brms or rstanarm R packages) is the most widely used and recommended option, implementing Hamiltonian Monte Carlo. PyMC (Python) and JAGS are also popular. Many implementations offer formula syntax similar to classical GLMs, lowering the learning curve.
How do I interpret the coefficients and credible intervals?
Coefficients are on the link scale. For a logit model, exp(beta) is an odds ratio for a one-unit change in the predictor (or per standard deviation if predictors were standardized); for a log-link count model, exp(beta) is a rate ratio. A 95 percent credible interval is the range that contains the parameter with 95 percent posterior probability, given the model and the prior; it is not a confidence interval in the frequentist sense.
Related methods
Sources
Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). CRC Press.
ISBN: 978-1439840955McCullagh, P., & Nelder, J. A. (1989). Generalized Linear Models (2nd ed.). Chapman & Hall.
ISBN: 978-0412317606