Diagnostic Test Calculator

StatisticsLast updated: August 22, 2026

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.

The number of people the test correctly identifies as having the condition.
The number of unaffected people the test wrongly flags as having the condition.
The number of affected people the test misses.
The number of people the test correctly identifies as unaffected.
%
If left blank, the PPV and NPV are computed from the sample. If you enter a value, the Bayes-adjusted PPV and NPV are shown as well.
The probability that the interval covers the true parameter.

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

  1. Enter the four cells of the 2×2 table you built against the gold standard: TP, FP, FN, and TN.
  2. Choose the confidence level; every proportion is computed together with its Wilson score interval.
  3. Read sensitivity and specificity together: high sensitivity matters in screening, high specificity in confirmation.
  4. 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.
  5. Check the likelihood ratios: LR+ ≥ 10 largely confirms the diagnosis, LR− ≤ 0.1 largely rules it out.
  6. 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%

Frequently Asked Questions

What is the difference between sensitivity and PPV?
Sensitivity answers the question "among people we know to be affected, how often is the test positive?" and is a property of the test itself. The PPV runs the other way: "the test came back positive, does this person really have the condition?" That second question depends on the prevalence of the disease. The same test can give a PPV of 20% for a rare disease and 90% for a common one.
Why is the PPV so low for rare diseases?
If the prevalence is 1%, then out of 1,000 people 10 are affected and 990 are not. With 90% sensitivity, 9 of the affected are caught; even with 95% specificity, about 50 of the 990 unaffected come out false positive. Of the 59 people with a positive result, only 9 truly have the condition, so the PPV is around 15%. This "base rate fallacy" is the most common interpretation error in both medicine and machine learning.
How do I use a likelihood ratio?
A likelihood ratio converts a pre-test probability into a post-test probability: post-test odds = pre-test odds × LR. The widely used cutoffs of Jaeschke and colleagues are: for LR+, above 10 is strong evidence, 5–10 moderate, and 2–5 weak; for LR−, below 0.1 is strong, 0.1–0.2 moderate, and 0.2–0.5 weak. Values close to 1 mean the test contributes nothing to the decision.
Why is accuracy not enough on its own?
When the classes are imbalanced, accuracy is misleading. For a disease with 1% prevalence, a test that calls everyone "healthy" and catches no cases at all reaches 99% accuracy. Sensitivity, specificity, the predictive values, F1, and Youden J must therefore be judged together; on imbalanced data, F1 and balanced accuracy are more informative.
What is the Youden J index good for?
J is computed as sensitivity + specificity − 1 and takes values between 0 and 1; 0 means the test is no better than chance and 1 means perfect separation. On a ROC curve it corresponds to the point furthest from the diagonal, which is why it is often used to choose the optimal cut-off. If the costs of a false positive and a false negative are not equal, however, the point that maximizes J may not be the best clinical choice.
Can the PPV and NPV be computed in a case-control design?
Not directly from the sample. In such designs the numbers of affected and unaffected participants are set by the researcher, so the sample prevalence is artificial and the PPV/NPV computed from it are meaningless. The correct approach is to take sensitivity and specificity from the sample and then feed the true prevalence of the target population into Bayes' rule to produce the PPV and NPV — which is exactly what this calculator does when the prevalence field is filled in.
Why is no confidence interval given for the F1 score?
Sensitivity, specificity, and accuracy are binomial proportions with a fixed denominator, so the Wilson score interval applies. The denominator of the F1 score, however, depends on TP, FP, and FN alike and does not fit a simple binomial model. Because there is no closed-form interval formula, only the point estimate is reported; if you need an interval, use a bootstrap.