Exercise

Why simulate?

Simulation is great because you can easily learn about other parameters of interest!

Remember P is the proportion of college women who think they are overweight.

Suppose you are interested instead in a probability interval for the odds ratio (\(OR\)), the ratio of the probability of "overweight" and the probability of "underweight":

$$ OR = \frac{P}{1-P} $$

Instructions

100 XP

Use simulation to summarize Harry's posterior density to learn about the odds ratio. (Recall that Harry's posterior for P is beta with parameters 19 and 7.)

  • Define the vector ab, the beta shape parameters for Harry's posterior.
  • Use the rbeta() function to simulate 1000 values from this beta curve. Store the values in p_sim.
  • Compute a vector or_sim of corresponding simulated values of the odds ratio.
  • Construct a histogram of the simulated odds ratios.
  • From the simulated values, compute the probability that the odds ratio is greater than 2.
  • Compute a 90% probability interval for the odds ratio.