Bayesian Linear Regression
The Bayesian linear regression model is
where , , and the prior is the Normal-Inverse-Gamma (NIG) family scaled by . The conjugate posterior is again NIG with
Marginal posterior for (integrating out ):
a multivariate Student- centered at with degrees of freedom. The scale matrix inherits both the design-matrix geometry (through ) and the residual scale .Posterior predictive for new inputs : again multivariate Student-,
The predictive covariance splits into noise variance () and parameter-uncertainty variance () — the latter grows with distance from the training design, producing natural uncertainty inflation for extrapolation.Ridge-regression correspondence. With prior , the posterior mean is
exactly the ridge regression estimator with penalty . Ridge is the Bayesian MAP under a Gaussian prior; the Bayesian interpretation adds a principled way to choose (via marginal likelihood) and a credible interval on each coefficient.Reference prior limit. With and (improper prior ), the posterior mean equals the OLS estimate , and the marginal posterior is with — numerically identical to the frequentist sampling distribution.
Prerequisites
- 3.1 Bayesian Framework — Bayesian mechanics.
- 3.5.2 Normal-Normal Model — the univariate NIG conjugate analysis this generalizes.
- 3.8 Bayesian Regression — parent index.
- 1.2. Linear Regression — frequentist linear regression for comparison.
Intuition
The conjugate analysis works because everything in the model is Gaussian. Writing the log-joint as a function of , both the prior and the likelihood contribute quadratic forms; their sum is another quadratic, completed to identify a Gaussian posterior for conditional on . The variance, , has its own Inverse-Gamma conjugate prior, and the two pieces combine into the NIG hierarchy. Integrating out of the joint posterior yields a Student- marginal for , mirroring the univariate Normal-Inverse-Gamma story in 3.5.2 Normal-Normal Model.
The matrix is the posterior precision: the data contribute their Gram matrix and the prior contributes . For ridge, regularizes directions where the data are information-poor (small eigenvalues of ). The prior effectively adds phantom observations that pull toward , and the ratio of prior-precision eigenvalues to data-precision eigenvalues controls how much each coordinate of is shrunk.
The predictive variance is the crucial Bayesian payoff. Plug-in prediction forgets that itself was estimated; the Bayesian predictive distribution correctly inflates variance by , which grows for test inputs far from the training design. A regression model is therefore automatically more uncertain about extrapolation — no post-hoc confidence-inflation tricks needed.
Properties
(Ridge as MAP Under Gaussian Prior) The ridge estimator is the posterior mode under .
Setting and yields posterior mean , the ridge estimator. The Bayesian view explains why ridge shrinks: the Gaussian prior puts mass near zero, so coefficients without strong data support are pulled toward zero. The choice of corresponds to choosing the prior’s concentration; cross-validation and Type-II MLE (evidence maximization, see 3.7 Marginal Likelihood) give two principled ways to set it.
(Lasso as MAP Under Laplace Prior) A Laplace (double-exponential) prior on yields the LASSO posterior mode.
Taking with density , the log-posterior is -fit plus ; maximizing it recovers the LASSO. The Laplace prior is not conjugate to the Gaussian likelihood — the posterior has no closed form, but it admits a data-augmented Gibbs sampler via a scale mixture representation. Practical Bayesian LASSO fits typically use the Park-Casella Gibbs sampler.
(Multivariate Student-t Marginal for ) Integrating out of the NIG posterior yields a Student- marginal for the coefficient vector.
Degrees of freedom grow linearly with ; the tails thicken for small and approach Gaussian as . The -th marginal is univariate Student-:
whose credible interval is . Under the reference prior limit this collapses to the classical -interval.
(Posterior Predictive is Multivariate Student-t) Predictions at new inputs inherit heavy tails and design-dependent uncertainty.
The predictive variance decomposes as noise variance plus parameter-uncertainty variance . For a test input far from training, is large; predictive intervals widen automatically. This is the discrete-grid analog of the increasing posterior variance in GP regression away from data.
(Reference-Prior Posterior Equals OLS Sampling Distribution) The Jeffreys prior limit recovers frequentist inference exactly.
With and ,
with . The Bayesian credible interval coincides numerically with the frequentist confidence interval, though the interpretations differ (see 3.2 Credible Intervals).
(Conjugate Gibbs Sampler) In non-conjugate extensions, the conditional for given stays Gaussian, enabling Gibbs.
If has any prior (not necessarily Inverse-Gamma), the conditional remains Gaussian — a full conditional ready for Gibbs. This conditional conjugacy is why Bayesian regression is a canonical Gibbs target even when the full joint is not conjugate. See 3.11.2 Gibbs Sampling.
(Evidence and Model Comparison) The marginal likelihood has closed form, enabling Bayesian model selection.
This lets Bayes factors compare nested linear models (whether to include a covariate, polynomial order, etc.) without resorting to BIC. The closed form also enables Type-II MLE tuning of (evidence-based choice of ridge penalty). See 3.7 Marginal Likelihood.
(Sensitivity to Prior Scale) Regression coefficient priors must be calibrated to covariate scale.
A prior has very different regularizing force when the covariate ranges over than when it ranges over . Standard practice is to standardize covariates before regression, making a unit-scale prior the default. Alternately, use a scale-invariant hierarchical prior that learns an appropriate per-coefficient scale.
Examples
Example 1: Closed-Form Posterior for a Single-Predictor Regression
Data with and centered (so intercept drops out) and , . Prior and improper .
Design quantities: , , .
Posterior for : with — the ridge estimator.
Posterior for : under the improper prior.
Marginal posterior for : with .Setting recovers the frequentist OLS. Increasing shrinks toward zero and narrows the credible interval around the shrunk value — a variance-bias tradeoff made explicit.
Example 2: Predictive Uncertainty for Extrapolation
Suppose a simple linear regression is fit with training points . Consider predicting at (outside the training range).
Plug-in variance: residual variance, giving predictive standard deviation regardless of — wrong.
Bayesian predictive variance: . For centered and :
With , (say), and , the variance inflates by a factor over the plug-in. At , the factor is — a 2.7-fold increase in predictive standard deviation. Extrapolation uncertainty is automatic.
Example 3: Ridge via Marginal-Likelihood Tuning
With prior and , the marginal likelihood is a smooth function of . Maximizing it gives an empirical-Bayes ridge penalty.
Recipe: for each candidate on a log-grid, compute the closed-form evidence using the formula above and pick the maximizer. This works out to a GCV-like criterion but is principled (the evidence already penalizes complexity — see 3.7 Marginal Likelihood’s BIC property). For a design with and well-conditioned , the evidence-optimal typically lands between cross-validation’s choice and the LOO-CV choice, with similar predictive performance.
Derivation
Goal: derive the NIG posterior for .
The likelihood times prior is
Collecting terms quadratic in inside the exponent:
by completing the square, with and . The constant-in- piece is
Substituting:
which is NIG with as stated.
Marginal posterior for : integrating out against the Inverse-Gamma marginal of the NIG. The resulting density is , the multivariate- kernel.
Posterior predictive: with and . Summing two Student- dependence structures preserves degrees of freedom and adds scales.
See Also
- 3.8 Bayesian Regression — parent index.
- 3.5.2 Normal-Normal Model — univariate conjugate analysis this generalizes.
- 3.9 Laplace Approximation — non-conjugate regressions require this.
- 3.11.2 Gibbs Sampling — conditional conjugacy makes Gibbs the natural sampler for non-NIG priors (Laplace, horseshoe, etc.).
- 3.8.2 Bayesian AutoRegression — linear regression with lagged responses.
- 3.8.3 Bayesian Logistic Regression — non-conjugate binary-response counterpart.
- 3.8.4 Bayesian Poisson Regression — non-conjugate count-response counterpart.
- 3.10 Gaussian Processes — generalization to infinite-dimensional linear models via kernels.
- 1.2. Linear Regression — frequentist analog.