Chair of Spatial Data Science and Statistical Learning

Lecture 5 Bayesian Inference

5.1 Overview

This lecture provides an introduction to Bayesian inference, the second major approach to statistical inference alongside likelihood-based inference. After a short recap on likelihood-based inference in Section 5.2, we continue with the motivation for Bayesian inference in Section 5.3 which arises from another philosophical perspective on the parameter of interest, namely that it comes from a random distribution. By referring to Bayes’ Theorem in Section 5.4 we explain how the posterior distribution of the parameter is linked to three key components: the likelihood, the prior, and the marginal model. In Section 5.5 then provide an example of such an bayesian approach. Finally, in the very last Section 5.7 we present different types of prior distributions for the parameter of interest.

5.2 Reminder: Likelihood Inference

In likelihood inference, we have redefined the density as the likelihood: Lx(θ)=i=1nf(xi|θ)=p(x|θ)=Pθ(X=x) This means our objective function is the likelihood of the observed random data given the fixed parameter θ. To estimate the true population parameter θ, we maximize the likelihood with respect to θ: θ^ML=argmaxθLx(θ)

5.3 Philosophical Consideration: Parameter Distribution

Up to now we have assumed that only the data comes from a random distribution D while parameter vector θ is fixed: XD(θ)whereθ=const. However, by using a frequentist approach (maximum likelihood) it is only possible to infer the insecurity of the estimation but not the distribution of the parameter itself.

Bayesian statistics builds upon the question whether a parameter can be fixed or if it is random anyway. It assumes that also the parameter θR has a random prior distribution D with parameter vector ξ: θD(ξ) That leads to our target size now being p(θ|X). This is called the posterior distribution of θ since it is the distribution of the parameter after observing the data. For the following sections we follow the very same bayesian approach and assume randomness in the parameter θ.

5.4 Bayes’ Theorem

5.4.1 General Equation

Thomas Bayes’ Theorem provides a mathematical rule for inverting conditional probabilities. It can be written as the following fraction: P(A|B)=P(B|A)P(A)P(B) where A and B are events and P(B)0.

  • P(A|B) is the conditional probability of event A occurring given that B is true.
  • P(B|A) is the conditional probability of event B occurring given that A is true.
  • P(A) and P(B) are the probabilities of observing A and B respectively without any given conditions. They are known as the marginal probabilities.

The question now is: How can this be used for inference?

5.4.2 Application: Bayesian Inference

Substituting the target distribution p(θ|X) into the left-hand side of Bayes’ Theorem yields the following equation: p(θ|X)=p(X|θ)p(θ)p(X) where

  • p(θ|X) is the posterior distribution of the random parameter θ given the data X.
  • p(X|θ) is the likelihood of the data given the fixed parameter.
  • p(θ) is the prior probability of the parameter.
  • p(X) is the marginal distribution of the data.

We can now reinterpret this fraction as a framework for updating probabilities based on new evidence. Since the denominator is fixed, it is called the normalizing constant and does not affect the mode of the posterior. Hence, it is often sufficient to consider only the numerator, as the equations are proportional: p(θ|X)p(X|θ)p(θ)

In Bayesian inference we now search for p(θ|X), i.e., the distribution of the parameter given the data. For this purpose we only need the likelihood p(X|θ) and the prior distribution p(θ).

5.5 Practical Example

5.5.1 Setting

We assume that the data are realizations from a Poisson-distributed random variable X. However, the rate parameter λ of this distribution is also assumed to be random. Given that it can only take positive values, suitable prior distributions include the Chi-Squared, Exponential, and Gamma distribution. Among these, the gamma distribution is often the preferred choice, which we will also use in the following example:

  • xiPo(λ),i=1,,n
  • λGa(a0,b0)
As a result, the posterior distribution is proportional to: p(θ|X)i=1nλxixi!exp(λ)Likelihood: p(X|λ)b0a0Γ(a0)λa01exp(λb0)Prior: p(λ)
Reminder: PMF of Poisson and Density of Gamma

Probability Mass Function Poisson: f(x|λ)=λxx!eλ

