Bayesian linear regression

From HandWiki
Short description: Method of statistical analysis

Bayesian linear regression is a type of conditional modeling in which the mean of one variable is described by a linear combination of other variables, with the goal of obtaining the posterior probability of the regression coefficients (as well as other parameters describing the distribution of the regressand) and ultimately allowing the out-of-sample prediction of the regressand (often labelled y) conditional on observed values of the regressors (usually X). The simplest and most widely used version of this model is the normal linear model, in which y given X is distributed Gaussian. In this model, and under a particular choice of prior probabilities for the parameters—so-called conjugate priors—the posterior can be found analytically. With more arbitrarily chosen priors, the posteriors generally have to be approximated.

Model setup

Consider a standard linear regression problem, in which for i=1,,n we specify the mean of the conditional distribution of yi given a k×1 predictor vector 𝐱i: yi=𝐱iTβ+εi,

where β is a k×1 vector, and the εi are independent and identically normally distributed random variables: εiN(0,σ2).

This corresponds to the following likelihood function:

ρ(𝐲𝐗,β,σ2)(σ2)n/2exp(12σ2(𝐲𝐗β)T(𝐲𝐗β)).

The ordinary least squares solution is used to estimate the coefficient vector using the Moore–Penrose pseudoinverse: β^=(𝐗T𝐗)1𝐗T𝐲

where 𝐗 is the n×k design matrix, each row of which is a predictor vector 𝐱iT; and 𝐲 is the column n-vector [y1yn]T.

This is a frequentist approach, and it assumes that there are enough measurements to say something meaningful about β. In the Bayesian approach, the data are supplemented with additional information in the form of a prior probability distribution. The prior belief about the parameters is combined with the data's likelihood function according to Bayes theorem to yield the posterior belief about the parameters β and σ. The prior can take different functional forms depending on the domain and the information that is available a priori.

Since the data comprise both 𝐲 and 𝐗, the focus only on the distribution of 𝐲 conditional on 𝐗 needs justification. In fact, a "full" Bayesian analysis would require a joint likelihood ρ(𝐲,𝐗β,σ2,γ) along with a prior ρ(β,σ2,γ), where γ symbolizes the parameters of the distribution for 𝐗. Only under the assumption of (weak) exogeneity can the joint likelihood be factored into ρ(𝐲𝐗,β,σ2)ρ(𝐗γ).[1] The latter part is usually ignored under the assumption of disjoint parameter sets. More so, under classic assumptions 𝐗 are considered chosen (for example, in a designed experiment) and therefore has a known probability without parameters.[2]

With conjugate priors

Conjugate prior distribution

For an arbitrary prior distribution, there may be no analytical solution for the posterior distribution. In this section, we will consider a so-called conjugate prior for which the posterior distribution can be derived analytically.

A prior ρ(β,σ2) is conjugate to this likelihood function if it has the same functional form with respect to β and σ. Since the log-likelihood is quadratic in β, the log-likelihood is re-written such that the likelihood becomes normal in (ββ^). Write

(𝐲𝐗β)T(𝐲𝐗β)=[(𝐲𝐗β^)+(𝐗β^𝐗β)]T[(𝐲𝐗β^)+(𝐗β^𝐗β)]=(𝐲𝐗β^)T(𝐲𝐗β^)+(ββ^)T(𝐗T𝐗)(ββ^)+2(𝐗β^𝐗β)T(𝐲𝐗β^)= 0=(𝐲𝐗β^)T(𝐲𝐗β^)+(ββ^)T(𝐗T𝐗)(ββ^).

The likelihood is now re-written as ρ(𝐲|𝐗,β,σ2)(σ2)v2exp(vs22σ2)(σ2)nv2exp(12σ2(ββ^)T(𝐗T𝐗)(ββ^)), where vs2=(𝐲𝐗β^)T(𝐲𝐗β^) and v=nk, where k is the number of regression coefficients.

This suggests a form for the prior: ρ(β,σ2)=ρ(σ2)ρ(βσ2), where ρ(σ2) is an inverse-gamma distribution ρ(σ2)(σ2)v021exp(v0s022σ2).

In the notation introduced in the inverse-gamma distribution article, this is the density of an Inv-Gamma(a0,b0) distribution with a0=v02 and b0=12v0s02 with v0 and s02 as the prior values of v and s2, respectively. Equivalently, it can also be described as a scaled inverse chi-squared distribution, Scale-inv-χ2(v0,s02).

Further the conditional prior density ρ(β|σ2) is a normal distribution,

ρ(βσ2)(σ2)k/2exp(12σ2(βμ0)TΛ0(βμ0)).

In the notation of the normal distribution, the conditional prior distribution is 𝒩(μ0,σ2Λ01).

Posterior distribution

With the prior now specified, the posterior distribution can be expressed as

ρ(β,σ2𝐲,𝐗)ρ(𝐲𝐗,β,σ2)ρ(βσ2)ρ(σ2)(σ2)n/2exp(12σ2(𝐲𝐗β)T(𝐲𝐗β))(σ2)k/2exp(12σ2(βμ0)TΛ0(βμ0))(σ2)(a0+1)exp(b0σ2)

With some re-arrangement,[3] the posterior can be re-written so that the posterior mean μn of the parameter vector β can be expressed in terms of the least squares estimator β^ and the prior mean μ0, with the strength of the prior indicated by the prior precision matrix Λ0

μn=(𝐗T𝐗+Λ0)1(𝐗T𝐗β^+Λ0μ0).

