42
Bayesian Methods LABORATORY Lesson 1: Jan 24 2002 Software: R Bayesian Methods – p.1/20

Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

  • Upload
    lethuy

  • View
    239

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Bayesian MethodsLABORATORY

Lesson 1: Jan 24 2002

Software: R

Bayesian Methods – p.1/20

Page 2: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The R Projectfor Statistical Computing

http://www.r-project.org/

• R is a language and environment forstatistical computing and graphics.

• R, like S, is designed around a computer language,and it allows users to add additional functionality bydefining new functions.

• The term "environment" is intended to characterizeit as a fully planned and coherent system, ratherthan an incremental accretion of very specific andinflexible tools.

Bayesian Methods – p.2/20

Page 3: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The R Projectfor Statistical Computing

http://www.r-project.org/

• R is a language and environment forstatistical computing and graphics.

• R, like S, is designed around a computer language,and it allows users to add additional functionality bydefining new functions.

• The term "environment" is intended to characterizeit as a fully planned and coherent system, ratherthan an incremental accretion of very specific andinflexible tools.

Bayesian Methods – p.2/20

Page 4: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The R Projectfor Statistical Computing

http://www.r-project.org/

• R is a language and environment forstatistical computing and graphics.

• R, like S, is designed around a computer language,and it allows users to add additional functionality bydefining new functions.

• The term "environment" is intended to characterizeit as a fully planned and coherent system, ratherthan an incremental accretion of very specific andinflexible tools.

Bayesian Methods – p.2/20

Page 5: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• It is a GNU project which is similar to the Slanguage and environment.

• The GNU Project was launched in 1984 to developa complete Unix-like operating system which is freesoftware.

• Free software is a matter of the users’ freedom torun, copy, distribute, study, change and improve thesoftware. It is not a matter of price!

• R can be considered as a differentimplementation of S. There are some importantdifferences, but much code written for S runs unalteredunder R.

Bayesian Methods – p.3/20

Page 6: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• It is a GNU project which is similar to the Slanguage and environment.

• The GNU Project was launched in 1984 to developa complete Unix-like operating system which is freesoftware.

• Free software is a matter of the users’ freedom torun, copy, distribute, study, change and improve thesoftware. It is not a matter of price!

• R can be considered as a differentimplementation of S. There are some importantdifferences, but much code written for S runs unalteredunder R.

Bayesian Methods – p.3/20

Page 7: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• It is a GNU project which is similar to the Slanguage and environment.

• The GNU Project was launched in 1984 to developa complete Unix-like operating system which is freesoftware.

• Free software is a matter of the users’ freedom torun, copy, distribute, study, change and improve thesoftware. It is not a matter of price!

• R can be considered as a differentimplementation of S. There are some importantdifferences, but much code written for S runs unalteredunder R.

Bayesian Methods – p.3/20

Page 8: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• It is a GNU project which is similar to the Slanguage and environment.

• The GNU Project was launched in 1984 to developa complete Unix-like operating system which is freesoftware.

• Free software is a matter of the users’ freedom torun, copy, distribute, study, change and improve thesoftware. It is not a matter of price!

• R can be considered as a differentimplementation of S. There are some importantdifferences, but much code written for S runs unalteredunder R.

Bayesian Methods – p.3/20

Page 9: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

ONE-DIMENSIONAL parameter models

1. The Binomial model and its coniugate Betaprior

in Bin(n, θ) there is a single parameter of interest

(n is tipically assumed known), that is the probability θ

of a certain outcome in each of the n trials con-

sidered.

Bayesian Methods – p.4/20

Page 10: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Bayesian estimation of a probability fromBINOMIAL data

Gelman book, pag. 39, sec. 2.5R code placenta.r is in the Lab notes at the course webpage

• Our interest focus on the proportion of female births inthe so called maternal condition placenta previa

• Our data consist in a early study in Germany: 437females on 980 placenta previa births

• How much evidence do they provide that theproportion of placenta previa female births is < 0.485,the proportion of the general population female births?

Bayesian Methods – p.5/20

Page 11: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Bayesian estimation of a probability fromBINOMIAL data

Gelman book, pag. 39, sec. 2.5R code placenta.r is in the Lab notes at the course webpage

• Our interest focus on the proportion of female births inthe so called maternal condition placenta previa

• Our data consist in a early study in Germany: 437females on 980 placenta previa births

• How much evidence do they provide that theproportion of placenta previa female births is < 0.485,the proportion of the general population female births?

Bayesian Methods – p.5/20

Page 12: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Bayesian estimation of a probability fromBINOMIAL data

Gelman book, pag. 39, sec. 2.5R code placenta.r is in the Lab notes at the course webpage

• Our interest focus on the proportion of female births inthe so called maternal condition placenta previa

