Guides  /  diagnostic accuracy

Sensitivity, specificity, PPV and NPV

Four numbers describe how well a test performs, and two of them change depending on who you test. That single fact explains most of the confusion around diagnostic accuracy, including why a 95% accurate test can still be wrong nine times out of ten when it says yes. This guide covers all four measures, likelihood ratios, why overall accuracy misleads, and how to report a diagnostic study.

Sidra Khan Written and reviewed by Sidra Khan, Lead Biostatistician
Updated 26 October 202612 min read
What is the difference between sensitivity, specificity, PPV and NPV?

Sensitivity and specificity describe the test. Sensitivity is the proportion of people with the condition that the test correctly flags; specificity is the proportion without it that the test correctly clears. Positive and negative predictive value describe what a result means for the person in front of you: PPV is the chance someone actually has the condition given a positive result, NPV the chance they are clear given a negative one. The first pair stays roughly constant across populations. The second pair moves with how common the condition is, which is why the same test can be useful in a clinic and useless as a screening tool.

The foundation

The 2 by 2 table

Everything comes from four counts: how the test result compares with the truth, established by a reference standard.

Condition presentCondition absent
Test positiveTrue positive (TP)False positive (FP)
Test negativeFalse negative (FN)True negative (TN)

Read down the columns and you get sensitivity and specificity. Read across the rows and you get the predictive values. That is the whole difference between the two pairs, and it is why they behave differently.

Properties of the test

Sensitivity and specificity

Sensitivity = TP / (TP + FN). Of everyone who has the condition, the share the test catches. A sensitive test rarely misses.

Specificity = TN / (TN + FP). Of everyone without it, the share the test clears. A specific test rarely raises a false alarm.

There is a trade-off between them whenever the test produces a number rather than a yes or no. Lower the threshold and you catch more cases while creating more false alarms. The two move in opposite directions, so a test is never simply "better" without saying at what threshold and for what purpose.

SnNout and SpPin

A highly Snsitive test with a Negative result rules the condition out. A highly Specific test with a Positive result rules it in. Clumsy mnemonics, but they encode the right instinct: use sensitive tests to exclude and specific tests to confirm.

What it means for a patient

PPV, NPV and why they move

PPV = TP / (TP + FP). Given a positive result, the chance the condition is really there.

NPV = TN / (TN + FN). Given a negative result, the chance it really is not.

These are the numbers a patient actually cares about, and they depend on prevalence. The test has not changed; the mix of people being tested has. In a population where almost nobody has the condition, nearly everyone the test flags will be a false alarm, simply because there are so many more well people available to be flagged.

Why this trips up screening programmes

A test validated in a hospital clinic, where perhaps a third of patients have the condition, looks excellent. Deploy it for population screening at a prevalence of one in a hundred and its PPV collapses, without a single property of the test changing. This is the central argument in most debates about whether a screening programme is worth running.

Worked example one

All six measures, calculated by hand

A new test is evaluated against a reference standard in 420 patients. Sixty turn out to have the condition. Here is the table, and then every measure derived from it.

Condition presentCondition absentTotal
Test positiveTP = 54FP = 3690
Test negativeFN = 6TN = 324330
Total60360420

Step 1. Sensitivity

Read down the first column. Of the 60 people who have the condition, 54 tested positive.

sensitivity = 54 / 60 = 0.900, so 90.0%, 95% CI 79.9% to 95.3%.

Note how wide that interval is. Sensitivity rests on only 60 people, because the 360 without the condition contribute nothing to it. A study can have 420 participants and still estimate sensitivity poorly.

Step 2. Specificity

Read down the second column. Of 360 people without the condition, 324 tested negative.

specificity = 324 / 360 = 0.900, so 90.0%, 95% CI 86.5% to 92.7%.

Same point estimate as sensitivity, much tighter interval, because six times as many people inform it.

Step 3. Positive predictive value

Now read across the top row. Of the 90 people the test flagged, 54 really had the condition.

PPV = 54 / 90 = 0.600, so 60.0%, 95% CI 49.7% to 69.5%.

A positive result on a test with 90% sensitivity and 90% specificity is right 60% of the time here. That is not a flaw in the test. It is what those numbers produce at this prevalence.

Step 4. Negative predictive value

Read across the bottom row. Of 330 negatives, 324 were genuinely clear.

NPV = 324 / 330 = 0.982, so 98.2%, 95% CI 96.1% to 99.2%.

Step 5. Likelihood ratios

LR+ = sensitivity / (1 − specificity) = 0.90 / 0.10 = 9.0

LR− = (1 − sensitivity) / specificity = 0.10 / 0.90 = 0.111

A positive result makes the condition nine times more likely than it was. A negative result cuts the odds to about a ninth.

Step 6. Prevalence, accuracy and Youden's J