Density Gamma: f(x|α,β)=βαΓ(α)xα1eβx Note: In our case λ is the random variable in the gamma density.

5.5.2 Result

The next step is to simplify the term and remove all parts that do not depend on λ: p(θ|X)λi=1nxiexp(nλ)λa01exp(λb0)b0a0Γ(a0)i=1nxi!does not depend on λλ(a0+i=1nxi)1exp((n+b0)λ) When having a closer look, the result has an identical kernel structure as the gamma prior. We conclude: λ|xGa(a0+i=1nxi,n+b0)

The moments of a gamma distribution Ga(α,β) with parameters α and β are given by E(X)=αβ and Var(X)=αβ2.

In our exemplary case, the posterior mean is given by E(λ|x)=a0+i=1nxin+b0=nb0a0+nb0i=1nxinb0(b0+n)=nb0+ni=1nxin+b0b0+na0b0=nb0+nλ^ML+b0b0+nλ^prior and the posterior variance is expressed as

Var(λ|x)=a0+i=1nxi(n+b0)2=i=1nxi(n+b0)2+a0(n+b0)2=n2(n+b0)2i=1nxin2+b02(n+b0)2a0b02=n2(n+b0)2Var(λ^ML)+b02(n+b0)2Var(λprior)

5.5.3 Interpretation

We observe that both the posterior mean and variance are weighted averages of the respective moments derived from the MLE and the prior distribution. Notably, a larger prior scale parameter b0 , which corresponds to a smaller prior variance, increases the prior’s influence. However, as the number of observations n increases, the likelihood’s influence becomes more dominant relative to the prior.

5.6 Interactive Shiny App

An example of Poisson-distributed data is the number of days in August with a maximum temperature below 0°C on the Zugspitze (Germany), observed over the years 1936 to 2016. In the following app you can get an impression on how the shape of the likelihood and the Gamma prior influence the resulting posterior distribution:

Click here for the full version of the ‘Introduction to Bayesian Statistics’ shiny app. It even includes a second example from the WeatherGermany dataset to play around with.

5.7 Types of Priors

A suitable prior distribution is one that matches the parameter space of the respective parameter. However, there are three special types of priors that are often used in practice:

  • Conjugate priors
  • Non-informative priors (not relevant)
  • Jeffreys priors (not relevant)

5.7.1 Conjugate Priors

A prior distribution p(θ) is called conjugate prior for the likelihood Lx(θ) if the posterior distribution p(θ|x) is in the same distribution family as the prior. This phenomenon allows for simpler calculations of the posterior making Bayesian inference easier. A conjugate prior can be identified by examining the kernel of the distribution and the support of the prior. See the example in Section 5.5 where the gamma distribution is conjugate to the poisson distribution with respect to λ.

5.7.2 Excursus: Non-informative Priors

Non-informative priors are used when we are indifferent about the parameter’s distribution. They assign equal probabilities to all possible values of the parameter vector θ: p(θ)const. Since the prior is proportional to a constant, these priors are also referred to as “flat priors”. Common examples include the uniform distribution prior or Jeffreys prior 5.7.3. Typically, the usage of flat priors in Bayesian inference yields a posterior that does not differ a lot from the frequentist approach (Maximum-Likelihood).

5.7.3 Excursus: Jeffreys Prior

Jeffreys Prior is commonly used as a non-informative prior because of its desirable properties. Its density function is proportional to the square root of the determinant of the Fisher information matrix: p(θ)|I(θ)|12 One of is key features is that it is invariant under reparametrization. In contrast, a uniform prior is not invariant, i.e., if you apply nonlinear transformation, the prior distribution changes in a way that might introduce bias.

Example: Jeffreys Prior for Gaussian Distribution

For the Gaussian distribution of the real value x f(x|σ)=12πσ2exp(xμ)22σ2 with μ fixed, the Jeffreys prior for the standard deviation σ>0 is p(σ)I(σ)=E[(ddσlogf(x|σ))2]=E[((xμ)2σ2σ3)2]=+f(x|σ)((xμ2)σ2σ3)2dx=2σ21σ