Session Ready
Exercise

Bayesian updating

Suppose Rebekah is using a beta density with shape parameters 8.13 and 3.67 to reflect her current knowledge about P (the proportion of college women who think they are overweight). In a sample survey, 16 out of 20 students surveyed think they are overweight.

Here our definition of a "success" is thinking one is overweight, so we observe 16 successes and 4 failures.

The posterior density for P will make a beta curve with new parameters \(8.13 + 16 = 24.13\) and \(3.67 + 4 = 7.67\). The graph on the right displays the prior (blue) and posterior (red) curves.

Instructions
100 XP

Harry has a different prior for P. His beliefs are represented by a beta curve with parameters 3 and 3. His best guess at P is 0.5 and he is relatively unsure about this guess.

  • Define a vector ab containing the shape parameters for Harry's prior.
  • Define a vector sf containing the observed successes and failures.
  • Compute the vector ab_new of shape parameters for Harry's beta posterior.
  • Use the function beta_draw() to draw Harry's posterior beta curve.