prevalence = 60 / 420 = 14.3%  ·  accuracy = (54 + 324) / 420 = 90.0%  ·  J = 0.90 + 0.90 − 1 = 0.80

Check it with Bayes

The predictive values can be derived a second way, which is worth doing because it catches arithmetic slips. Pre-test odds are 0.143 / 0.857 = 0.167. Multiply by LR+ of 9.0 to get post-test odds of 1.50. Convert back to a probability: 1.50 / (1 + 1.50) = 0.600. Exactly the PPV the table gave.

Use the Wilson interval rather than the ordinary normal approximation for all of these. Sensitivity and specificity often sit near 90% or above, where the normal approximation produces intervals that extend past 100%.

Worked example two

The same test, a different population

The test above now goes into a screening programme where 2% of those attending have the condition. Nothing about the test changes: sensitivity stays at 90%, specificity at 90%. Only the mix of people changes.

Step 1. Rebuild the table at the new prevalence

Take 10,000 attendees. At 2% prevalence, 200 have the condition and 9,800 do not.

TP = 200 × 0.90 = 180  ·  FN = 20  ·  TN = 9,800 × 0.90 = 8,820  ·  FP = 980

Step 2. Recalculate the predictive values

PPV = 180 / (180 + 980) = 180 / 1,160 = 15.5%

NPV = 8,820 / (8,820 + 20) = 99.8%

Step 3. Translate it into something a clinician would recognise

1,160 people are told their result is positive. 180 of them have the condition. That is 6.4 positive results for every true case, and 980 people sent for further investigation who did not need it.

Clinic, 14% prevalenceScreening, 2% prevalence
Sensitivity90.0%90.0%
Specificity90.0%90.0%
Accuracy90.0%90.0%
PPV60.0%15.5%
NPV98.2%99.8%

The first three rows are identical. The fourth has fallen by three quarters. Any paper quoting sensitivity, specificity and accuracy alone would describe these two situations with the same numbers.

The useful ones

Likelihood ratios

Likelihood ratios solve the problem that predictive values are population-specific while sensitivity and specificity do not tell you what a result means.

LR+ = sensitivity / (1 − specificity). How much more likely a positive result is in someone with the condition than someone without.

LR− = (1 − sensitivity) / specificity. The same for a negative result.

They are properties of the test, so they travel between populations, and they combine with prevalence through Bayes' rule: pre-test odds multiplied by the likelihood ratio gives post-test odds. For the test above, LR+ is 9.5 and LR− is 0.056. At 1% prevalence the pre-test odds are 0.0101, so the post-test odds after a positive are 0.096, which is a probability of 8.8%. Exactly the figure the 2 by 2 table gave.

LR+Practical meaning
Above 10Large and often conclusive shift towards the condition
5 to 10Moderate shift
2 to 5Small shift
1 to 2Barely changes anything
1The result carries no information at all

A trap

Why overall accuracy misleads

Accuracy is (TP + TN) / total, and it is the most quoted and least useful figure in diagnostics.

Consider a condition affecting 1% of people and a "test" that always returns negative. It never catches a single case. Its sensitivity is zero. Its accuracy is 99%, and it would beat most real tests on that measure alone.

This is the same problem that makes accuracy a poor measure for any classifier on imbalanced data. Report sensitivity and specificity with confidence intervals, give predictive values alongside the prevalence they assume, and treat a headline accuracy figure as a warning sign rather than a result.

Decisions

Choosing the threshold

When a test yields a continuous measurement, the cut-off is a choice, and an ROC curve shows every option at once. It and it should follow from consequences rather than from whatever maximises a statistic.

✓If missing a case is dangerous and a false alarm merely means another test, favour sensitivity.
✓If a positive result triggers something invasive, costly or frightening, favour specificity.
✓Youden's J, sensitivity plus specificity minus one, picks the point furthest from chance. It weights both errors equally, which is rarely what the clinical situation does.
✓Decide the threshold before you see the outcome data. Choosing the cut-off that produces the best result is a well-known way to overstate performance.

Doing it

In R, SPSS and Stata

R

The epiR package produces everything above from a 2 by 2 matrix, with exact confidence intervals, in one call. Enter the counts in the order TP, FP, FN, TN, filling the matrix by row.

library(epiR)
tab <- matrix(c(54, 36, 6, 324), nrow = 2, byrow = TRUE)
epi.tests(tab, conf.level = 0.95)

This returns sensitivity, specificity, both predictive values, both likelihood ratios, prevalence and accuracy, each with an interval. For a model rather than a fixed test, pROC::roc() gives the curve and pROC::coords() the measures at any threshold.

SPSS

SPSS has no single diagnostic accuracy command, so build the table and derive the measures from it.

CROSSTABS TABLES = testresult BY goldstandard
  /CELLS = COUNT
  /STATISTICS = CHISQ.

