Diagnostic Test Statistics Calculator — Sensitivity, Specificity, PPV, NPV & Likelihood Ratios
Enter a 2×2 test table and get sensitivity, specificity, PPV, NPV, positive and negative likelihood ratios, the diagnostic odds ratio and Youden's J — each with its formula and a 95% confidence interval. Then re-project PPV, NPV and post-test probability onto any disease prevalence. Free, no signup, runs in your browser.
How it works
A diagnostic test is scored against a reference (“gold”) standard. Cross-tabulating the two gives four counts: true positives (TP), false positives (FP), false negatives (FN) and true negatives (TN). Every statistic below is a ratio of those cells or of the rates derived from them. Definitions follow Altman & Bland (BMJ 1994) and Deeks & Altman (BMJ 2004).
- Sensitivity = TP / (TP + FN) and specificity = TN / (TN + FP). These describe the test itself and stay fixed no matter how common the disease is.
- PPV = TP / (TP + FP) and NPV = TN / (TN + FN) are the predictive values at the sample's own prevalence. Unlike sensitivity and specificity, they move with prevalence.
- Likelihood ratiossummarise a result's weight of evidence: LR+ = Sens / (1 − Spec) and LR− = (1 − Sens) / Spec. The diagnostic odds ratio = (TP·TN) / (FP·FN) = LR+ / LR−, and Youden's J = Sens + Spec − 1.
- Prevalence adjustmentuses Bayes' theorem to recompute predictive values for any target prevalence p:
PPV(p) = Sens·p / (Sens·p + (1 − Spec)·(1 − p))andNPV(p) = Spec·(1 − p) / (Spec·(1 − p) + (1 − Sens)·p). The post-test probability after a positive result is exactly PPV(p); equivalently, pre-test odds × LR+ converted back to a probability — the Fagan nomogram in algebra. - Confidence intervals. Sensitivity, specificity, PPV and NPV each carry a 95% Wilson score interval on their own denominator (for example, sensitivity uses n = TP + FN). Wilson is used instead of the Wald approximation because it stays inside 0–100% and behaves at the extremes and small samples typical of validation studies (Altman, Statistics with Confidence).
A built-in cross-check proves the two engines agree: projecting PPV with Bayes at the sample's own prevalence reproduces the direct count formula TP / (TP + FP) to machine precision. All arithmetic uses exact double-precision values; only the display is rounded, so chained steps never accumulate rounding drift.
Worked examples
Frequently asked questions
Sources & references
- Altman DG, Bland JM — Diagnostic tests 1: sensitivity and specificity (BMJ 1994;308:1552)
- Deeks JJ, Altman DG — Diagnostic tests 4: likelihood ratios (BMJ 2004;329:168)
- Centre for Evidence-Based Medicine (Oxford) — likelihood ratios & Fagan nomogram
- WHO — Evaluation of diagnostic tests (background on validation study design)
The formulas on this page are textbook-standard and vendor-neutral. They were last reconciled against the cited references on 2026-07-10. If a result ever disagrees with a source you trust, email me the inputs and I will investigate.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.