Exercise 1

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a Bayes’ estimate of \(\theta\). (Use the posterior mean.)

Solution

  • Recall that a Beta distribution with parameters \(\alpha\) and \(\beta\) has mean \(\frac{\alpha}{\alpha + \beta}\).
  • The posterior distribution for the Beta-Bernoulli model is a Beta distribution with parameters \(a = \alpha + \sum x_i\) and \(b = \beta + \sum y_i\).
    • Here we have, \(\sum y_i = n - \sum x_i\).
    • Here we are using \(\alpha\) and \(\beta\) as the parameters for the prior, and \(a\) and \(b\) as the parameters of the posterior.

So, in this case, we have

\[ \theta \mid X_1, X_1, \ldots, X_n \sim \text{Beta}(a = 20, b = 10) \]

Then we have

\[ \hat{\theta}_B = \frac{a}{a + b} = \frac{20}{20 + 10} = \boxed{\frac{2}{3}} \]


Exercise 2

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a Bayes’ estimate of \(\theta\). (Use the posterior mean.)

Solution

In this case, we have

\[ \theta \mid X_1, X_1, \ldots, X_n \sim \text{Beta}(a = 82, b = 28) \]

Then we have

\[ \hat{\theta}_B = \frac{a}{a + b} = \frac{82}{82 + 28} = \boxed{\frac{41}{55}} \]


Exercise 3

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a Bayes’ estimate of \(\theta\). (Use the posterior mean.)

Solution

In this case, we have

\[ \theta \mid X_1, X_1, \ldots, X_n \sim \text{Beta}(a = 12, b = 63) \]

Then we have

\[ \hat{\theta}_B = \frac{a}{a + b} = \frac{12}{12 + 63} = \boxed{\frac{4}{25}} \]


Exercise 4

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a 99% credible interval

Solution

qbeta(c(0.005, 0.995), shape1 = 10 + 2, shape2 = 60 + 3)
## [1] 0.06973817931 0.28374038952

Exercise 5

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a 90% credible interval

Solution

qbeta(c(0.05, 0.95), shape1 = 4 + 2, shape2 = 4 + 3)
## [1] 0.2452998013 0.6847622093

Exercise 6

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to calculate a 95% credible interval

Solution

qbeta(c(0.025, 0.975), shape1 = 10 + 2, shape2 = 4 + 48)
## [1] 0.1024842436 0.2909709491

Exercise 7

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to test \(H_0: \theta > 0.50\) vs \(H_1: \theta \leq 0.50\)

Solution

pbeta(0.50, shape1 = 10 + 20, shape2 = 4 + 30, lower.tail = FALSE)
## [1] 0.3073275079
pbeta(0.50, shape1 = 10 + 20, shape2 = 4 + 30)
## [1] 0.6926724921

Accept \(H_1\).


Exercise 8

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to test \(H_0: 0.25 < \theta < 0.50\) vs \(H_1: \theta \leq 0.25, \theta \geq 0.50\)

Solution

diff(pbeta(c(0.25, 0.50), shape1 = 10 + 5, shape2 = 10 + 15))
## [1] 0.9020703778

Accept \(H_0\).


Exercise 9

Consider the following model,

and observed data with statistics,

Use the given prior and the observed data to test \(H_0: \theta > 0.80\) vs \(H_1: \theta \leq 0.80\)

Solution

pbeta(0.80, shape1 = 3 + 70, shape2 = 3 + 30, lower.tail = FALSE)
## [1] 0.003745930192
pbeta(0.80, shape1 = 3 + 70, shape2 = 3 + 30)
## [1] 0.9962540698

Accept \(H_1\).