The 2×2 table
Every calculation starts from a 2×2 table that compares the test result with the true state, as established by a reference standard:
- True positives (TP): ill and test positive, 90 in the example
- False negatives (FN): ill but test negative, 10
- False positives (FP): healthy but test positive, 95
- True negatives (TN): healthy and test negative, 1,805
Put the true state in the columns and the test result in the rows, and add totals on both sides. Most errors in these calculations come from dividing by the wrong total, so label the table clearly.
Sensitivity and specificity
Sensitivity divides by the column of people with the disease: 90 ÷ (90 + 10) = 90%. The test misses 10% of cases. Specificity divides by the column of people without it: 1,805 ÷ (1,805 + 95) = 95%, so 5% of healthy people get a false alarm.
A highly sensitive test is good for ruling a disease out: a negative result is reassuring because few cases are missed. A highly specific test is good for ruling it in. The positive likelihood ratio combines both, sensitivity ÷ (1 − specificity) = 0.90 ÷ 0.05 = 18: a positive result is 18 times more likely in someone with the disease than in someone without.
Worked example: a screening test in 2,000 people
The four cells of the 2×2 table and the screening prevalence in D13 are yellow inputs. Totals, sensitivity, specificity, predictive values and the PPV at another prevalence are formulas.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | 2×2 table | Disease present | Disease absent | Total |
| 2 | Test positive | 90 | 95 | 185 |
| 3 | Test negative | 10 | 1,805 | 1,815 |
| 4 | Total | 100 | 1,900 | 2,000 |
| 5 | ||||
| 6 | Sensitivity = TP ÷ (TP + FN) | 90.0% | ||
| 7 | Specificity = TN ÷ (TN + FP) | 95.0% | ||
| 8 | Positive predictive value (PPV) = TP ÷ all positives | 48.6% | ||
| 9 | Negative predictive value (NPV) = TN ÷ all negatives | 99.4% | ||
| 10 | Prevalence in this group | 5.0% | ||
| 11 | Accuracy = (TP + TN) ÷ total | 94.8% | ||
| 12 | Positive likelihood ratio = sensitivity ÷ (1 − specificity) | 18.00 | ||
| 13 | Prevalence in a screening population | 1.0% | ||
| 14 | PPV at that prevalence (Bayes) | 15.4% | ||
- D6
=B2/B4Sensitivity - D7
=C3/C4Specificity - D8
=B2/D2Positive predictive value - D9
=C3/D3Negative predictive value - D12
=D6/(1-D7)Positive likelihood ratio - D14
=D6*D13/(D6*D13+(1-D7)*(1-D13))PPV at a different prevalence
Invented counts for teaching. Real test evaluations report confidence intervals and the reference standard used. Not medical advice.
PPV and NPV
The predictive values divide by the rows, the test results. PPV = TP ÷ all positives = 90 ÷ 185 = 48.6%: fewer than half of the positives are true. NPV = TN ÷ all negatives = 1,805 ÷ 1,815 = 99.4%.
The PPV is low here although the test looks good, because the 5% false-positive rate applies to the large healthy group (1,900 people) and produces 95 false alarms, more than the 90 true cases.
Why prevalence changes everything
Sensitivity and specificity are properties of the test and stay the same across groups. PPV and NPV are not: they depend on the prevalence. With Bayes' theorem, PPV = Se × p ÷ (Se × p + (1 − Sp) × (1 − p)). In Excel, with sensitivity in D6, specificity in D7 and prevalence in D13: =D6*D13/(D6*D13+(1-D7)*(1-D13)).
For the same test: at 20% prevalence the PPV is 81.8%, at 5% it is 48.6%, at 1% it is 15.4% and at 0.1% only 1.8%. That is why screening the general population for a rare condition produces mostly false positives, and why a positive screening result is usually followed by a more specific confirmatory test.
Accuracy is a poor summary
Accuracy, (TP + TN) ÷ total, is 94.75% in the example, which sounds excellent. But a "test" that calls everyone healthy would reach 95% accuracy at 5% prevalence while finding no cases at all. For diagnostic tests, report sensitivity and specificity together, plus PPV and NPV for the population in question, ideally with confidence intervals when the counts are small.
Common mistakes
- Dividing by the wrong total. Sensitivity and specificity divide by the true state (columns), PPV and NPV by the test result (rows).
- Reading sensitivity as the chance of being ill after a positive test. That is the PPV, and it can be much lower.
- Carrying PPV over to another population. PPV and NPV depend on prevalence. Recalculate them for the group being tested.
- Judging a test by accuracy. With a rare disease, a useless test can still be over 95% accurate.
- Swapping false positives and false negatives. A false negative is an ill person the test missed.
- Ignoring small numbers. With 10 cases, 90% sensitivity has a wide confidence interval.
Frequently asked questions
How do you calculate sensitivity and specificity?
Sensitivity = true positives ÷ (true positives + false negatives). Specificity = true negatives ÷ (true negatives + false positives). Both come from a 2×2 table of test result against true disease status.
What is the difference between sensitivity and PPV?
Sensitivity is the share of ill people who test positive. PPV is the share of positive tests that belong to ill people. Sensitivity describes the test, PPV also depends on how common the disease is.
Why does a low prevalence lower the PPV?
With few ill people, even a small false-positive rate applied to the large healthy group creates many false alarms, which can outnumber the true positives.
How do you calculate PPV from sensitivity, specificity and prevalence?
PPV = sensitivity × prevalence ÷ (sensitivity × prevalence + (1 − specificity) × (1 − prevalence)). With 90% sensitivity, 95% specificity and 1% prevalence, PPV = 15.4%.