• Our data consist in a early study in Germany: 437females on 980 placenta previa births

• How much evidence do they provide that theproportion of placenta previa female births is < 0.485,the proportion of the general population female births?

Bayesian Methods – p.5/20

Page 13: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Analysis using a UNIFORM PRIOR

• Let the 1-parameter θ denote the proportionof placenta previa female births

• We assume a Bin(θ, 980) ∝ θ437 (1− θ)980−437

to be the model generating the data• We specify the prior for θ to be a U [0, 1]

• The posterior for θ is, then,∝ θ437 (1− θ)980−437, i.e., is aBeta(437 + 1, 980− 437 + 1)

Bayesian Methods – p.6/20

Page 14: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Analysis using a UNIFORM PRIOR

• Let the 1-parameter θ denote the proportionof placenta previa female births

• We assume a Bin(θ, 980) ∝ θ437 (1− θ)980−437

to be the model generating the data

• We specify the prior for θ to be a U [0, 1]

• The posterior for θ is, then,∝ θ437 (1− θ)980−437, i.e., is aBeta(437 + 1, 980− 437 + 1)

Bayesian Methods – p.6/20

Page 15: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Analysis using a UNIFORM PRIOR

• Let the 1-parameter θ denote the proportionof placenta previa female births

• We assume a Bin(θ, 980) ∝ θ437 (1− θ)980−437

to be the model generating the data• We specify the prior for θ to be a U [0, 1]

• The posterior for θ is, then,∝ θ437 (1− θ)980−437, i.e., is aBeta(437 + 1, 980− 437 + 1)

Bayesian Methods – p.6/20

Page 16: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Analysis using a UNIFORM PRIOR

• Let the 1-parameter θ denote the proportionof placenta previa female births

• We assume a Bin(θ, 980) ∝ θ437 (1− θ)980−437

to be the model generating the data• We specify the prior for θ to be a U [0, 1]

• The posterior for θ is, then,∝ θ437 (1− θ)980−437, i.e., is aBeta(437 + 1, 980− 437 + 1)

Bayesian Methods – p.6/20

Page 17: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

(Beta-)Uniform–Binomial

0.35 0.40 0.45 0.50 0.55

05

1015

2025

theta

likelihood

Bayesian Methods – p.7/20

Page 18: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

(Beta-)Uniform–Binomial

0.35 0.40 0.45 0.50 0.55

05

1015

2025

theta

likelihood

prior

Bayesian Methods – p.7/20

Page 19: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

(Beta-)Uniform–Binomial

0.35 0.40 0.45 0.50 0.55

05

1015

2025

theta

likelihood

prior

posterior

Bayesian Methods – p.7/20

Page 20: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Analysis using different BETA PRIORS

As the likelihood p(y|θ) ≡ L(θ; y) is ∝ θy (1− θ)n−y

if the prior is of the same form, e.g., p(θ) is ∝

θα−1 (1− θ)β−1

then the posterior will also be of this form. In fact, p(θ|y) is

∝ θy+α−1 (1− θ)n−y+β−1 = Beta(α + y, β + n− y)

-> the BETA prior distribution is a coniugate family forthe BINOMIAL likelihood

Bayesian Methods – p.8/20

Page 21: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 10

0.35 0.40 0.45 0.50 0.55

05

1015

2025 a+b−2= 100

0.35 0.40 0.45 0.50 0.55

05

1525

35 a+b−2= 1000

0.35 0.40 0.45 0.50 0.55

020

4060

80 a+b−2= 10000

Bayesian Methods – p.9/20

Page 22: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 10

0.35 0.40 0.45 0.50 0.55

05

1015

2025 a+b−2= 100

0.35 0.40 0.45 0.50 0.55

05

1525

35 a+b−2= 1000

0.35 0.40 0.45 0.50 0.55

020

4060

80 a+b−2= 10000

Bayesian Methods – p.9/20

Page 23: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 0

0.35 0.40 0.45 0.50 0.55

05

1015

2025

a+b−2= 10

0.35 0.40 0.45 0.50 0.55

05

1015

2025 a+b−2= 100

0.35 0.40 0.45 0.50 0.55

05

1525

35 a+b−2= 1000

0.35 0.40 0.45 0.50 0.55

020

4060

80 a+b−2= 10000

Bayesian Methods – p.9/20

Page 24: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

How does posterior COMPROMISE betweenprior and the data?

• The compromise depends on how muchweight prior has (or how much informative itis) w.r.t. the data at hand

• i.e., in the binomial case, depends on therelative weight of

α + β − 2≈ number of prior observations (∼ priorprecision)Note: precision=1/variance, var= θ(1−θ)

α+β+1

w.r.t. n, the sample size

Bayesian Methods – p.10/20

Page 25: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

