Exercise

Comparison of proportions

Recall that when comparing two drugs with the use of a uniform prior, the posterior distributions for the two proportions were independent with pS as \(beta(13, 9)\) and pN as \(beta(18, 4)\).

Suppose a vector of differences d_NS = pN - pS is computed. A histogram of the posterior density of d_NS is displayed on the right with a 90 percent probability interval marked by vertical lines.

Now you will look at the posterior of the ratio of proportions r_NS = pN / pS.

Instructions

100 XP
  • Use the code provided in the editor to simulate 1000 draws from the posterior of (pS, pN).
  • For each pair of simulated proportions, compute the ratio of proportions r_NS.
  • Construct a histogram of the simulated values of r_NS.
  • Find the probability r_NS is larger than 1.
  • Find an 80% probability interval for r_NS.