30 Assignment 6

Due 11:59pm Sunday, March 1

The purpose of this assignment is to explore and reinforce concepts in Chapters 4 & 6, as well as selected topics from Chapters 10 & 23 of Bringing Bayesian Models to Life.

You may complete this assignment with a partner (i.e., max group size of 2 people). If you chose to work with a partner you only need to submit one assignment, but please make sure both of your names are on it. You may participate in a learning group of any size to complete the assignment, but please submit your own work.

Make sure to show all of your work and computer code, so that your mathematical and numerical results are easily reproducible. In the most basic sense, this is equivalent to “showing your work” as you would with pencil and paper in a mathematics course.

Please save the file as a pdf and name it Yourlastname_Assignment6. Upload this file to Canvas.

In class we built a hierarchical Bayesian model for the rabies test results. For this model, we assumed the following “data model” for the two rabies test results (rapid and PCR):

\[[y_{ij}|z_i,a_j]=\begin{cases} 0 & \text{if} & z_i=0 \\ \text{Bern(}a_j) & \text{if} & z_i=1 \end{cases},\] where \(y_{ij}\) is the \(i^\text{th}\) individual (persons) test result for the \(j^\text{th}\) test. The \(z_i\) is the true rabies status for the \(i^\text{th}\) individual. The \(a_j\) is the true positive rate for the \(j^\text{th}\) test type (i.e., the probability the test returns a rabies positive results if the bat has rabies). In this model \(i=1,2,...n\) and \(j=1,2,...J\). Remember, that in class we found out the data for my test results was \(y_{1,1}=0\) and \(y_{1,2}=0\) where \(j=1\) was the rapid test and \(j=2\) was the PCR test.

Because the no rabies test is 100% accurate, the \(z_i\) is a unobservable random variable. These are also known as “latent” or “hidden states” in the hierarchical modeling literature. In our example, we assume the following “process model”

\[[z_i|p]=\text{Bern}(p)\] where \(p\) is the probability the \(i^\text{th}\) bat has rabies (also known as the prevalence rate in the disease modelling literature).

To fully specify a Bayesian model, we have to assume models for all unknowns. Typically these are called parameters and we assume prior distributions for these. For \(p\) we assumed \([p]=\text{Beta}(\alpha_p,\beta_p)\) with \(\alpha_p=1\) and \(\beta_p=100\). For \(a_1\), which is the true positive rate for the rapid test assume \([a_1]=\text{Beta}(\alpha_{a_1},\beta_{a_1})\) with \(\alpha_{a_1}\)=80 and \(\beta_{a_1}=20\). For \(a_2\), which is the true positive rate for the PCR test assume \([a_2]=\text{Beta}(\alpha_{a_2},\beta_{a_2})\) with \(\alpha_{a_2}\)=200 and \(\beta_{a_1}=2\).

  1. Plot the priors for \(p\), \(a_1\), and \(a_2\). Write 4-5 sentences that comments on the appropriateness of of these priors for the rabies data example. Recall that the manufacture said that rapid test and PCR test had a true positive rate of 0.80 and 0.99 respectively. Remember that priors are just another model assumption. Assumptions are needed to analyze data and make inference (i.e., to infer from the tests if I have rabies or not).Thus I am asking you to evaluate how reasonable a portion of my assumptions are before you analyize the data.

  2. Write out (i.e., with pencil and paper) and sketch of the MCMC algorithm you will use to fit the fit the hierarchical Bayesian model described above to my rabies test results. Remember that fitting the model to my rabies data means that you need to sample from (or find analytically) \([p,z_1,a_1,a_2|y_{1,1},y_{1,2}]\).

  3. Fit the hierarchical Bayesian model to my rabies test results (i.e., \(y_{1,1}=0\) and \(y_{1,2}=0\)). For the MCMC algorithm, make sure to determine the appropriate burn-in interval and number of samples. Make sure to provide the code you used to fit the model.

  4. Using your results from 1, make a histogram representation of the distribution \([z_1|y_{1,1},y_{1,2}]\) This problem uses automatic marginalization (see pg. 541 in BBM2L). Make sure to label the label the axes appropriately.

  5. Using your results from 2, make a histogram representation of the distribution \([p|y_{1,1},y_{1,2}]\) (see pg. 541 in BBM2L). Make sure to label the label the axes appropriately.

  6. Using your results from 2, make a histogram representation of the distribution \([a_1|y_{1,1},y_{1,2}]\) (see pg. 541 in BBM2L). Make sure to label the label the axes appropriately.

  7. Using your results from 2, make a histogram representation of the distribution \([a_2|y_{1,1},y_{1,2}]\) (see pg. 541 in BBM2L). Make sure to label the label the axes appropriately.

  8. Using words and numerical results (e.g., approximations of \(E(z_1|y_{1,1},y_{1,2})\) and \(E(p|y_{1,1},y_{1,2})\)), write 5-7 sentences that summarizes the results and inferences you can make using the hierarchical Bayesian model that was fit to my rabies data.