How does posterior COMPROMISE betweenprior and the data?

• The compromise depends on how muchweight prior has (or how much informative itis) w.r.t. the data at hand

• i.e., in the binomial case, depends on therelative weight of

α + β − 2≈ number of prior observations (∼ priorprecision)Note: precision=1/variance, var= θ(1−θ)

α+β+1

w.r.t. n, the sample size

Bayesian Methods – p.10/20

Page 26: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

A first SENSITIVITY ANALYSIS

concept of sensitivity: sensitivity or robustness of theinferences to the choice of the prior

Prior information Posterior information

α + β − 2 mean mean 95% interval

0 0.500 0.446 [ 0.415 , 0.477 ]

0 0.485 0.446 [ 0.415 , 0.477 ]

10 0.485 0.446 [ 0.416 , 0.477 ]

100 0.485 0.450 [ 0.420 , 0.479 ]

1000 0.485 0.466 [ 0.444 , 0.488 ]

10000 0.485 0.482 [ 0.472 , 0.491 ]

NOTE: in placenta previa example n ≈ 1000 and y = 0.446

Bayesian Methods – p.11/20

Page 27: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The SIMULATION-based estimation ap-proach

• The modern approach to Bayesian estimationhas become closely linked to simulation-basedestimation methods.

• In fact, Bayesian estimation focuses onestimating the entire density of a parameter.

• This density estimation is based ongenerating samples from the posterior densityof the parameters themselves or of functionsof parameters.

Bayesian Methods – p.12/20

Page 28: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The SIMULATION-based estimation ap-proach

• The modern approach to Bayesian estimationhas become closely linked to simulation-basedestimation methods.

• In fact, Bayesian estimation focuses onestimating the entire density of a parameter.

• This density estimation is based ongenerating samples from the posterior densityof the parameters themselves or of functionsof parameters.

Bayesian Methods – p.12/20

Page 29: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

The SIMULATION-based estimation ap-proach

• The modern approach to Bayesian estimationhas become closely linked to simulation-basedestimation methods.

• In fact, Bayesian estimation focuses onestimating the entire density of a parameter.

• This density estimation is based ongenerating samples from the posterior densityof the parameters themselves or of functionsof parameters.

Bayesian Methods – p.12/20

Page 30: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• In the BETA-BINOMIAL model, the coniugacyallows us knowing the posterior density inclosed form.

• Then, direct calculations are feasible or directsimulation from it can be performed.

• However, even if posterior density cannot beexplicitly integrated, iterative simulationmethods (or MCMC) are alternatively used.We will see them in future lab’s.

Bayesian Methods – p.13/20

Page 31: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• In the BETA-BINOMIAL model, the coniugacyallows us knowing the posterior density inclosed form.

• Then, direct calculations are feasible or directsimulation from it can be performed.

• However, even if posterior density cannot beexplicitly integrated, iterative simulationmethods (or MCMC) are alternatively used.We will see them in future lab’s.

Bayesian Methods – p.13/20

Page 32: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

• In the BETA-BINOMIAL model, the coniugacyallows us knowing the posterior density inclosed form.

• Then, direct calculations are feasible or directsimulation from it can be performed.

• However, even if posterior density cannot beexplicitly integrated, iterative simulationmethods (or MCMC) are alternatively used.We will see them in future lab’s.

Bayesian Methods – p.13/20

Page 33: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

a first (direct) simulationCongdon book, pag. 31, sec. 2.11

• Wilcox (1996) presents data from a 1991 gallupopinion poll about the morality of President Bush’s nothelping Iraqi rebel groups after the formal end of thegulf war. Of the 751 adults responding, 150 thoughtthe president’s actions were not moral.

• We are interested in assessing the probability that arandomly sampled adult would respond ‘immoral’.

• In the inference we might use evidence from previouspolls on the proportion of the population generallylikely to consider a President’s actions immoral.

Bayesian Methods – p.14/20

Page 34: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

a first (direct) simulationCongdon book, pag. 31, sec. 2.11

• Wilcox (1996) presents data from a 1991 gallupopinion poll about the morality of President Bush’s nothelping Iraqi rebel groups after the formal end of thegulf war. Of the 751 adults responding, 150 thoughtthe president’s actions were not moral.

• We are interested in assessing the probability that arandomly sampled adult would respond ‘immoral’.

• In the inference we might use evidence from previouspolls on the proportion of the population generallylikely to consider a President’s actions immoral.

Bayesian Methods – p.14/20

Page 35: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

a first (direct) simulationCongdon book, pag. 31, sec. 2.11

• Wilcox (1996) presents data from a 1991 gallupopinion poll about the morality of President Bush’s nothelping Iraqi rebel groups after the formal end of thegulf war. Of the 751 adults responding, 150 thoughtthe president’s actions were not moral.

