# Lecture 24: Sensitivity, Specificity, and Diagnostic Testing

## Statistics / Biostatistics

---

## Learning Objectives

By the end of this lecture, students will be able to:

1. Define and calculate sensitivity, specificity, PPV, and NPV
2. Explain how prevalence affects predictive values
3. Construct and interpret a receiver operating characteristic (ROC) curve
4. Calculate and interpret likelihood ratios
5. Apply diagnostic testing concepts to clinical decision-making

---

## Lecture Content

### I. The 2x2 Table for Diagnostic Testing

All diagnostic test metrics derive from a fundamental 2x2 table:

| | Disease Present (D+) | Disease Absent (D-) |
|---|---|---|
| **Test Positive (T+)** | True Positive (TP) | False Positive (FP) |
| **Test Negative (T-)** | False Negative (FN) | True Negative (TN) |

The gold standard (reference test) defines the true disease status, and all calculations follow from the four cell counts in this table.

### II. Sensitivity and Specificity

**Sensitivity (Sn)** = TP / (TP + FN) = P(T+ | D+). It is the probability that a truly diseased person tests positive, also called the true positive rate (TPR). High sensitivity means few false negatives, making the test good for ruling OUT disease -- remembered by the mnemonic "SnNout" (Sensitivity Negative rules Out).

**Specificity (Sp)** = TN / (TN + FP) = P(T- | D-). It is the probability that a truly non-diseased person tests negative, also called the true negative rate (TNR). High specificity means few false positives, making the test good for ruling IN disease -- remembered as "SpPin" (Specificity Positive rules In).

Sensitivity and specificity are intrinsic properties of the test and do not depend on prevalence. However, there is usually a trade-off: increasing sensitivity decreases specificity and vice versa, because changing the cutoff threshold moves the balance between false negatives and false positives.

### III. Predictive Values

**Positive predictive value (PPV)** = TP / (TP + FP) = P(D+ | T+) is the probability that a person with a positive test truly has the disease. **Negative predictive value (NPV)** = TN / (TN + FN) = P(D- | T-) is the probability that a person with a negative test is truly disease-free.

The critical point is that PPV and NPV depend heavily on disease prevalence. As prevalence increases, PPV increases and NPV decreases. As prevalence decreases, PPV decreases and NPV increases. A test with 99% sensitivity and 99% specificity has a PPV of only 50% when the prevalence is 1%. This is because in a low-prevalence population, the large number of truly healthy individuals generates many false positives that swamp the true positives. Predictive values are what clinicians actually need for individual patient decisions.

<image>A three-panel figure illustrating the effect of prevalence on PPV. All three panels use a test with sensitivity = 95% and specificity = 90%. Panel A: Prevalence = 50% -- PPV = 90.5%. A population icon shows roughly equal disease and non-disease groups, with TP/FP counts labeled. Panel B: Prevalence = 10% -- PPV = 51.4%. The non-disease group is much larger, producing many FPs. Panel C: Prevalence = 1% -- PPV = 8.8%. The FPs vastly outnumber TPs. Each panel shows a natural frequency tree (e.g., out of 10,000 people) to make the numbers intuitive.</image>

### IV. Likelihood Ratios

Likelihood ratios combine sensitivity and specificity into a single metric that updates pre-test probability to post-test probability. The **positive likelihood ratio (LR+)** = Sensitivity / (1 - Specificity) = TPR / FPR tells how much more likely a positive test is in someone with disease versus someone without. An LR+ greater than 10 provides strong evidence to rule in disease, 5-10 provides moderate evidence, 2-5 provides small evidence, and an LR+ of 1 is useless.

The **negative likelihood ratio (LR-)** = (1 - Sensitivity) / Specificity = FNR / TNR tells how much less likely a negative test is in someone with disease. An LR- less than 0.1 provides strong evidence to rule out disease, 0.1-0.2 provides moderate evidence, and an LR- of 1 is useless.

