
Bayesian Linear Regression: Fundamentals, Ridge, and Lasso Regularization
In linear regression, we treat the coefficients as unknown constants and fit them by maximizing the likelihood. Here, we combine the same likelihood with a prior distribution. Bayes' rule then gives the posterior distribution, which describes uncertainty about the coefficients after observing the data. We derive the Gaussian posterior and show how posterior modes under Gaussian and Laplace priors connect to ridge and lasso estimates.
Recap: The Gaussian likelihood
For the fixed-design model in linear regression, the part of the likelihood that depends on is
Here and the observed are fixed. Multiplying by a prior adds its contribution to the log posterior; it does not change this sampling model.
Key Bayesian Regression Framework
Model Setup and Notation
We begin with the familiar linear model:
where:
- is an response vector,
- is an design matrix (including a column for the intercept),
- is a vector of unknown coefficients, and
- the errors are assumed to be independent and normally distributed as
Throughout the coefficient derivations, we condition on a fixed noise variance and fixed positive prior hyperparameters. We also apply the displayed priors to all coefficients, including the intercept, so that the matrix formulas have a consistent convention. An analysis that estimates the noise variance or gives the intercept a separate prior needs those additional choices stated explicitly.
The design is also fixed. Before observing data, has the specified prior and .
After observing , we keep fixed and average over to obtain posterior means and covariances. A different calculation, integrating the likelihood over the prior, gives the marginal likelihood. We omit from the densities below, but never average over it.
Standard Bayesian Linear Regression
Likelihood
The likelihood records how the observed data depend on the parameters and . Because the response is continuous, we use its probability density, viewed as a function of those parameters. Under the independent Gaussian error model, the likelihood is:
where is the th row of . When the noise variance is held fixed, we may omit factors that do not depend on the coefficients and write:
Prior
We describe uncertainty about with a prior distribution. A Gaussian prior on is conjugate to the Gaussian likelihood when the noise variance is held fixed: the conditional posterior remains Gaussian, making the update analytically tractable.
where controls the spread or uncertainty of our prior relative to the noise variance .
Conjugacy makes the Gaussian prior convenient, but convenience is not the only consideration. Different priors express different assumptions about plausible coefficient values:
-
Flat Prior: A constant prior density over , written as , assigns the same density to every coefficient value. On an unbounded parameter space, this density cannot integrate to one, so the prior is improper. We must check that the resulting posterior can be normalized to a probability distribution.
-
Weakly Informative Gaussian Prior: A Gaussian prior with a large variance (small ) permits a wider range of coefficient values. Whether it is weakly informative depends on the scales of the predictors and response.
-
Laplace Prior (Double-Exponential): A Laplace prior concentrates density near zero and connects posterior mode estimation to lasso variable selection:
-
Heavy-Tailed Priors: A heavy-tailed prior, such as a Student's t-distribution for , allows larger coefficient values than a Gaussian prior with comparable central concentration. This concerns the coefficient distribution; it does not by itself make the observation model robust to outliers.
The prior determines which coefficient values receive more weight before observing the responses. Gaussian and Laplace priors impose different penalties on large coefficients. We show this connection by deriving the maximum a posteriori (MAP) estimate, the coefficient vector at which the posterior density is largest. The prior scales must be chosen in relation to the predictor and response scales; the distribution name alone does not determine a suitable prior.
Posterior: Combine Likelihood and the Prior

