bayesian-course-1-short
bayesian-course-1-short
rule
Ben Lambert1
[email protected]
1 Imperial
College
London
1 Introduction
2 Course outline
2 Course outline
Today:
Lecture: 9.30am - 11am.
Class: 11:30am - 1pm.
Lecture: 2pm-3.30pm.
Class: 3.30pm - 5.15pm.
N.B. Usually I have 8-9 hours of lectures to teach this
material. We have 3 hours!
Lecture notes:
http://ben-lambert.com/bayesian-short-course/
1 Introduction
2 Course outline
2 Course outline
2 Course outline
B
Figure: Images adapted from “A Technical Introduction to Probability and
Bayesian Inference for Stan Users”, Stan Development Team, 2016.
What is inference?
B
An unlikely Small World
T Θ
B
A Boxian Small World: “All models are wrong but
some are useful”
T
Θ
B
The prior
T
μ = 1.5m
Θ
μ = 100m
B
The prior
T
μ = 1.5m
Θ
μ = 100m
B
The data
T
Θ
B
After the data
T
Θ
B
Summary of the inference process
B
The whole inference process
Specify a likelihood
T
Θ
B
The whole inference process
Specify a prior
T
Θ
B
The whole inference process
T
Θ
B
1 Introduction
2 Course outline
1
Inspired by Prof. Philip Maini.
Example likelihood: frequency of lift malfunctioning
X ∼ Poisson(5)
0.20
● ●
0.15 ●
●
pmf
●
0.10
●
●
0.05
● ●
●
● ● ●
0.00 ● ● ● ● ● ● ● ● ● ● ● ● ●
0 5 10 15 20 25
number of times lift breaks in one year
Example likelihood: frequency of lift malfunctioning
X ∼ Poisson(10)
0.20
0.15
● ●
● ●
pmf
0.10 ●
●
●
●
0.05 ●
● ●
● ●
● ●
● ● ●
0.00 ● ● ● ● ● ● ● ●
0 5 10 15 20 25
number of times lift breaks in one year
Example likelihood: frequency of lift malfunctioning
X ∼ Poisson(15)
0.20
0.15
pmf
0.10 ●
● ●
●
● ●
● ●
●
0.05 ●
●
● ●
● ●
● ● ●
● ● ● ● ● ● ● ●
0.00
0 5 10 15 20 25
number of times lift breaks in one year
Example likelihood: frequency of lift malfunctioning
X ∼ Poisson(θ)
0.20
0.15
θ=5
pmf
0.10 θ = 10
θ = 15
0.05
0.00
0 5 10 15 20 25
number of times lift breaks in one year
The aim of inference: inverting the likelihood
pmf
pmf
0.10 0.10 0.10
X=8
The aim of inference: inverting the likelihood
pmf
pmf
0.10 0.10 0.10
X=8
The aim of inference: inverting the likelihood
pmf
pmf
0.10 0.10 0.10
X=8
The aim of inference: inverting the likelihood
0.12
0.10
0.08
pmf
0.06
0.04
0.02
0.00
0 5 10 15 20 25 30
number of times lift breaks in one year
Frequentist inversion: null hypothesis testing
0.10
0.08
pmf
0.06
0.04
0.02
0.00
0 5 10 15 20 25 30
number of times lift breaks in one year
Frequentist inversion: null hypothesis testing
0.10
0.08
pmf
0.06
0.04
0.02
0.00
0 5 10 15 20 25 30
number of times lift breaks in one year
Frequentist inversion: null hypothesis testing
prior
0 5 10 15 20 25
mean number of times lift breaks in one year (θ)
Bayesian inversion
prior
pdf
data (likelihood)
0 5 10 15 20 25
mean number of times lift breaks in one year (θ)
Bayesian inversion
prior
data (likelihood)
pdf
posterior
0 5 10 15 20 25
mean number of times lift breaks in one year (θ)
Bayesian inversion: finding summary intervals
0.15
0.10
pdf
posterior
0.05
0.00
0 5 10 15 20 25
number of times lift breaks in one year (θ)
Bayesian inversion
0.15
area = 0.9
0.10
pdf
posterior
0.05
0.00
0 5 10 15 20 25
number of times lift breaks in one year (θ)
2 Course outline
Suppose:
The probability that a randomly chosen 40 year old
1
woman has breast cancer is approximately 100 .
If a woman has breast cancer the probability they will test
positive in a mammography is about 90%.
However there is a risk of about 8% of a false positive
result of the test.
Question: given that a woman tests positive, what is the
probability that they have breast cancer?
Bayes’ rule in action: breast cancer screening
Pr(+ | ) × Pr( )
Pr( | +) =
Pr(+)
Bayes’ rule in action: breast cancer screening
0.9 0.01
}
}
Pr(+ | ) × Pr( )
Pr( | +) =
Pr(+)
}
?
Marginalise out any cancer dependence via summation
(discrete equivalent of integration):
p(B|A) × p(A)
p(A|B) = (5)
p(B)
Bayes’ rule for inference
MAP
mean
posterior pdf
median
MAP
mean
median
θ
Intuition behind Bayesian analyses
Bayes’ rule:
0 20 40 60 80 100
likelihood
likelihood
0 20 40 60 80 100
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
Intuition behind Bayesian analyses: PD rate again
0 20 40 60 80 100
likelihood
likelihood
0 20 40 60 80 100
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
Intuition behind Bayesian analyses: PD rate again
0 20 40 60 80 100
likelihood
likelihood
0 20 40 60 80 100
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
An exception: zero priors (avoid these)
pdf prior
0 20 40 60 80 100
likelihood
likelihood
0 20 40 60 80 100
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
Intuition behind Bayesian analyses: summary
2 Course outline
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
Posterior predictive distribution
posterior predictive
pmf
0 1 2 3 4 5 6 7 8 9 10
˜
X , number of PD cases in new sample
Posterior predictive distribution
posterior
pdf
0 20 40 60 80 100
θ (PD prevalence), %
Posterior predictive distribution
posterior predictive
pmf
0 1 2 3 4 5 6 7 8 9 10
˜
X , number of PD cases in new sample
Posterior predictive distribution: uses
T
Posterior Posterior predictive
~
θ|X X|X
Summary
Bayesian statistics:
p(D|θ) × p(θ)
p(θ|D) = (13)
p(D)
Beigeian statistics:
p(D|θ) × p(θ)
p(θ|D) = (14)
p(D)