Diagnostic Test Calculator
The performance of a diagnostic test or a classification model cannot be captured by a single number. Sensitivity shows its power to catch the affected, specificity its power to correctly clear the unaffected, and the predictive values (PPV/NPV) show how confident a clinician looking at a test result can actually be. These measures are not interchangeable and must be reported separately.
From the 2×2 confusion matrix you build against a gold standard, this calculator computes sensitivity, specificity, PPV, NPV, accuracy, the F1 score, the positive and negative likelihood ratios, the diagnostic odds ratio, and the Youden J index, each with a Wilson score confidence interval. If you enter the true prevalence in the population, it recomputes the PPV and NPV with Bayes' rule and shows them next to the sample values, so you can see in numbers why the PPV collapses for rare diseases.
Diagnostic Test Performance Formulas
Confusion matrix: [TP FP; FN TN], N = TP + FP + FN + TN Sensitivity: Se = TP / (TP + FN) Specificity: Sp = TN / (TN + FP) PPV (sample): TP / (TP + FP) NPV: TN / (TN + FN) PPV (Bayes): (Se·π) / (Se·π + (1 − Sp)(1 − π)) NPV (Bayes): (Sp·(1 − π)) / (Sp·(1 − π) + (1 − Se)·π) Accuracy: (TP + TN) / N F1 score: 2·TP / (2·TP + FP + FN) LR+: Se / (1 − Sp) LR−: (1 − Se) / Sp Diagnostic odds ratio: (TP·TN) / (FP·FN) = LR+ / LR− Youden J: Se + Sp − 1 Wilson interval: (p̂ + z²/2n) / (1 + z²/n) ± z/(1 + z²/n) · √(p̂(1−p̂)/n + z²/4n²)
The confidence intervals for the proportions come from the Wilson score method, which is markedly more reliable than the Wald interval in small samples and for proportions near 0 or 1, and never crosses the [0, 1] bounds. The intervals for the LRs and the DOR are computed with the Wald (Simel/Katz) method on the log scale.
How to Calculate
- Enter the four cells of the 2×2 table you built against the gold standard: TP, FP, FN, and TN.
- Choose the confidence level; every proportion is computed together with its Wilson score interval.
- Read sensitivity and specificity together: high sensitivity matters in screening, high specificity in confirmation.
- If you know the true prevalence in the population, enter it in the prevalence field; the PPV and NPV are then recomputed with Bayes' rule.
- Check the likelihood ratios: LR+ ≥ 10 largely confirms the diagnosis, LR− ≤ 0.1 largely rules it out.
- Study the prevalence-PPV chart; it shows why, for rare diseases, a positive result is most often a false alarm.
Worked Examples
Screening test — at the sample prevalence
In a series of 1,000 people there are 100 affected. Sensitivity is 90.00% (95% CI: 82.56% – 94.48%), specificity is 96.67% (95% CI: 95.28% – 97.66%), the PPV is 75.00%, and the NPV is 98.86%. Accuracy is 96.00%, the Youden J index is 0.8667, LR+ = 27.000, and LR− = 0.1034; the diagnostic odds ratio is 261.00.
Sensitivity: 90.00% · Specificity: 96.67% · Positive predictive value (PPV): 75.00%
The same test in a population with 1% prevalence
Sensitivity and specificity do not change, because they are properties of the test itself. But once the prevalence drops to 1%, the Bayes-adjusted PPV falls to 21.43%: only about one in five people with a positive result truly has the condition. The NPV rises to 99.90%; for rare diseases a negative result is highly dependable, while a positive result needs confirmation.
Sensitivity: 90.00% · Specificity: 96.67% · Positive predictive value (PPV): 75.00%
A test with poor discriminating power
In a series of 140 people, sensitivity is 66.67% and specificity is 56.25%. With a Youden J index of only 0.2292, LR+ = 1.524, and LR− = 0.5926, the test adds no meaningful information to the diagnosis. Accuracy may look like 60.71%, but the diagnostic odds ratio of 2.57 is weak; no clinical decision can be made on these values.
Sensitivity: 66.67% · Specificity: 56.25% · Positive predictive value (PPV): 53.33%