For this introductory statement of Bayes' rule, we suppress the fixed design matrix and noise variance from the notation:
Next, we write the marginal likelihood by integrating over all possible :
The marginal likelihood normalizes the posterior and does not vary with the coefficients. To derive the posterior's form, we can therefore work up to a proportionality constant. For , Bayes' rule becomes:
Therefore, for our setup the posterior distribution is:
With the noise variance held fixed, the Gaussian likelihood and prior give a Gaussian posterior for . This conjugacy lets us describe coefficient uncertainty analytically, rather than approximating the posterior numerically.
Completing the square gives the conditional posterior:
The matrix is positive definite because . In particular, and ; the posterior mode also equals . This is the fixed-variance case of the Gaussian regression posterior derivation.
Posterior Distributions: Analytic and Approximate Forms
The Gaussian calculation is an example of conjugacy: updating the prior with the likelihood keeps the posterior within the same distribution family. Conjugacy is useful because it gives an explicit posterior, but it is not available for every likelihood–prior combination. Logistic regression provides a useful contrast.
Non-Analytic Example: Bayesian Logistic Regression
- Model Setup
-
Likelihood
Suppose are binary outcomes and is the design matrix. For logistic regression, each is modeled with
where is the logistic function. The likelihood for all data points is:
-
Prior
We can again choose a Gaussian prior for :
- Posterior Challenge
-
Form of the Posterior
Using Bayes’ rule, the posterior is:
Unlike the Gaussian likelihood, this log-likelihood is not quadratic in the coefficients: its logistic terms remain after multiplication by the Gaussian prior. Completing the square therefore does not produce a Gaussian posterior.
-
No Closed-Form Integral
Unlike the Gaussian–Gaussian case, the integral
does not generally yield a closed-form normalizing constant. We therefore need numerical methods for posterior inference.
Markov chain Monte Carlo (MCMC) approximates posterior summaries through samples, whereas variational inference approximates the posterior within a chosen distribution family. Both extend Bayesian inference beyond conjugate models, but their numerical accuracy must be assessed.
Returning to linear regression, the posterior describes uncertainty about each under the chosen model and prior. We next examine a particular posterior summary—the mode—to make the connection with regularization explicit.
Bayesian Ridge Regression
In Bayesian Ridge Regression, we use the same Gaussian prior:
Likelihood:
The likelihood function remains:
Prior:
The Gaussian prior on the coefficients is:
Posterior:
By Bayes’ rule, the posterior is:
Taking the negative logarithm (and ignoring constants) gives the following objective for Maximum A Posteriori (MAP) estimation:
Multiplying through by (which does not affect the minimizer) leads to:
Derivation of the MAP Estimate:
Taking the derivative with respect to and setting it to zero:
Rearrange to obtain:
Thus, the MAP estimate for Bayesian Ridge Regression is:
The penalty coefficient is because the prior covariance was scaled by . With an unscaled prior covariance instead, the equivalent RSS penalty would be . These are different prior conventions and should not be mixed within a derivation.
Bayesian Lasso Regression
Bayesian lasso uses a Laplace (double-exponential) prior on the regression coefficients. The connection to sparse estimates concerns the posterior mode; the full posterior still describes uncertainty about those coefficients. We use a fixed-variance, unscaled-prior formulation below. The fully hierarchical model of Park and Casella (2008) instead scales the Laplace prior with the noise standard deviation and also models the noise variance.
Model, Likelihood, and Prior for Bayesian Lasso
Model:
We retain the linear model:
Likelihood:
The likelihood function is:
Prior:
For this Laplace-prior model, we place independent priors on each coefficient , for . Unlike the Gaussian prior above, the scale used here is not multiplied by the noise standard deviation:
For the entire coefficient vector:
Posterior and MAP Estimation for Bayesian Lasso
Posterior:
Using Bayes’ rule, the posterior distribution is given by:
Taking the negative logarithm (ignoring constants) yields the MAP objective:
Multiplying through by for clarity, we have:
Note:
The norm is not differentiable at zero, so ordinary gradient equations do not apply there. In general, we compute the MAP estimate of numerically, for example by coordinate descent. Sampling methods such as Gibbs sampling answer a different question: they approximate the full posterior rather than only its mode.
Hyperparameter Interpretation
The Gaussian prior covariance decreases as increases, so a larger penalizes departures from zero more strongly. For the Laplace prior, increasing strengthens the corresponding penalty and can produce a sparser MAP estimate. Both choices also change the full posterior, not just the location of its mode.
Summary of Bayesian Linear Regression Methods
-
Standard Bayesian Linear Regression:
- Model:
- Notation:
is an response vector, is an design matrix, is a coefficient vector. - Prior:
. - Posterior:
, a Gaussian distribution with the mean and covariance derived above.
- Model:
-
Bayesian Ridge Regression:
- Prior:
. - MAP Estimator:
- Benefits:
Provides shrinkage of coefficients and quantifies uncertainty via the full posterior distribution.
- Prior:
-
Bayesian Lasso Regression:
- Prior:
Laplace prior . - MAP Objective:
- Benefits:
Can produce a sparse MAP estimate for variable selection. The full posterior and its mode serve different purposes; numerical methods are generally used to compute the required summary.
- Prior:
Practical Considerations
The computation depends on the model and the posterior summary we need. Conjugate Gaussian models allow analytic calculations, while more complex models may require MCMC methods such as Gibbs sampling or Metropolis–Hastings. For posterior simulation, we check whether the chain has stabilized and explored the relevant parts of the posterior. For variational inference, we assess what the chosen family of distributions can represent. Both approaches still require us to assess the model and prior.
The distinction between a posterior and a point estimate is central to this note. Gaussian and Laplace priors connect Bayesian analysis to familiar regularization objectives, but the posterior contains more information than its mode. Keeping those roles separate helps us choose both the prior and the summary that answer the scientific question.
Further Reading & Citations
- Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian Data Analysis. Chapman & Hall/CRC.
- Bishop, C. M. (2006). Pattern Recognition and Machine Learning. Springer.
- Park, T., & Casella, G. (2008). The Bayesian Lasso. Journal of the American Statistical Association, 103(482), 681-686.
