Diagnostic tests and measurement

9 min read.

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.

The diagnostic 2x2 table
Disease presentDisease absentRow total
Test positiveTrue positive (TP) = 160False positive (FP) = 80240
Test negativeFalse negative (FN) = 40True negative (TN) = 720760
Column total2008001,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.
Diagnostic measures worked with TP 160, FP 80, FN 40 and TN 720
MeasureFormulaWorked value
SensitivityTP / (TP + FN)160 / 200 = 80%
False negative rateFN / (TP + FN), and sensitivity = 1 minus this rate40 / 200 = 20%, so sensitivity = 1 minus 0.20 = 80%
SpecificityTN / (TN + FP)720 / 800 = 90%
False positive rateFP / (TN + FP), and specificity = 1 minus this rate80 / 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.

Rebuilding the counts from rates
CellRuleWork
True positives (TP)Sensitivity x number with disease0.90 x 300 = 270
False negatives (FN)Number with disease minus TP300 minus 270 = 30
True negatives (TN)Specificity x number without disease0.95 x 700 = 665
False positives (FP)Number without disease minus TN700 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.

Predictive values read along the rows of the 2x2 table
Disease presentDisease absentPredictive value, whole row as denominator
Test positive (top row)TPFPPPV = TP / (TP + FP)
Test negative (bottom row)FNTNNPV = 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%.

One test at 3 prevalences, sensitivity 90% and specificity 90%, 1,000 people each
PrevalenceTP and FPTN and FNPPVNPV
1%9 and 99891 and 19 / 108 = 8.3%891 / 892 = 99.9%
10%90 and 90810 and 1090 / 180 = 50%810 / 820 = 98.8%
50%450 and 50450 and 50450 / 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.
Likelihood ratios for sensitivity 80% and specificity 90%
RatioIn ratesFrom sensitivity and specificityWorked value
LR+True-positive rate / false-positive ratesensitivity / (1 minus specificity)0.80 / 0.10 = 8
LR-False-negative rate / true-negative rate(1 minus sensitivity) / specificity0.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.

  1. Convert to odds: odds = p / (1 minus p).
  2. Multiply by the LR: posttest odds = pretest odds x LR.
  3. Convert back: posttest probability = posttest odds / (1 + posttest odds).
Pretest to posttest probability after a positive result (LR+ = 8)
StepRulePretest 20%Pretest 50%
1. Pretest probabilityPrevalence or clinical estimate20%50%
2. Pretest oddsp / (1 minus p)0.20 / 0.80 = 0.250.50 / 0.50 = 1
3. Posttest oddsPretest odds x LR0.25 x 8 = 21 x 8 = 8
4. Posttest probabilityOdds / (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.

What moving the cutoff does
MoveSensitivitySpecificityFalse positivesFalse negatives
Widen the positive group (lower the cutoff when high values are abnormal)UpDownMoreFewer
Narrow the positive group (raise the cutoff when high values are abnormal)DownUpFewerMore

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.

Cutoff moves worked from counts, 200 with disease and 800 without
Positive groupCounts (TP, FP, FN, TN)SensitivitySpecificityPPVNPV
Original160, 80, 40, 720160 / 200 = 80%720 / 800 = 90%160 / 240 = 66.7%720 / 760 = 94.7%
Widened180, 160, 20, 640180 / 200 = 90%640 / 800 = 80%180 / 340 = 52.9%640 / 660 = 97.0%
Widened another way190, 88, 10, 712190 / 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.

One ROC point per cutoff
Point1 minus specificity (horizontal)Sensitivity (vertical)Reading
Original cutoff80 / 800 = 0.10160 / 200 = 0.80One cutoff gives one point
Widened positive group160 / 800 = 0.20180 / 200 = 0.90A different cutoff gives a different point
Diagonal lineEqual to the vertical value at every pointEqual to the horizontal value at every pointAUC 0.5: no discrimination beyond chance
Upper left corner01.0AUC 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.
The target grid for accuracy and precision
Accurate (no systematic error)Inaccurate (systematic error)
Precise (little random error)Tight cluster on the true valueTight cluster off target
Imprecise (random error)Scattered around the true valueScattered 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