- Introduced by
- Laplace, P.-S. (early 19th c.); modern treatment: Gelman et al.
- Year
- Early 19th century; textbook synthesis 2013
- Type
- Bayesian linear regression
- Family
- Regression / GLM
What does it do?
Bayesian Simple Linear Regression models the relationship between a continuous outcome and a single predictor by combining a Gaussian likelihood with prior distributions over the intercept, slope, and error variance.
The result is a full posterior distribution over all parameters, providing probabilistic uncertainty quantification rather than a single point estimate.
The intuition behind the method
Instead of finding one best-fit line, Bayesian Simple Linear Regression produces a probability distribution over all plausible lines. Before seeing the data, you specify prior beliefs about how steep the slope might be and where the intercept lies. After observing the data, Bayes' theorem updates those beliefs into a posterior distribution. You can then ask not just 'what is the slope?' but 'what range of slopes is credible, and how probable is each?' This makes uncertainty fully explicit and naturally propagates through predictions.
History
Bayesian treatments of linear regression trace back to Laplace's probabilistic treatment of least squares in the early nineteenth century. The modern framework is presented in Gelman et al.'s Bayesian Data Analysis (3rd ed., 2013), and McElreath's Statistical Rethinking (2nd ed., 2020) made the approach accessible to applied researchers. Software such as Stan and brms later made routine fitting of these models practical.
When to use it
Choose this model when the question involves one continuous predictor and a continuous outcome, and you want the uncertainty in the intercept, slope and error scale reported as a full posterior distribution. It is most useful when the sample is small, when prior estimates from earlier work should be formally included, or when you need a predictive distribution rather than a single predicted value. Do not choose it when there is no meaningful prior information and the sample is large, because OLS will then give nearly the same coefficient estimates at much lower cost. It is also a poor fit when the outcome is binary or count-valued, since the Gaussian likelihood does not suit those data, and when the audience would be confused by posterior distributions rather than helped by them.
Limitations and considerations
- Sampling the posterior with a Half-Normal prior on sigma, or other non-conjugate choices, requires MCMC, which costs more than OLS and becomes expensive when many refits are needed.
- Conclusions depend most strongly on the prior when the sample is small, so the prior must be justified and its influence reported.
- Sampler convergence must be checked before posterior summaries are reported, which adds work to the analysis.
- Results are harder to explain to non-statistical audiences, because a posterior distribution is not a single estimate with a familiar confidence interval.
- Closed-form posteriors are available mainly for conjugate families such as Normal-Inverse-Gamma, which is placed on the error variance; the Half-Normal setup described for sigma falls outside that family.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The posterior covers the intercept, slope and error standard deviation jointly, so uncertainty in the noise scale feeds into the slope's credible interval rather than being fixed at a point estimate.
- Prior distributions let existing subject-matter information about the slope enter the analysis explicitly, and their influence can be checked by refitting with alternative priors.
- With a single slope, the posterior can be read directly as probabilities of ranges of values, such as the posterior probability that the slope is positive.
- Posterior predictive distributions carry parameter and residual uncertainty into predictions at new values of x.
- The same framework extends to hierarchical structures or other likelihoods without changing how the posterior is interpreted.
Applications
- Estimating the effect of a single treatment or exposure on a continuous health or behavioral outcome with full uncertainty quantification.
- Small-sample calibration studies where frequentist interval estimates are unstable and a prior-based analysis is preferred.
- Incorporating expert prior knowledge about a slope (e.g., from previous studies) into a new analysis.
- Generating probabilistic forecasts for a continuous variable given a single driver, with prediction intervals that reflect all sources of uncertainty.
- Teaching Bayesian inference concepts using the simplest possible regression setting.
- Sensitivity analysis: testing how different prior choices affect posterior conclusions about the slope.
How it works
How it works
The observed outcomes y are assumed to be normally distributed around a linear mean alpha + beta*x with constant variance sigma^2. This is the same structural assumption as OLS, encoding how the data were generated.
Formula
y_i \mid \alpha, \beta, \sigma \sim \mathcal{N}(\alpha + \beta x_i,\, \sigma^2)Before seeing the data, prior distributions are placed on the intercept alpha, slope beta, and noise standard deviation sigma. Weakly informative priors, such as Normal(0,10) for the coefficients and a Half-Normal prior for sigma, let the data carry most of the information when the prior scales suit the problem. The appropriate prior scale depends on the units of the outcome and the predictor, so priors should be chosen relative to those scales, for example after centring or standardising the variables, and their influence checked by refitting with alternative choices.
Formula
\alpha \sim p(\alpha),\; \beta \sim p(\beta),\; \sigma \sim p(\sigma)
Bayes' theorem combines the likelihood and priors to produce the joint posterior distribution of all parameters. The posterior is proportional to the product of the likelihood and the priors; it is rarely available in closed form for non-conjugate choices.
Formula
p(\alpha, \beta, \sigma \mid \mathbf{y}) \propto p(\mathbf{y} \mid \alpha, \beta, \sigma)\, p(\alpha)\, p(\beta)\, p(\sigma)When a conjugate prior family is used (for example, Normal-Inverse-Gamma, placed on the error variance rather than on sigma), the posterior has a known closed form and can be sampled directly. The Half-Normal prior on sigma described above is not part of that family, so the posterior is typically sampled with Markov chain Monte Carlo (MCMC), such as Hamiltonian Monte Carlo (Stan/brms) or Gibbs sampling where the conditional distributions are tractable.
Posterior summaries (mean, median, credible intervals) are reported for each parameter. Posterior predictive checks compare simulated datasets to observed data to assess model adequacy, and predictions naturally carry full uncertainty through the posterior predictive distribution.
Common pitfalls
- Using very diffuse priors on the error scale can let the sampler explore implausibly large noise levels; check the prior behaviour and the posterior before accepting the fit.
- Skipping posterior predictive checks and accepting the model because the coefficient summaries look reasonable, without comparing simulated and observed data.
- Fitting the Gaussian model without checking its assumptions: linearity, independent errors with constant variance, approximately normal residuals, and no single observation driving the fit. Assess these with posterior predictive checks and residual plots, and consider bayesian-robust-regression when the errors appear heavy-tailed.
- Reading a 95% credible interval as a confidence interval: a credible interval summarises the parameter given the prior and model, whereas a confidence interval describes the long-run coverage of a procedure.
- Ignoring sampler diagnostics such as R-hat values well above 1 or low effective sample size, which indicate that the chains have not mixed.
- Leaving the predictor uncentred: when x has a large mean, the intercept and slope posteriors are strongly correlated, which slows the sampler and makes the intercept hard to interpret.
- Expecting different answers from OLS in large samples with weakly informative priors; the two usually agree closely, so the extra MCMC cost may not be justified.
Frequently asked questions
How does Bayesian Simple Linear Regression differ from OLS?
OLS minimises the sum of squared residuals and returns point estimates with frequentist confidence intervals. Bayesian regression places priors on all parameters and returns a full posterior distribution. With large samples and weakly informative priors the two give nearly identical coefficient estimates, but the Bayesian approach additionally yields posterior probabilities and propagates uncertainty into predictions.
What priors should I choose for the slope and intercept?
Normal(0, 10) is one example of a weakly informative prior for the slope and intercept, but whether it is weak depends on the units of your outcome and predictor: the same prior can be very diffuse for one variable and quite restrictive for another. Judge the scale against those units, for example after standardising the variables. If earlier studies provide an estimate of the slope, centre the prior on that estimate and choose a standard deviation that reflects how confident you are in it. Always check sensitivity by refitting with alternative priors.
Do I need MCMC for Bayesian Simple Linear Regression?
Not always. With a conjugate prior such as Normal-Inverse-Gamma, which is placed on the error variance rather than the standard deviation, the posterior is available in closed form and can be computed analytically. For other prior choices, MCMC (e.g., Stan, brms) or other approximate methods are needed.
What is a posterior predictive check?
A posterior predictive check generates new datasets by drawing parameters from the posterior and then simulating data from the likelihood. Comparing these simulated datasets to the observed data reveals whether the model captures the main features of the data — it is the Bayesian analogue of residual diagnostics.
When is a credible interval narrower or wider than an OLS confidence interval?
With an informative prior that is consistent with the data, the credible interval can be narrower than the frequentist confidence interval because prior information is incorporated. With a weakly informative prior and a large sample, both intervals are nearly identical. With a strongly informative but incorrect prior, the credible interval can be misleadingly narrow — prior misspecification is a real risk.
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-1439840955McElreath, R. (2020). Statistical Rethinking: A Bayesian Course with Examples in R and Stan (2nd ed.). CRC Press.
ISBN: 978-0367139919