Bayesclassday 1
Bayesclassday 1
2. Classical Solutions
3. BAYES Solution
1
THE PROBLEM
Multiple laboratories perform repeated
measurements on the same quantity. The
objective is to arrive at
• consensus value
• associated consensus measure of
uncertainty.
2
EXAMPLE:
PCB 101:
3
Graph of the Lab means ± 2 stdev.
42
40
38
mean
36
34
32
30
1 2 3 4 5 6
lab
4
CLASSICAL SOLUTIONS
Solution 1.
The Simplest.
GRAND MEAN:
(36.50)
5
Assumptions:
Advantages:
1. Conceptual simplicity.
2. Ease of calculation.
Disadvantages:
6
Solution 2.
THE MEAN OF MEANS:
(34.45)
7
Assumptions:
Advantages:
1. Simplicity.
2. Ease of calculation.
3. Assumptions are less restrictive
than for Method 1.
8
Solution 3.
More sophisticated.
Maximum Likelihood(MLE) &
variants:
(1.29)
9
Assumptions:
Advantages:
The assumptions are the least restrictive
so far and thus more likely to be met and
produce accurate results.
Disadvantages:
More computationally demanding.
10
Summary of the Results for
PCB 101:
42
38
mean
34
30
11
Notes:
12
Solution 4.
A Bayesian Solution:
Classical:
Parameter µ is fixed.
Data are random.
Bayes:
Data (once observed) are
fixed.
Parameter µ is random.
13
0.25
0.20
0.15
0.10
0.05
0.00
26.70 28.37 30.04 31.71 33.38 35.05 36.72 38.39 40.06 41.73 43.40
consensus.mean
14
Advantages of the Bayesian formulation.
15
Disadvantages of the Bayesian
formulation.
16
Specifying the prior distribution.
17
We will get back to the construction of
priors later.
18
SECTION 2 – BAYESIAN
STATISTICS 101
2.1 PROBABILITY
a. Definitions
b. Conditional Probability
c. Law of Total Probability
d. Bayes’ Rule
19
2.1 PROBABILITY
Basic Properties:
1. 0 ≤ P(A ) ≤ 1.
2. P(S) = 1.
3. P(Ø) = 0.
4. P(A)=1-P(~A)
5. If A and B have no outcomes
in common then P(A U B) =
P(A) + P(B).
20
Example 1: Throw a six-sided die.
Event A: throw a 5,
Event B : throw a 6,
Event C: throw an even number.
21
Interpretations of Probability:
2. Degree of Belief
22
Example 2: Weather forecasting.
23
Conditional Probability:
24
Definition:
The conditional probability of B given A
is
P(B|A) = P(A B)/ P(A),
Multiplication Rule:
P(A B) = P(A) P(B|A).
Independence of events:
A and B are independent if
P(A|B) = P(A) or P(B|A) = P(B).
25
In Example 1:
Event B : throw a 6,
Event C: throw an even number.
P(BI C ) 1
6
P(B|C) = = = 1/3.
P(C) 1
2
26
Example 3: Test a randomly selected
subject’s blood to determine whether
infected by a disease.
27
P(A|B) = probability of subject being
infected given a positive test
result.
By definition:
P(A|B) = P(A B)/ P(B)
= P(B|A) P(A) / P(B) ***
28
LAW OF TOTAL PROBABILITY
A B
C∩B
C∩A
P( C ) = P(C A) + P(C B)
= P(C|A) P(A) + P(C|B) P(B)
29
Applying the Law of Total Probability to
Example 3:
So
P(A|B) =
P(B|A) P(A) /
(P(B|A) P(A)+P(B|~A) P(~A))
30
In Example 3:
Recall that
Event A = subject is infected
Event B = test is positive.
Let
P(A) = 0.2
P(B|A) = 0.9
( 1 – P(B|A) = 0.1 is the false negative rate)
P(B| ~ A) = 0.05
( the false positive rate)
31
P(B) = P(B|A)P(A) + P(B|~ A)P(~ A)
= 0.9 (0.2) + 0.05 (0.8) = 0.22
32
How do we apply BAYES THEOREM
in interlab experiments ?
33
Classical statistical models use only the
function P(Y| ) .
34
Given data, this can be inverted into a
confidence interval which enables us to
say:
35
Bayesian models use Bayes Theorem to
obtain P( |Y) which enables us to say :
36
We will now turn to the simpler situation
of models for proportions to fully explain
the concepts of prior distributions,
likelihood functions and the use of Bayes
Result to obtain posterior distributions.
37
2.2 MODELS FOR PROPORTIONS
&LJDUHWWH
38
Objective:
Compare the responses of the two
types of cigarettes for the three types
of substrate.
Let p1 = probability that #529 ignites
10 layers (1993),
P2 = probability that #531 ignites
10 layers (1993).
39
Classical Analysis:
Calculate a 95% confidence interval
for p1 and p2 based on the sample
proportions p̂1 = 0 16 , p̂2 = 16 16 , i.e.
We obtain:
0.005728 ≤ p1 ≤0.240736
0.759264≤ p2 ≤0.994272
40
To make a more direct comparison
between the two proportions we can
compute a 95% confidence interval
for the difference p1 – p2:
Need:
1. prior probabilities for p1 and
p2, i.e. P(B)
42
Prior Distribution for p1:
Even though p1 can have one of
infinitely many values between 0 and 1,
we can make its range discrete. An
example of a possible prior distribution
is:
Value of p1 Probability
0 0.6
0.0625 0.15
0.125 0.1
0.1875 0.07
0.25 0.05
0.3125 0.03
0.375 0
0.4375 0
0.5 0
0.5625 0
0.625 0
0.6875 0
0.75 0
0.8125 0
0.875 0
0.9375 0
43
1 0
0.6
0.5
0.4
probability
0.3
0.2
0.1
0.0
-0.1 0.1 0.3 0.5 0.7 0.9 1.1
p1
Value of p2 Probability
0 0
0.0625 0
0.125 0
0.1875 0
0.25 0
0.3125 0
0.375 0
0.4375 0
0.5 0
0.5625 0
0.625 0
0.6875 0.03
0.75 0.05
0.8125 0.07
0.875 0.1
0.9375 0.15
1 0.6
Mean of p2 = 0.9431
45
The prior distribution of p2 :
0. 6
0. 5
0. 4
probability
0. 3
0. 2
0. 1
0. 0
-0. 1 0. 1 0. 3 0. 5 0. 7 0. 9 1. 1
p2
46
Likelihood Function:
The Likelihood of a model is the
probability of the data occurring,
calculated assuming that model.
47
We can obtain the likelihood values by
assuming a binomial distribution.
If x = number of ignitions
x
P( data = | p = π) =
16
16!
π x (1 − π )16 −x
x! (16 − x )!
48
We obtain for #529:
P(data= 0/16| p1 = 0.0000) = 1.0
P(data= 0/16| p1 = 0.0625) = 0.3561
P(data= 0/16| p1 = 0.125 ) = 0.1181
P(data= 0/16| p1 = 0.1875) = 0.0361
P(data= 0/16| p1 = 0.2500) = 0.01
P(data= 0/16| p1 = 0.3125) = 0.0025
P(data= 0/16| p1 = 0.375) = 0.0005
P(data= 0/16| p1 = 0.4375) = 0.0001
P(data= 0/16| p1 = 0.5000) = 0.0000
P(data= 0/16| p1 0.0625) = 0.0
49
In table form:
Value of p1 Likelihood
0 1
0.0625 0.3561
0.125 0.1181
0.1875 0.0361
0.25 0.01
0.3125 0.0025
0.375 0.0005
0.4375 0.0001
0.5 0
0.5625 0
0.625 0
0.6875 0
0.75 0
0.8125 0
0.875 0
0.9375 0
1 0
50
The likelihood and the prior plotted
on the same graph display the
difference between our prior belief
and the evidence given by the data:
1.0
likelihood
probability
0.8
0.6
0.4
0.2
0.0
-0.1 0.1 0.3 0.5 0.7 0.9 1.1
p1
51
For cigarette #531:
In table form:
Value of p2 Likelihood
0 0
0.0625 0
0.125 0
0.1875 0
0.25 0
0.3125 0
0.375 0
0.4375 0
0.5 0
0.5625 0.0001
0.625 0.0005
0.6875 0.0025
0.75 0.01
0.8125 0.0361
0.875 0.1181
0.9375 0.3561
1 1
52
To calculate the posterior:
PRIOR X LIKELIHOOD
Posterior =
P(Data )
( )
P(Data = 0 16) = P Data = 0 16 | p1 = 0 P ( p1 = 0 )
( )
+... + P Data = 0 16 | p1 = 0.4375 P ( p1 = 0.4375) =
0.66833
53
We obtain for p1:
54
We obtain for p2:
55
To compare the three distributions for p1:
0.6 1.0
0.5 0.8
probability
likelihood
0.4
0.6
0.3
0.4
0.2
0.1 0.2
0.0 0.0
-0.1 0.3 0.7 1.1 -0.1 0.3 0.7 1.1
p1 p1
0.8
posterior
0.6
0.4
0.2
0.0
-0.1 0.3 0.7 1.1
p1
56
57