Checkpoint 1: When Is a Positive Really Positive?
Due 10/18 (12 points). See Project Central for the full project overview. Make sure you have addressed any feedback from Checkpoint 0.
Goal
Use conditional probability and Bayes’ rule to answer: If someone served by my public health program gets a positive result, how likely is it that they truly have the condition?
Course topics used: events, conditional probability, the Law of Total Probability, Bayes’ rule, independence.
Your scenario
Use the input values from your Checkpoint 0 table, with any corrections from my feedback. Every value should come from your source packet or from a course value on your scenario card.
Community breast cancer screening program
- Events: \(D\) = has breast cancer; \(T^+\) = the mammogram is read as abnormal.
- Inputs: prevalence (course value), sensitivity, and specificity from Lee et al. (2023).
- Program question: What does an abnormal read mean for a woman screened on the van?
County COVID-19 testing and contact tracing
- Events: \(D\) = infected with SARS-CoV-2; \(T^+\) = the rapid antigen test is positive.
- Inputs: prevalence (course value), and sensitivity and specificity for people without symptoms from the Cochrane review.
- Program question: How much should a resident without symptoms trust a positive rapid test?
State newborn heart screening program
- Events: \(D\) = has a critical congenital heart defect (CCHD); \(T^+\) = the pulse oximetry screen is positive.
- Inputs: prevalence, sensitivity, and false-positive rate from the Cochrane review. Your false-positive rate is already \(P(T^+ \mid D^c)\), and your specificity is \(1 - (\text{false-positive rate})\).
- Program question: What does a positive screen mean for a newborn’s family?
Tasks
1. Set up the problem
- Copy your events and your three Checkpoint 1 probability statements from Checkpoint 0, with any corrections from my feedback. Keep the source for each value.
- Add the one conditional probability you did not record in Checkpoint 0, using the complement rule:
- Scenarios A and B: the false-positive rate, \(P(T^+ \mid D^c) = 1 - P(T^- \mid D^c)\).
- Scenario C: the specificity, \(P(T^- \mid D^c) = 1 - P(T^+ \mid D^c)\).
- Draw a tree diagram or a 2×2 table for a hypothetical population of 100,000 people screened by your program. Round each count to a whole number of people.
2. Solve analytically
- Use the Law of Total Probability to find \(P(T^+)\).
- Use Bayes’ rule to find the positive predictive value \(P(D \mid T^+)\) and the negative predictive value \(P(D^c \mid T^-)\).
- Show your work. You may use R as a calculator, but write out each formula first.
Lee et al. (2023) report an abnormal interpretation rate of 8.3% and a PPV1 of 6.9% for DBT. Your \(P(T^+)\) and \(P(D \mid T^+)\) should be close to these values. If they are, Bayes’ rule just reproduced numbers from a published study!
3. Simulate it
- Simulate a population of at least 100,000 people in R. Assign each person a disease status, then a test result that depends on their disease status.
- Estimate PPV and NPV from your simulated population and compare them with your analytic answers.
- In 1–2 sentences, explain why the simulated and analytic values are close but not identical.
Where to start: Lesson 4 already has a simulation just like this one. Open the slide Calculate probability with both rules: simulating in R (the mammogram example, Example 6), copy its code into your editing file, and adapt it:
- Replace the three probabilities with your scenario’s values. You need \(P(D)\), \(P(T^+ \mid D)\), and \(P(T^+ \mid D^c)\). For Scenarios A and B, \(P(T^+ \mid D^c)\) is 1 minus your specificity. For Scenario C, it is your false-positive rate.
- Rename the variables so they match your scenario (for example,
infectedinstead ofcancerfor Scenario B). - The lesson code already finds the PPV: it keeps only the positive tests, then finds the proportion with the condition.
- For the NPV, do the opposite: keep only the negative tests, then find the proportion without the condition. In R,
!means “not,” sofilter(!positive)keeps the negative tests andmean(!cancer)is the proportion without cancer.
If your prevalence is very small (Scenario C has about 6 cases per 10,000 babies), a population of 100,000 has only about 60 true cases, so your simulated PPV will bounce around. Try reps <- 1000000 and see whether your simulated values get closer to your analytic answers.
4. Explore: how does prevalence matter?
- Compute the analytic PPV for prevalence values from 0.01% to 50%, keeping sensitivity and specificity fixed.
- Plot PPV (y-axis) against prevalence (x-axis), and mark your scenario’s prevalence on the plot.
- In 2–3 sentences, describe what happens to PPV as prevalence changes. Then describe a group or setting your program might serve where the prevalence would be higher or lower than your scenario’s value (for example, women with a family history of breast cancer, residents tested during a COVID-19 surge, or babies whose prenatal ultrasound showed a possible heart problem). How would a positive result mean something different there?
Why no simulation here? You could simulate a new population for every prevalence value, but that would be thousands of simulations. Since your simulation in Task 3 showed that Bayes’ rule gives the right answer, here we use the formula.
Starter code: copy each chunk into your editing file and fill in each ___.
Step 1: Make a range of prevalence values and find the PPV for each one
- 1
- The same three values you used in Tasks 2 and 3.
- 2
-
seq()makes an evenly spaced sequence of numbers, from 0.0001 (0.01%) to 0.5 (50%), going up by 0.0001 each time. That is 5,000 prevalence values.tibble()puts them in a column calledprev, one row per prevalence value. - 3
-
Write the Bayes’ rule formula for the PPV from Task 2, using
prevwherever you had \(P(D)\). Becauseprevis a column,mutate()computes the PPV for every row (every prevalence value) at once. - 4
-
Print the result to check that it looks right: the PPV should go up as
prevgoes up.
Step 2: Find the PPV at your scenario’s prevalence
1my_ppv <- ___- 1
- Your PPV from Task 2. You can type the number or reuse the object you saved there.
Step 3: Plot it
You do not need to write this code yourself. Run it once your Step 1 and Step 2 code works, then change the title to describe your scenario.
- 1
-
Start a plot using the data
ppv_by_prev.aes()says which columns go on which axis: prevalence on the x-axis and PPV on the y-axis. - 2
- Draw a line connecting the points.
- 3
- Add one point at your scenario’s prevalence and PPV, in orange so it stands out.
- 4
- Put the x-axis on a log scale. All three scenarios have a prevalence below 1%, so on a regular axis your point would be squished against the left edge. On a log scale, each step to the right multiplies the prevalence by 10.
- 5
-
Add a title and axis labels. Replace
___with a short title for your scenario. - 6
- Use a clean background and larger text.
5. Say it
Your program sends a letter or text message to every person with a positive result. Write a short paragraph (4–6 sentences) for that message. Explain what the result means using natural frequencies (e.g., “Out of 1,000 people who get a positive result, about ___ actually have…”) rather than probability notation, and say what the next step is (a follow-up appointment, a confirmatory test, or a heart ultrasound).
Then answer your Checkpoint 1 guiding question from Checkpoint 0 in one sentence.
Submission
Submit a rendered HTML file (use code-fold: true) and your .qmd. Make sure the qmd and html are named lastname_firstinitial_checkpoint_01.qmd and lastname_firstinitial_checkpoint_01.html or lastname1_lastname2_checkpoint_01.qmd and lastname1_lastname2_checkpoint_01.html. One submission per team. Either person in the pair can submit it.
You can download the .qmd editing file for this checkpoint here. The link takes you to GitHub, where you can click the download button (the arrow pointing down) near the top right of the file.
The editing file has the headings and tasks, but not the detailed instructions on this page. Please do not remove anything from the editing file. You will only add your work to it.