Bayesian Linear Regression with Gibbs Sampling
An in-depth guide on implementing Bayesian linear regression and Gibbs sampling for parameter estimation.
TL; DR
Bayesian linear regression assumes data follows a normal distribution given parameters.
Prior distributions for regression coefficients and variance are normally and inverse-gamma distributed respectively.
Gibbs sampling is used to sample from the posterior distribution when direct computation is infeasible.
The full conditional distributions for coefficients and variance are derived to facilitate sampling.
The Gibbs sampling procedure iterates between sampling regression coefficients and variance to approximate the posterior distribution.
Bayesian Linear Regression and Gibbs Sampling
Bayesian linear regression is a statistical method in which the statistical analysis is undertaken within the context of Bayesian inference. When performing Bayesian linear regression, we assume that the observed data, , given the parameters and , follows a normal distribution:
Prior Distributions
The prior distributions for the parameters are set as follows:
For :
with the prior probability density function (pdf) given by:
For :
with the prior pdf given by:
Gibbs Sampling
Directly computing can be challenging, so we use Gibbs sampling by sampling from the full conditional distributions of and .
Gibbs Sampling Procedure
The Gibbs sampling procedure for obtaining samples from is as follows:
Sample from
Sample from .
Sample from
Sample from
Continue this process for iterations.
After iterations, we have samples from the full posterior distribution.
Last updated