01 / 21

Bayes' Theorem
in Diagnostics

Learn how to use prior probability and test accuracy to calculate the true chance a patient has a disease after a positive test result.

Biostatistics

Why a Positive Test Doesn't Mean You're Sick

Imagine a disease affects 1 in 1,000 people. A screening test is 99% accurate. You test positive: what's the chance you actually have the disease?

Key Vocabulary

Prevalence
The proportion of the population that actually has the disease: \( P(D) \)
Sensitivity
Probability the test is positive given the patient is sick: \( P(+\mid D) \)
Specificity
Probability the test is negative given the patient is healthy: \( P(-\mid D^c) \)

The Four Outcomes of a Test

Reality Has Disease (D)
No Disease \(D^c\)
Test Result
\(+\)
\(-\)
True Positive
Sick & test says \(+\)
False Positive
Healthy & test says \(+\)
False Negative
Sick & test says \(-\)
True Negative
Healthy & test says \(-\)
The confusion matrix for diagnostic testing

Sensitivity vs Specificity

Sensitivity
$$ P(+\mid D) = \frac{\text{TP}}{\text{TP} + \text{FN}} $$
Of all sick people, how many test positive? High sensitivity: few false negatives.
Specificity
$$ P(-\mid D^c) = \frac{\text{TN}}{\text{TN} + \text{FP}} $$
Of all healthy people, how many test negative? High specificity: few false positives.

Bayes' Theorem: The Formula

\( P(D) \)
Prior: prevalence of the disease before testing
\( P(+\mid D) \)
Likelihood: sensitivity of the test
\( P(D\mid +) \)
Posterior: updated probability after positive test

Visualizing with a Probability Tree

Pop.
\(P(D)\)
D
\(P(D^c)\)
\(D^c\)
\(P(+\mid D)\)
TP
\(P(-\mid D)\)
FN
\(P(+\mid D^c)\)
FP
\(P(-\mid D^c)\)
TN ★ ★
\(P(D\mid+)\)
\(=\frac{TP}{TP+FP}\)

PPV vs NPV: Key Distinction

Positive Predictive Value Negative Predictive Value
Question If test is \(+\), is patient sick? If test is \(-\), is patient healthy?
Formula \( \frac{\text{TP}}{\text{TP}+\text{FP}} \) \( \frac{\text{TN}}{\text{TN}+\text{FN}} \)
Depends on Sensitivity + Prevalence Specificity + Prevalence
As prevalence ↓ PPV drops sharply NPV stays high

How to Apply Bayes' Theorem

1
Identify the prior: What is the disease prevalence \( P(D) \)?
2
Find the test properties: What are the sensitivity \( P(+\mid D) \) and specificity \( P(-\mid D^c) \)?
3
Calculate the false positive rate: \( P(+\mid D^c) = 1 - \text{specificity} \)
4
Plug into Bayes' formula and compute \( P(D\mid +) \).
5
Interpret: State the result as a percentage and compare to the prior.

Worked Example: Rare Disease Screening

Given: A disease affects 1 in 1,000 people. A test has 99% sensitivity and 99% specificity. A patient tests positive. What is \( P(D\mid +) \)?

Same Problem Using Natural Frequencies

100,000 people 100 sick 99,900 healthy 99 TP
test \(+\)
1 FN
test \(-\)
999 FP
test \(+\)
98,901 TN
test \(-\)
PPV = \( \frac{99}{99 + 999} = \frac{99}{1098} \approx \) 9.0%

Example 2: Higher Prevalence

Given: A flu test with 95% sensitivity and 90% specificity is used during flu season when 20% of patients have the flu. What is \( P(\text{Flu}\mid +) \)?

Example 3: Two-Step Testing

Scenario: After the first positive (from Example 1), the patient takes a second independent test with the same 99% sensitivity and 99% specificity. The new prior is now 9%.

How Prevalence Shapes PPV

0% 25% 50% 75% 100% 0% 10% 20% 30% 40% 50% Prevalence PPV Sens=99%, Spec=99% Sens=95%, Spec=90% 50%

Common Mistakes

✕ Base Rate Neglect
Ignoring the prevalence \( P(D) \) and assuming a positive test means near-certain disease. Always start with the base rate.
✕ Swapping Conditionals
Confusing \( P(D\mid +) \) with \( P(+\mid D) \). Sensitivity tells you about sick people; PPV tells you about positive results.
✕ Forgetting the Complement
Using specificity directly instead of computing the false positive rate: \( P(+\mid D^c) = 1 - \text{specificity} \).

Summary of Key Formulas

Concept Formula Meaning
Bayes' Theorem \( \frac{P(+\mid D) \cdot P(D)}{P(+)} \) Update belief after data
Sensitivity \( P(+\mid D) \) True positive rate
Specificity \( P(-\mid D^c) \) True negative rate
FPR \( 1 - \text{Specificity} \) False positive rate
PPV \( P(D\mid +) \) Chance of disease if \(+\)
NPV \( P(D^c\mid -) \) Chance of health if \(-\)

Question 1 of 5

A disease has 5% prevalence. A test has 90% sensitivity and 90% specificity. What is \( P(D\mid +) \)?

Question 2 of 5

Which of the following increases the positive predictive value (PPV) of a test?

Question 3 of 5

A test has 99% sensitivity and 95% specificity. In a population where 2% have the disease, about how many of the positive results are false positives?

Question 4 of 5

A student writes: "The test is 95% accurate, so if I test positive, there's a 95% chance I have the disease." What error is the student making?

Question 5 of 5

After one positive test, a patient's probability of disease rises from 0.1% to 9%. They take the same test again and it's positive. Using Bayes' theorem with the updated prior of 9%, the new \( P(D\mid ++) \) is approximately: