Diagnostic test bench: sensitivity, specificity and predictive values

NAVLEBCSESet prevalence, sensitivity and specificity and watch a herd of 1,000 animals sort into true and false results. See why predictive values change with prevalence, and compare testing in series and in parallel.

The herd: 1,000 animals, one dot each

Click a color group (a dot, a button above, or a cell in the 2×2 table) to see what that group means and which formula it feeds.

Set the disease and the test

Share of the herd that truly has the disease (0.1% to 90%).
Share of diseased animals that test positive.
Share of healthy animals that test negative.
Herd size
Group the dots by
Diseased animals first (red, amber), then healthy.

Counts are rounded to whole animals. Percentages use the exact formulas, so they can differ slightly from the rounded counts in very small groups.

Move the cut-off: trade sensitivity for specificity

Most tests give a number (a titer, an optical density, a skin thickness). Healthy and diseased animals overlap, so someone must pick a cut-off. Here a result at or above the cut-off is called positive. Simplified model: two bell-shaped curves with equal spread.

HealthyDiseasedFalse positivesFalse negatives
ROC curve: every cut-off is one point. Area under the curve (AUC) 0.92; 0.5 is a coin toss, 1.0 is a perfect test.
Lower it: more animals test positive. Raise it: fewer do.
Overlap of the two groups
Sensitivity0%
Specificity0%

Sends the cut-off's sensitivity and specificity to test A (kept within the 50 to 100% slider range).

Two tests: in series or in parallel

Series: the animal is called positive only if both tests are positive (in practice, only the positives on test A are retested with test B). Parallel: the animal is called positive if either test is positive.

StrategySeSpPPVNPV
Show in the herd and the 2×2 table

Assumption: the two tests are independent (the error of one tells you nothing about the error of the other, in diseased and in healthy animals). Real tests that measure the same thing, such as two antibody tests, make some of the same mistakes, so the real gain is smaller than shown here.

Live 2×2 table

DiseasedHealthyTotal
Test + 0
Test − 0
Total000
PPV0%
NPV0%
True prev0%
App. prev0%

Predictive values against prevalence

PPV: a positive is truly diseasedNPV: a negative is truly healthy
Accuracy0%
LR+0
LR−0
Se / Sp shown90 / 90%

Apparent prevalence is the share that tests positive (TP + FP). True prevalence is the share that is diseased (TP + FN). LR+ = Se ÷ (1 − Sp); LR− = (1 − Se) ÷ Sp. Prevalence axis is stretched at the low end (log scale).

Pick a problem

Sensitivity, specificity and prevalence values in these problems are illustrative round numbers chosen to show the principle. They are not the published performance of any real test kit.

Starting point

Prevalence 10%, sensitivity 90%, specificity 90%. Move one slider at a time and watch which numbers move. Prevalence changes PPV and NPV but never sensitivity or specificity.

Herd level: will a sample find the disease?

You test n animals from a herd. If the disease is present at prevalence p, the chance that at least one sampled animal tests positive is 1 − (1 − p × Se)n.

Chance of at least 1 positive0%
Sample for 95% confidence0animals
Quick rule: 3 ÷ (p × Se)0animals

Uses the sensitivity of test A (90%). Sample size for 95% confidence: n = ln(0.05) ÷ ln(1 − p × Se), rounded up. This simple formula assumes a large herd (sampling a few animals does not change the prevalence in the rest), a random sample, and perfect specificity (every positive is treated as a true positive). In a small herd, fewer animals are needed than the formula gives.

Numbers and formulas to know

TermFormulaIn words
Sensitivity (Se)TP ÷ (TP + FN)Of the diseased, the share that test positive
Specificity (Sp)TN ÷ (TN + FP)Of the healthy, the share that test negative
Positive predictive value (PPV)TP ÷ (TP + FP)Of the test positives, the share that are diseased
Negative predictive value (NPV)TN ÷ (TN + FN)Of the test negatives, the share that are healthy
PPV from Se, Sp and prevalence pSe·p ÷ [Se·p + (1−Sp)(1−p)]Bayes' theorem; falls as p falls
NPV from Se, Sp and pSp(1−p) ÷ [Sp(1−p) + (1−Se)·p]Rises as p falls
True prevalence(TP + FN) ÷ NShare truly diseased
Apparent prevalence(TP + FP) ÷ NShare that test positive = Se·p + (1−Sp)(1−p)
True from apparent prevalence (AP)(AP + Sp − 1) ÷ (Se + Sp − 1)Rogan-Gladen estimate
Accuracy (of a test)(TP + TN) ÷ NShare of all results that are correct
Likelihood ratio positive (LR+)Se ÷ (1 − Sp)How much a positive raises the odds of disease
Likelihood ratio negative (LR−)(1 − Se) ÷ SpHow much a negative lowers the odds of disease
Post-test oddspre-test odds × LROdds = p ÷ (1 − p)
Series (both positive), independent testsSe = SeA·SeB
Sp = 1 − (1−SpA)(1−SpB)
Sp and PPV rise, Se falls
Parallel (either positive), independent testsSe = 1 − (1−SeA)(1−SeB)
Sp = SpA·SpB
Se and NPV rise, Sp falls
Chance of at least 1 positive in n sampled1 − (1 − p·Se)nHerd-level sensitivity; large herd, perfect Sp
Sample size to detect disease, 95% confidenceln(0.05) ÷ ln(1 − p·Se)About 3 ÷ (p·Se) when p is small
Area under the ROC curve0.5 to 1.00.5 = no better than chance; 1.0 = perfect

Pairs that get mixed up

Accuracy vs precision (of a measurement)

Accurateand precise Precise,not accurate Accurate onaverage only Neither

Accuracy is how close a result is to the true value. Precision is how close repeated results are to each other (repeatability). A badly calibrated analyzer can be precise and wrong every time. In the 2×2 table, "accuracy" has a second meaning: the share of all animals classified correctly.

Incidence vs prevalence

Start of yearEnd of year Survey day

Incidence counts new cases that start during a period, divided by the animals at risk: the 4 blue bars begin inside the year. Prevalence counts all existing cases at one point in time, divided by the population: 3 bars cross the red survey line. Long-lasting diseases build up, so prevalence is roughly incidence × average duration. Predictive values depend on prevalence.

Memory hooks

  • SnNout: with a highly Sensitive test, a Negative rules disease out.
  • SpPin: with a highly Specific test, a Positive rules disease in.
  • Predictive values travel with prevalence. Sensitivity and specificity do not.
  • Rare disease: doubt the positive. Common disease: doubt the negative.
  • Screen with a sensitive test, confirm with a specific test.
  • Series = "and" = more specific. Parallel = "or" = more sensitive.
  • Sensitivity and specificity read down the columns of the 2×2 table (by disease). Predictive values read across the rows (by test result).
  • Lower the cut-off: catch more disease, raise more false alarms. You cannot improve both with the cut-off alone.
  • Rule of three: to find a disease present in a share p of a large herd, sample about 3 ÷ p animals for 95% confidence.

Exam check

For exam study only. Simplified teaching models: do not use these tools to make decisions for real patients. Last reviewed November 2026.

More free tools in the Vet Lab

ECG Rhythm Bench Acid-Base and Blood Gas Interpreter Fluid Plan and CRI Builder Pharmacokinetics Bench
Now test it on exam-style questions.
Practice NAVLE and BCSE questions with full explanations.
Start free trial