Diagnostic tests and measurement
Build the 2x2 table and score the test. Then read predictive values, likelihood ratios and the receiver operating characteristic (ROC) curve.
Sensitivity, specificity and the 2x2 table
For diagnostic test problems, put test result (positive, negative) in the rows and disease status (present, absent) in the columns.
The top row holds the true positives and false positives, abbreviated TP and FP. The bottom row holds the false negatives and true negatives, abbreviated FN and TN. Read the labels before applying a formula, because some sources swap rows and columns.
| Disease present | Disease absent | Row total | |
|---|---|---|---|
| Test positive | True positive (TP) = 160 | False positive (FP) = 80 | 240 |
| Test negative | False negative (FN) = 40 | True negative (TN) = 720 | 760 |
| Column total | 200 | 800 | 1,000 |
- Sensitivity is the proportion of people who truly have the disease whose test is positive: the true-positive rate, TP / (TP + FN).
- The false negative rate is FN / (TP + FN), so sensitivity equals 1 minus the false negative rate.
- Specificity is the proportion of people who truly do not have the disease whose test is negative: the true-negative rate, TN / (TN + FP).
- The false positive rate is FP / (TN + FP), so specificity equals 1 minus the false positive rate.
- Prevalence in the table is everyone with disease divided by everyone tested.
- Accuracy is the proportion of all tested people classified correctly, counting both true positives and true negatives.
| Measure | Formula | Worked value |
|---|---|---|
| Sensitivity | TP / (TP + FN) | 160 / 200 = 80% |
| False negative rate | FN / (TP + FN), and sensitivity = 1 minus this rate | 40 / 200 = 20%, so sensitivity = 1 minus 0.20 = 80% |
| Specificity | TN / (TN + FP) | 720 / 800 = 90% |
| False positive rate | FP / (TN + FP), and specificity = 1 minus this rate | 80 / 800 = 10%, so specificity = 1 minus 0.10 = 90% |
| Accuracy | (TP + TN) / (TP + FP + FN + TN) | (160 + 720) / 1,000 = 88% |
| Prevalence | (TP + FN) / (TP + FP + FN + TN) | 200 / 1,000 = 20% |
When a question gives rates instead of counts, rebuild the table. Sensitivity times the number with disease gives the true positives, and specificity times the number without disease gives the true negatives. The rest of each group are false negatives and false positives.
| Cell | Rule | Work |
|---|---|---|
| True positives (TP) | Sensitivity x number with disease | 0.90 x 300 = 270 |
| False negatives (FN) | Number with disease minus TP | 300 minus 270 = 30 |
| True negatives (TN) | Specificity x number without disease | 0.95 x 700 = 665 |
| False positives (FP) | Number without disease minus TN | 700 minus 665 = 35 |
300 people with disease, 700 without, sensitivity 90%, specificity 95%.
A negative result on a highly sensitive test makes disease unlikely, so it helps rule disease out. A positive result on a highly specific test makes disease likely, so it helps rule disease in.
Predictive values and prevalence
Positive predictive value (PPV) is the chance that a person who tests positive actually has the disease.
Negative predictive value (NPV) is the chance that a person who tests negative is actually free of the disease.
| Disease present | Disease absent | Predictive value, whole row as denominator | |
|---|---|---|---|
| Test positive (top row) | TP | FP | PPV = TP / (TP + FP) |
| Test negative (bottom row) | FN | TN | NPV = TN / (TN + FN) |
Sensitivity and specificity use the columns. Predictive values use the rows.
In the first 2x2 table, PPV = 160 / (160 + 80) = 160 / 240 = 66.7%. NPV = 720 / (720 + 40) = 720 / 760 = 94.7%.
A change in prevalence alone leaves sensitivity and specificity fixed but shifts PPV and NPV.
With sensitivity and specificity held fixed, PPV rises as prevalence rises and falls as prevalence falls. NPV moves the opposite way: it falls as prevalence rises and rises as prevalence falls.
Prevalence in the tested group works as the pretest probability.
Rebuild the counts at each prevalence from the same sensitivity and specificity. At 10% prevalence in 1,000 people, 100 have the disease and 900 do not. With sensitivity and specificity both 90%, TP = 90, FN = 10, TN = 810 and FP = 90. Then PPV = 90 / 180 = 50% and NPV = 810 / 820 = 98.8%.
| Prevalence | TP and FP | TN and FN | PPV | NPV |
|---|---|---|---|---|
| 1% | 9 and 99 | 891 and 1 | 9 / 108 = 8.3% | 891 / 892 = 99.9% |
| 10% | 90 and 90 | 810 and 10 | 90 / 180 = 50% | 810 / 820 = 98.8% |
| 50% | 450 and 50 | 450 and 50 | 450 / 500 = 90% | 450 / 500 = 90% |
Sensitivity and specificity stay fixed in every row. Only the counts are rebuilt.
You can also compute predictive values without a table. Se is sensitivity, Sp is specificity and P is prevalence.
- PPV = Se x P / [Se x P + (1 minus Sp) x (1 minus P)].
- NPV = Sp x (1 minus P) / [Sp x (1 minus P) + (1 minus Se) x P].
At 10% prevalence, PPV = 0.09 / (0.09 + 0.09) = 50%, which matches the rebuilt table.
In real use, sensitivity, specificity and likelihood ratios can also change with disease spectrum, threshold and setting. The prevalence rules above apply when the test, cutoff, case mix and setting stay the same.
Likelihood ratios and posttest probability
A likelihood ratio (LR) compares how likely a given test result is in people with the disease against how likely it is in people without it.
- The positive likelihood ratio is sensitivity divided by the false-positive rate: LR+ = sensitivity / (1 minus specificity).
- The negative likelihood ratio is the false-negative rate divided by specificity: LR- = (1 minus sensitivity) / specificity.
| Ratio | In rates | From sensitivity and specificity | Worked value |
|---|---|---|---|
| LR+ | True-positive rate / false-positive rate | sensitivity / (1 minus specificity) | 0.80 / 0.10 = 8 |
| LR- | False-negative rate / true-negative rate | (1 minus sensitivity) / specificity | 0.20 / 0.90 = 0.22 |
An LR+ above 10 (typical of a highly specific test) gives strong evidence to rule disease in. An LR- below 0.1 (typical of a highly sensitive test) gives strong evidence to rule it out.
LRs come from sensitivity and specificity. When those are unchanged, one LR can be applied at any pretest probability, unlike predictive values. A different spectrum, threshold or setting can alter them.
The pretest probability of disease is the prevalence in the tested population, or a clinician's estimate after history and examination.
Pretest probability must be converted to odds before it is multiplied by an LR.
- Convert to odds: odds = p / (1 minus p).
- Multiply by the LR: posttest odds = pretest odds x LR.
- Convert back: posttest probability = posttest odds / (1 + posttest odds).
| Step | Rule | Pretest 20% | Pretest 50% |
|---|---|---|---|
| 1. Pretest probability | Prevalence or clinical estimate | 20% | 50% |
| 2. Pretest odds | p / (1 minus p) | 0.20 / 0.80 = 0.25 | 0.50 / 0.50 = 1 |
| 3. Posttest odds | Pretest odds x LR | 0.25 x 8 = 2 | 1 x 8 = 8 |
| 4. Posttest probability | Odds / (1 + odds) | 2 / 3 = 66.7% | 8 / 9 = 88.9% |
The 20% pretest column matches the first table, where the prevalence was 20% and the PPV was 160 / 240 = 66.7%.
Cutoffs, the gold standard and ROC curves
Widening the positive group raises sensitivity and lowers specificity, with more false positives and fewer false negatives.
Narrowing the positive group raises specificity and lowers sensitivity, with more false negatives and fewer false positives.
A measure stays the same if no one in its group crosses the cutoff. Sensitivity and false negatives count people with the disease. Specificity and false positives count people without it.
When high values are abnormal, lowering the cutoff widens the positive group and raising it narrows the group.
| Move | Sensitivity | Specificity | False positives | False negatives |
|---|---|---|---|---|
| Widen the positive group (lower the cutoff when high values are abnormal) | Up | Down | More | Fewer |
| Narrow the positive group (raise the cutoff when high values are abnormal) | Down | Up | Fewer | More |
A column stays the same if no one in the group it counts crosses the cutoff. Sensitivity and false negatives count people with the disease. Specificity and false positives count people without it. PPV and NPV are computed from the new counts, not given a direction.
Calculate PPV and NPV from the actual counts, because their direction is not guaranteed. In the first table 200 people have the disease and 800 do not. Suppose a wider cutoff moves 20 people with disease from FN to TP and 80 people without disease from TN to FP. PPV falls from 66.7% to 52.9% and NPV rises from 94.7% to 97.0%. A different widening, moving 30 people with disease from FN to TP and 8 people without disease from TN to FP, raises both PPV and NPV.
| Positive group | Counts (TP, FP, FN, TN) | Sensitivity | Specificity | PPV | NPV |
|---|---|---|---|---|---|
| Original | 160, 80, 40, 720 | 160 / 200 = 80% | 720 / 800 = 90% | 160 / 240 = 66.7% | 720 / 760 = 94.7% |
| Widened | 180, 160, 20, 640 | 180 / 200 = 90% | 640 / 800 = 80% | 180 / 340 = 52.9% | 640 / 660 = 97.0% |
| Widened another way | 190, 88, 10, 712 | 190 / 200 = 95% | 712 / 800 = 89% | 190 / 278 = 68.3% | 712 / 722 = 98.6% |
Predictive values here come from these counts only. Another set of counts needs its own calculation.
When healthy and diseased results overlap and high values are abnormal, a cutoff at the low end of the overlap gives 100% sensitivity. One at the high end gives 100% specificity, and a middle cutoff is the practical compromise.
An ROC curve plots sensitivity (true-positive rate) on the vertical axis against 1 minus specificity (false-positive rate) on the horizontal axis, across all possible cutoffs.
Each point on the curve corresponds to one cutoff value.
An area under the curve (AUC) of 0.5, the diagonal line, means the test cannot discriminate beyond chance. An AUC of 1.0 means a perfect test.
A better test has a larger AUC, with the curve bowing toward the upper left corner.
| Point | 1 minus specificity (horizontal) | Sensitivity (vertical) | Reading |
|---|---|---|---|
| Original cutoff | 80 / 800 = 0.10 | 160 / 200 = 0.80 | One cutoff gives one point |
| Widened positive group | 160 / 800 = 0.20 | 180 / 200 = 0.90 | A different cutoff gives a different point |
| Diagonal line | Equal to the vertical value at every point | Equal to the horizontal value at every point | AUC 0.5: no discrimination beyond chance |
| Upper left corner | 0 | 1.0 | AUC 1.0: a perfect test. A better test bows toward this corner |
A gold standard is the reference test regarded as the most accurate for a condition. Other tests are judged by how well they agree with it.
Accuracy, precision and error
In this section, accuracy (validity) means how close results are to the true value. That is a different sense from the share classified correctly in the 2x2 table. Accurate results are free of systematic error (bias).
Reliability, also called reproducibility, is how consistently a test gives the same result over time and between observers. For board exams, precision means the same thing, and random error reduces it.
- Systematic error lowers accuracy.
- Random error lowers precision.
| Accurate (no systematic error) | Inaccurate (systematic error) | |
|---|---|---|
| Precise (little random error) | Tight cluster on the true value | Tight cluster off target |
| Imprecise (random error) | Scattered around the true value | Scattered and off target |
A test can be precise but inaccurate (tightly clustered but off target) or accurate but imprecise (scattered around the true value).
A scale that always reads 2 kg too high gives a tight cluster that misses the true weight. That is precise but inaccurate.
Higher precision means less scatter, so repeated measurements have a smaller standard deviation. It also increases statistical power.
Last checked by a DO:
Read next
- Bias and confoundingPaidselection, screening, recall, observer bias, confounding
- Statistical inferencePaiderrors, power, p versus alpha, confidence intervals, test choice
- Prevention and population healthPaidprevention levels, DALY and QALY, causes of death, normal aging