• We are interested in assessing the probability that arandomly sampled adult would respond ‘immoral’.

• In the inference we might use evidence from previouspolls on the proportion of the population generallylikely to consider a President’s actions immoral.

Bayesian Methods – p.14/20

Page 36: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

a first (direct) simulationThe R code is in betabin.r at the course web page

• We present Bayesian inference about the probability ofan adult responding ‘immoral’ assuming different Betapriors:

1. α = β = 1 prior information ∼ 0 E = 1/2

2. α = β = 0.001 prior information < 0 E = 1/2

3. α = 1 β = 0.11 prior information < 0 E = 0.9

4. α = 1.8 β = 0.2 prior information ∼ 0 E = 0.9

5. α = 4.5, 45 β = 0.5, 5 prior information ∼ 5,50E = 0.9

Bayesian Methods – p.15/20

Page 37: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

1., 2. are both non informative, but 2. is a reasonable choice for

‘one-off’ events (or for correlated data) 3., 4. may be assumed on the

basis of previous polls. Although E=0.9 they still are diffuse. 5., 6 are

increasingly informative.

0.0 0.2 0.4 0.6 0.8 1.0

02

46

810

density(x = rbeta(50000, 45, 5))

N = 50000 Bandwidth = 0.004278

Den

sity

a=.001 b=.001

a=1 b=1

a=45 b=5

Bayesian Methods – p.16/20

Page 38: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Legend for the next figure –>

in each figure:

• curves: histogram of 10,000 draws from the posteriorBeta(150+α,601+β); likelihood ∝ Bin(150,751).intervals: Unif-Bin 95% posterior interval; 95%(Beta(150+α,601+β)) posterior interval; Normalapproximation of the 95% posterior interval; Inverted95% posterior interval on the logit scale.

• Though θ is close to 0, because of the large samplesize (751), the normal approximation is good as well asposterior inferences are insensitive to prior choice(even if discordant to data), at least for prior information≤ 0.

Bayesian Methods – p.17/20

Page 39: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Legend for the next figure –>

in each figure:

• curves: histogram of 10,000 draws from the posteriorBeta(150+α,601+β); likelihood ∝ Bin(150,751).intervals: Unif-Bin 95% posterior interval; 95%(Beta(150+α,601+β)) posterior interval; Normalapproximation of the 95% posterior interval; Inverted95% posterior interval on the logit scale.

• Though θ is close to 0, because of the large samplesize (751), the normal approximation is good as well asposterior inferences are insensitive to prior choice(even if discordant to data), at least for prior information≤ 0.

Bayesian Methods – p.17/20

Page 40: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Histogram of post

0.16 0.18 0.20 0.22 0.24 0.26

05

1020

30

a+b−2= 0 a= 1

Histogram of post

0.16 0.18 0.20 0.22 0.24 0.26

05

1020

30

a+b−2= −1.998 a= 0.001

Histogram of post

0.16 0.18 0.20 0.22 0.24 0.26

05

1020

30

a+b−2= −0.89 a= 1

Histogram of post

0.16 0.18 0.20 0.22 0.24 0.26 0.28

05

1020

30

a+b−2= 0 a= 1.8

Histogram of post

0.16 0.18 0.20 0.22 0.24 0.26

05

1020

30

a+b−2= 3 a= 4.5

Histogram of post

0.20 0.22 0.24 0.26 0.28 0.30

05

1020

30

a+b−2= 48 a= 45

Bayesian Methods – p.18/20

Page 41: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

And what about if our sample size was only

n = 5, with y = 1 adults consideringimmoral the President’s actions? ->

NOTE: the empirical mean still is y/n = 0.2

Bayesian Methods – p.19/20

Page 42: Bayesian Methods - Departmentsfdominic/teaching/BM/slides1.pdf · Bayesian Methods – p.5/20. Bayesianestimationofaprobabilityfrom BINOMIAL data Gelman book, pag. 39, sec. 2.5 R

Histogram of post

0.0 0.2 0.4 0.6 0.8

0.0

1.0

2.0

a+b−2= 0 a= 1

Histogram of post

0.0 0.2 0.4 0.6 0.8

01

23

a+b−2= −1.998 a= 0.001

Histogram of post

0.0 0.2 0.4 0.6 0.8

0.0

1.0

2.0

a+b−2= −0.89 a= 1

Histogram of post

0.0 0.2 0.4 0.6 0.8

0.0

1.0

2.0

a+b−2= 0 a= 1.8

Histogram of post

0.2 0.4 0.6 0.8

0.0

1.0

2.0

a+b−2= 3 a= 4.5

Histogram of post

0.65 0.70 0.75 0.80 0.85 0.90 0.95

02

46

8

a+b−2= 48 a= 45

Bayesian Methods – p.20/20