To use likelihood ratios, convert the pre-test probability to pre-test odds (odds = p / (1 - p)), multiply by the likelihood ratio to get post-test odds, and convert back to probability (p = odds / (1 + odds)). Likelihood ratios, like sensitivity and specificity, are independent of prevalence.

### V. ROC Curves

A **Receiver Operating Characteristic (ROC) curve** plots sensitivity (y-axis) against 1-specificity (x-axis) across all possible cutoff values. Each point on the curve represents a different threshold for calling the test positive. A test with no discriminatory ability produces a diagonal line (AUC = 0.5), while a perfect test reaches the upper-left corner (sensitivity = 1, 1-specificity = 0; AUC = 1.0). The closer the curve to the upper-left corner, the better the test.

The **Area Under the Curve (AUC)** is a summary measure of overall diagnostic accuracy. An AUC of 0.5 is no better than chance, 0.7-0.8 is acceptable, 0.8-0.9 is excellent, and an AUC above 0.9 is outstanding. ROC curves can compare two or more diagnostic tests and help select an optimal cutoff based on clinical priorities.

<image>An ROC curve figure. Panel A: A single ROC curve (solid line) with AUC = 0.85 labeled. The diagonal reference line (AUC = 0.5, "chance") is shown as a dashed line. A specific operating point on the curve is highlighted with a dot, labeled with its sensitivity (0.90) and specificity (0.70), representing a clinically chosen cutoff. Panel B: Two ROC curves compared -- Test A (AUC = 0.92) and Test B (AUC = 0.78). Test A clearly dominates. A box shows the p-value for the difference in AUCs (DeLong test).</image>

### VI. Choosing an Optimal Cutoff

The "best" cutoff depends entirely on the clinical context. When **false negatives are costly** (such as screening for a fatal treatable disease), a cutoff with high sensitivity should be chosen, accepting lower specificity -- it is better to over-diagnose than to miss cases. When **false positives are costly** (such as when confirmatory testing is invasive or psychologically harmful), a cutoff with high specificity should be chosen, accepting lower sensitivity.

**Youden's index** (J = Sensitivity + Specificity - 1) is maximized at the "optimal" balance point between sensitivity and specificity. Alternatively, a cost-based analysis can explicitly weigh the costs of false positives, false negatives, true positives, and true negatives to select the cutoff that minimizes total expected cost.

### VII. Multiple Tests: Serial and Parallel Testing

**Serial (sequential) testing** performs a second test only if the first is positive. This approach increases overall specificity and PPV but decreases overall sensitivity. It is used to confirm a positive screening result, such as performing a Western blot after a positive ELISA for HIV.

**Parallel testing** performs both tests simultaneously and considers the result positive if either test is positive. This increases overall sensitivity and NPV but decreases overall specificity. It is used in emergency settings where missing a diagnosis is dangerous.

### VIII. Clinical Application Example

Consider screening for breast cancer with mammography, which has a sensitivity of approximately 85% and a specificity of approximately 90%. In a population with 1% prevalence, the PPV is approximately 7.9% (meaning most positive results are false positives) while the NPV is approximately 99.8% (meaning a negative result is very reassuring). The implication is that positive mammograms require follow-up biopsy, and most biopsies will be negative. Despite the low PPV, the screening is still valuable because it catches cancers early, but patients should be counseled about the high likelihood of false positives.

<image>A natural frequency tree (icon array) for mammography screening. Start with 10,000 women. Branch into 100 with breast cancer (1% prevalence) and 9,900 without. Of the 100 with cancer: 85 test positive (TP), 15 test negative (FN). Of the 9,900 without: 990 test positive (FP), 8,910 test negative (TN). The final positive pool (85 + 990 = 1,075) is highlighted, with PPV = 85/1,075 = 7.9%. An icon array below uses colored dots to visually represent the proportion of true positives among all positives.</image>

---
