ArticleslgStudy

mathematics

Bayesian linear regression

Bayesian linear regression is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bayesian linear regression rather than just read about it. In short: 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 ob…

Bayesian linear regression — main illustration
Bayesian linear regression — illustration

Key takeaways

  • Bayesian linear regression belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bayesian linear regression to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bayesian linear regression from memory before moving on to harder problems.

Reference excerpt

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=𝐱i𝖳𝜷+εi, where 𝜷 is a k×1 vector, and the εi are independent and identically normally distributed random variables: εi∼N(0,σ2). This corresponds to the following likelihood function: ρ(𝐲∣𝐗,𝜷,σ2)∝(σ2)−n/2exp⁡(−12σ2(𝐲−𝐗𝜷)𝖳(𝐲−𝐗𝜷)). The ordinary least squares solution is used to estimate the coefficient vector using the Moore–Penrose pseudoinverse: 𝜷̂=(𝐗𝖳𝐗)−1𝐗𝖳𝐲 where 𝐗 is the n×k design matrix, each row of which is a predictor vector 𝐱i𝖳; and 𝐲 is the column n-vector [y1⋯yn]𝖳. This is a frequentist approach, and it assumes that there are enough measurements to say something meaningful about 𝜷. In the Bayesian approach, the data is 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 comprises 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 𝐗. We can factor out the joint likelihood by assuming strict exogeneity. Strict exogeneity requires:

that the parameter vector 𝜽=(𝜷,γ) can be decomposed into two components, with 𝜷 indexing the conditional density of the response variable ρ(yi∣𝒙i) and γ indexing the marginal density of the regressors ρ(𝒙i) that data point yj not convey any additional information about data point yi beyond that contained in the regressors 𝒙i and the parameter vector 𝜷 Formally, the first condition requires that ρ(yi∣𝒙i,𝜽)=ρ(yi∣𝒙i,𝜷) and ρ(𝒙i∣𝜽)=ρ(𝒙i∣γ), and the second condition requires ρ(yi|yj,𝒙i,𝒙j,𝜷)=ρ(yi|𝒙i,𝜷) for all j≠i. Under strict exogeneity, the joint likelihood can then be factored into ρ(𝐲∣𝐗,β,σ2)ρ(𝐗∣γ). The latter part is usually ignored under the assumption of disjoint parameter sets. More strongly, 𝐗 is often considered as chosen (for example, in a designed experiment) and therefore has a known probability without parameters.

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 the posterior 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 (𝐲−𝐗𝜷)𝖳(𝐲−𝐗𝜷)=[(𝐲−𝐗𝜷̂)+(𝐗𝜷̂−𝐗𝜷)]𝖳[(𝐲−𝐗𝜷̂)+(𝐗𝜷̂−𝐗𝜷)]=(𝐲−𝐗𝜷̂)𝖳(𝐲−𝐗𝜷̂)+(𝜷−𝜷̂)𝖳(𝐗𝖳𝐗)(𝜷−𝜷̂)+2(𝐗𝜷̂−𝐗𝜷)𝖳(𝐲−𝐗𝜷̂)⏟= 0=(𝐲−𝐗𝜷̂)𝖳(𝐲−𝐗𝜷̂)+(𝜷−𝜷̂)𝖳(𝐗𝖳𝐗)(𝜷−𝜷̂). The likelihood is now re-written as ρ(𝐲|𝐗,𝜷,σ2)∝(σ2)−v2exp⁡(−vs22σ2)(σ2)−n−v2exp⁡(−12σ2(𝜷−𝜷̂)𝖳(𝐗𝖳𝐗)(𝜷−𝜷̂)), where vs2=(𝐲−𝐗𝜷̂)𝖳(𝐲−𝐗𝜷̂) and v=n−k, 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)−v02−1exp⁡(−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)𝖳𝜦0(𝜷−𝝁0)). In the notation of the normal distribution, the conditional prior distribution is 𝒩(𝝁0,σ2𝜦0−1).

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Bayesian linear regression

Start with the simplest possible case. Write down what Bayesian linear regression claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bayesian linear regression before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bayesian linear regression ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bayesian linear regression

In research
Bayesian linear regression appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bayesian linear regression in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bayesian linear regression is common in secondary-school and first-year university syllabi. It links to neighbouring topics Bayesian inference, Single-equation methods (econometrics), so understanding it makes those chapters shorter.
In everyday life
Look for Bayesian linear regression outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bayesian linear regression” →

How to study Bayesian linear regression in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bayesian linear regression means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bayesian linear regression out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bayesian linear regression in simple terms?

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…

Why does Bayesian linear regression matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bayesian linear regression?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bayesian linear regression.

Tags

  • Bayesian inference
  • Single-equation methods (econometrics)

Keep exploring