To justify that μn is indeed the posterior mean, the quadratic terms in the exponential can be re-arranged as a quadratic form in βμn.[4]

(𝐲𝐗β)T(𝐲𝐗β)+(βμ0)TΛ0(βμ0)=(βμn)T(𝐗T𝐗+Λ0)(βμn)+𝐲T𝐲μnT(𝐗T𝐗+Λ0)μn+μ0TΛ0μ0.

Now the posterior can be expressed as a normal distribution times an inverse-gamma distribution:

ρ(β,σ2𝐲,𝐗)(σ2)k/2exp(12σ2(βμn)T(𝐗T𝐗+Λ0)(βμn))(σ2)n+2a021exp(2b0+𝐲T𝐲μnT(𝐗T𝐗+Λ0)μn+μ0TΛ0μ02σ2).

Therefore, the posterior distribution can be parametrized as follows. ρ(β,σ2𝐲,𝐗)ρ(βσ2,𝐲,𝐗)ρ(σ2𝐲,𝐗), where the two factors correspond to the densities of 𝒩(μn,σ2Λn1) and Inv-Gamma(an,bn) distributions, with the parameters of these given by

Λn=(𝐗T𝐗+Λ0),μn=(Λn)1(𝐗T𝐗β^+Λ0μ0), an=a0+n2,bn=b0+12(𝐲T𝐲+μ0TΛ0μ0μnTΛnμn).

which illustrates Bayesian inference being a compromise between the information contained in the prior and the information contained in the sample.

Model evidence

The model evidence p(𝐲m) is the probability of the data given the model m. It is also known as the marginal likelihood, and as the prior predictive density. Here, the model is defined by the likelihood function p(𝐲𝐗,β,σ) and the prior distribution on the parameters, i.e. p(β,σ). The model evidence captures in a single number how well such a model explains the observations. The model evidence of the Bayesian linear regression model presented in this section can be used to compare competing linear models by Bayesian model comparison. These models may differ in the number and values of the predictor variables as well as in their priors on the model parameters. Model complexity is already taken into account by the model evidence, because it marginalizes out the parameters by integrating p(𝐲,β,σ𝐗) over all possible values of β and σ. p(𝐲|m)=p(𝐲𝐗,β,σ)p(β,σ)dβdσ This integral can be computed analytically and the solution is given in the following equation.[5] p(𝐲m)=1(2π)n/2det(Λ0)det(Λn)b0a0bnanΓ(an)Γ(a0)

Here Γ denotes the gamma function. Because we have chosen a conjugate prior, the marginal likelihood can also be easily computed by evaluating the following equality for arbitrary values of β and σ. p(𝐲m)=p(β,σ|m)p(𝐲𝐗,β,σ,m)p(β,σ𝐲,𝐗,m) Note that this equation is nothing but a re-arrangement of Bayes theorem. Inserting the formulas for the prior, the likelihood, and the posterior and simplifying the resulting expression leads to the analytic expression given above.

Other cases

In general, it may be impossible or impractical to derive the posterior distribution analytically. However, it is possible to approximate the posterior by an approximate Bayesian inference method such as Monte Carlo sampling[6] or variational Bayes.

The special case μ0=0,Λ0=c𝐈 is called ridge regression.

A similar analysis can be performed for the general case of the multivariate regression and part of this provides for Bayesian estimation of covariance matrices: see Bayesian multivariate linear regression.

See also


Notes

  1. See Jackman (2009), p. 101.
  2. See Gelman et al. (2013), p. 354.
  3. The intermediate steps of this computation can be found in O'Hagan (1994) at the beginning of the chapter on Linear models.
  4. The intermediate steps are in Fahrmeir et al. (2009) on page 188.
  5. The intermediate steps of this computation can be found in O'Hagan (1994) on page 257.
  6. Carlin and Louis (2008) and Gelman, et al. (2003) explain how to use sampling methods for Bayesian linear regression.

References

  • Box, G. E. P.; Tiao, G. C. (1973). Bayesian Inference in Statistical Analysis. Wiley. ISBN 0-471-57428-7. 
  • Carlin, Bradley P.; Louis, Thomas A. (2008). Bayesian Methods for Data Analysis (Third ed.). Boca Raton, FL: Chapman and Hall/CRC. ISBN 1-58488-697-8. 
  • Fahrmeir, L.; Kneib, T.; Lang, S. (2009). Regression. Modelle, Methoden und Anwendungen (Second ed.). Heidelberg: Springer. doi:10.1007/978-3-642-01837-4. ISBN 978-3-642-01836-7. 
  • Gelman, Andrew et al. (2013). "Introduction to regression models". Bayesian Data Analysis (Third ed.). Boca Raton, FL: Chapman and Hall/CRC. pp. 353–380. ISBN 978-1-4398-4095-5. 
  • Jackman, Simon (2009). "Regression models". Bayesian Analysis for the Social Sciences. Wiley. pp. 99–124. ISBN 978-0-470-01154-6. 
  • Rossi, Peter E.; Allenby, Greg M.; McCulloch, Robert (2006). Bayesian Statistics and Marketing. John Wiley & Sons. ISBN 0470863676. 
  • O'Hagan, Anthony (1994). Bayesian Inference. Kendall's Advanced Theory of Statistics. 2B (First ed.). Halsted. ISBN 0-340-52922-9. 
  • Bayesian estimation of linear models (R programming wikibook). Bayesian linear regression as implemented in R.