For a continuous score use ROC VARIABLES = score BY outcome (1) /PLOT = CURVE /PRINT = COORDINATES SE. The coordinate table lists sensitivity and one minus specificity at every cut-off, so specificity is one minus the column shown. Predictive values are not produced and must be calculated from the counts.

Stata

The user-written diagt command is the usual route and gives the full set directly.

ssc install diagt
diagt goldstandard testresult

For immediate counts without a dataset, diagti 54 36 6 324 takes the four cells in the same order. For a continuous score, roctab outcome score, detail gives the curve and the coordinates.

Check the cell order before you trust the output

Every package expects the four counts in its own order, and getting it wrong silently swaps sensitivity with specificity or with PPV. The numbers still look plausible, which is what makes it dangerous. Verify one measure by hand against the raw table before reporting anything.

Avoid these

Six mistakes that cost marks

MistakeWhy it matters
Quoting PPV without prevalenceThe number is meaningless without it, and it will not transfer to any other setting. This is the single most common reporting failure in diagnostic studies.
Leading with accuracyDominated by whichever group is larger. With a rare condition a test that finds nothing still scores well.
Confusing sensitivity with PPV"The test is 90% accurate at detecting it" could mean either. They were 90% and 60% in the example above, and they answer different questions.
Normal-approximation intervalsAt values near 90% and above they can extend past 100%. Use Wilson or an exact method.
Choosing the threshold from the same dataPerformance at a cut-off picked to maximise it will not reproduce elsewhere. Pre-specify, or validate separately.
Ignoring indeterminate resultsTests that fail or return an unclear result are quietly excluded, which flatters every measure. Report them as their own category.

Validity

Bias in diagnostic studies

Accuracy estimates are often too optimistic, and usually for one of four reasons.

ProblemWhat happens
Spectrum biasComparing obviously ill patients with obviously healthy controls. Performance looks far better than it will in the borderline cases where a test is actually needed.
Verification biasOnly test-positive patients go on to the reference standard, so false negatives are never discovered and sensitivity is inflated.
Imperfect reference standardIf the comparator is itself fallible, the new test is judged against the wrong truth and can be penalised for being right.
Unblinded interpretationWhoever reads the index test knows the reference result, or the reverse. Both inflate agreement.

The first two matter most and are the easiest to spot in a paper. A study with no borderline patients in it is describing a situation where nobody would have ordered the test.

Writing it up

How to report it

✓Give the full 2 by 2 table, not only the derived percentages.
✓Report sensitivity and specificity with 95% confidence intervals, using an interval that behaves near 0% and 100%.
✓State the prevalence in your sample, and say plainly that your PPV and NPV apply only at that prevalence.
✓Give likelihood ratios, so readers can apply the test in their own setting.
✓Describe the reference standard, who was blinded, and how patients were selected.
✓Say whether the threshold was prespecified or chosen from these data.

STARD is the reporting standard for diagnostic accuracy studies and most journals expect it, in the same way STROBE is expected for observational work. If the analysis is already drafted and you want it checked before submission, that is what an independent statistical review covers.

Common questions

Frequently asked questions

What is positive predictive value?

The probability that someone genuinely has the condition given that the test came back positive, calculated as true positives divided by all positives. Unlike sensitivity and specificity it depends on how common the condition is in the group being tested, so the same test has a different PPV in a screening programme than in a specialist clinic.

What is the difference between sensitivity and specificity?

Sensitivity is the proportion of people with the condition that the test correctly identifies, so it measures how well the test avoids missing cases. Specificity is the proportion without the condition that the test correctly clears, so it measures how well the test avoids false alarms. Lowering the threshold raises one and lowers the other.

Why does PPV change between populations?

Because it depends on how many cases are available to find relative to how many well people are available to misclassify. At low prevalence the well group is so much larger that false positives outnumber true ones even for a very specific test, so PPV falls while sensitivity and specificity stay the same.

Can a 95% accurate test be wrong most of the time?

Yes, when it says positive and the condition is rare. A test with 95% sensitivity and 90% specificity applied at 1% prevalence produces about 95 true positives against 990 false ones, so a positive result is correct under 9% of the time. Overall accuracy still reads 90%, which is exactly why accuracy should not be quoted on its own.

What is a good likelihood ratio?

An LR+ above 10 produces a large shift in probability towards the condition and an LR− below 0.1 a large shift away. Values between 1 and 2 barely change anything, and an LR of exactly 1 means the result carries no information. Because likelihood ratios are properties of the test rather than the population, they transfer between settings in a way predictive values do not.

Should I report accuracy?

Only alongside the rest, never alone. Accuracy is dominated by whichever group is larger, so with a rare condition a test that finds nothing can still score highly. Report sensitivity and specificity with confidence intervals, predictive values with the prevalence they assume, and likelihood ratios.