Sensitivity & Specificity Calculator
Sensitivity & Specificity Calculator
Work out sensitivity, specificity, PPV, NPV, accuracy and prevalence from a 2×2 table — and see why the first two belong to the test and the next two belong to the population you applied it to.
Sensitivity & Specificity
2×2 table → test performanceA 95% sensitive, 95% specific test applied to 10,000 people of whom 100 have the disease: TP 95, FP 495, FN 5, TN 9,405
The six figures a 2×2 table gives
specificity = TN ÷ (TN + FP)
PPV = TP ÷ (TP + FP) · NPV = TN ÷ (TN + FN)
accuracy = (TP + TN) ÷ total · prevalence = (TP + FN) ÷ total
- sensitivity
- of the people who have the disease, the proportion the test called positive. It is measured down the diseased column, so it cannot be affected by how many healthy people were tested. It is a property of the test
- specificity
- of the people who do not have the disease, the proportion the test called negative. Measured down the healthy column, and likewise a property of the test
- PPV
- of the people the test called positive, the proportion who actually have the disease. Measured ACROSS the positive row, which mixes the two columns — so it depends on how many people are in each, which is to say on prevalence. It is not a property of the test
- NPV
- of the people the test called negative, the proportion who are actually well. Also measured across a row, also prevalence-dependent, and close to 100% for almost any test in a low-prevalence population — which is why a high NPV is rarely the compliment it sounds like
- accuracy
- the proportion of all results that were correct. It is the least useful number here: in a population with 1% prevalence, a test that calls everybody negative is 99% accurate and completely useless
- prevalence
- the proportion of the tested population with the disease. It appears nowhere in sensitivity or specificity and drives both predictive values
Worked example
A 95% sensitive, 95% specific test applied to 10,000 people of whom 100 have the disease: TP 95, FP 495, FN 5, TN 9,405
Sensitivity = 95 ÷ (95 + 5) = 95.0%
Specificity = 9,405 ÷ (9,405 + 495) = 95.0%
PPV = 95 ÷ (95 + 495) = 95 ÷ 590 = 16.1% — five positives in six are false alarms
NPV = 9,405 ÷ (9,405 + 5) = 99.9%
Accuracy = (95 + 9,405) ÷ 10,000 = 95.0%; prevalence = 100 ÷ 10,000 = 1.0%
Now apply the identical test where 10% have the disease — TP 950, FP 450, FN 50, TN 8,550 — and the PPV rises to 950 ÷ 1,400 = 67.9%. Sensitivity and specificity have not moved by a decimal place
The same 95%/95% test at four prevalences, in 10,000 people
| Prevalence | TP | FP | PPV | NPV |
|---|---|---|---|---|
| 0.1% (10 cases) | 9.5 | 499.5 | 1.9% | 100.0% |
| 1% (100 cases) | 95 | 495 | 16.1% | 99.9% |
| 10% (1,000 cases) | 950 | 450 | 67.9% | 99.4% |
| 50% (5,000 cases) | 4,750 | 250 | 95.0% | 95.0% |
Which figures move with the population and which do not
| Figure | Read along | Changes with prevalence? | What it is |
|---|---|---|---|
| Sensitivity | The diseased column | No | A property of the test |
| Specificity | The healthy column | No | A property of the test |
| PPV | The positive row | Yes, strongly | A property of the test and this population |
| NPV | The negative row | Yes | A property of the test and this population |
| Accuracy | Both diagonals | Yes | Usually the least informative number in the table |
| Likelihood ratios | Derived from the columns | No | The form that combines directly with a pre-test probability |
Why a highly specific test still cries wolf
A 2×2 table has four cells and yields six familiar figures, and the useful thing about it is not the arithmetic but the direction in which each figure is read. Sensitivity and specificity are read down the columns — of the people who have the disease, how many did we catch; of the people who do not, how many did we correctly clear. Because each stays inside one column, neither can be changed by how many people are in the other. They belong to the test, they are what a manufacturer’s evaluation measures, and they travel from one laboratory to another.
The predictive values are read across the rows, and a row contains both columns. Of everyone the test called positive, how many really have the disease? That answer must depend on how many diseased and healthy people were in the room, which is to say on prevalence. PPV and NPV are therefore not properties of the test at all. They are properties of the test applied to one particular population, and quoting them without saying which population is close to meaningless.
The consequence is the one clinicians meet most often and believe least readily. Take a test that is 95% sensitive and 95% specific — respectable by most standards — and screen 10,000 people among whom 100 have the disease. It finds 95 of the 100 cases. It also calls 495 of the 9,900 healthy people positive, because 5% of a large number is a larger number than 95% of a small one. Of 590 positive results, 495 are wrong. The positive predictive value is 16%, and five people in six who are told they have screened positive do not have the disease.
Nothing is broken. Run the identical test where a tenth of people are affected and the PPV rises to 68%; run it where half are affected and it reaches 95%. This is why screening an unselected population is a different undertaking from testing someone who already has symptoms, why screening programmes are built around a second confirmatory test rather than around a better first one, and why the accuracy figure deserves the least attention of the six: at 1% prevalence, a test that simply reports everyone as negative is 99% accurate. If you want a number that belongs to the test and still tells you what one patient’s result means, you want the likelihood ratio.
Frequently asked questions
What is the difference between sensitivity and positive predictive value?
Sensitivity asks: of the people who have the disease, how many did the test find? PPV asks the reverse: of the people the test called positive, how many have the disease? Sensitivity is fixed by the test, while PPV also depends on how common the disease is in the population tested.
Why does a specific test produce so many false positives when screening?
Because specificity applies to a much larger group. At 1% prevalence in 10,000 people, a 95% specific test wrongly flags 5% of the 9,900 healthy people — 495 of them — against only 95 true cases found. Most positives are false, even though the test is behaving exactly as advertised.
Does prevalence change sensitivity or specificity?
No. Both are calculated within a single column of the 2×2 table — sensitivity among the diseased, specificity among the healthy — so the size of the other column cannot affect them. Predictive values and accuracy do change with prevalence, sometimes dramatically.
Is a high negative predictive value good news?
Usually it is arithmetic rather than news. In any low-prevalence population almost everyone is disease-free, so almost everyone called negative is genuinely well and the NPV is near 100% for even a mediocre test. Judge a rule-out test on its sensitivity and its negative likelihood ratio instead.
Why is accuracy a poor summary of a test?
Because it is dominated by whichever group is larger. Where 1% of people have a disease, reporting every result as negative gives 99% accuracy and finds no cases at all. Sensitivity, specificity and the likelihood ratios describe performance in a way that a lopsided population cannot flatter.
Related calculators
References
- Altman DG, Bland JM. Diagnostic tests 1: sensitivity and specificity. BMJ. 1994;308(6943):1552.
- Altman DG, Bland JM. Diagnostic tests 2: predictive values. BMJ. 1994;309(6947):102.
- Deeks JJ, Altman DG. Diagnostic tests 4: likelihood ratios. BMJ. 2004;329(7458):168–169.
Medical Disclaimer: The tools and content provided here are for educational and reference purposes only. They are not intended to substitute for professional medical advice, diagnosis, or treatment. Clinical decisions should always be based on the comprehensive assessment of a qualified healthcare professional.
