Sensitivity & Specificity Calculator

Calculate sensitivity, specificity, PPV, NPV, likelihood ratios, and Youden's J from a confusion matrix. Includes PPV/NPV table at different prevalence levels.

About the Sensitivity & Specificity Calculator

Sensitivity and specificity are the core measures of diagnostic test performance. Sensitivity measures how well a test detects the condition when it is present, while specificity measures how well it rejects the condition when it is absent.

This calculator takes a 2×2 confusion matrix and computes sensitivity, specificity, predictive values, likelihood ratios, Youden's J, diagnostic odds ratio, and confidence intervals. It also shows how PPV and NPV shift with prevalence, which matters a lot when a test is used for screening rather than confirmation.

That gives you a more complete picture than accuracy alone, especially for medical tests and other binary classifiers.

Why Use This Sensitivity & Specificity Calculator?

Diagnostic tests are rarely judged by one number alone. Sensitivity, specificity, and prevalence-adjusted predictive values answer different questions, so seeing them together helps separate a good screening test from a good confirmatory test.

How to Use This Calculator

  1. Enter the four cells of the confusion matrix: TP, FP, FN, TN.
  2. Or click a preset for common diagnostic scenarios.
  3. Optionally enter a custom prevalence to include in the PPV/NPV table.
  4. Set the confidence level for interval estimates.
  5. Review sensitivity, specificity, and predictive values.
  6. Examine likelihood ratios for clinical utility assessment.
  7. Check the PPV/NPV table at different prevalence levels.

Formula

Sensitivity = TP / (TP + FN) Specificity = TN / (TN + FP) PPV = TP / (TP + FP) NPV = TN / (TN + FN) Likelihood Ratios: LR+ = Sensitivity / (1 − Specificity) LR− = (1 − Sensitivity) / Specificity Prevalence-adjusted PPV: PPV = (Sens × Prev) / (Sens × Prev + (1−Spec) × (1−Prev)) Youden's J = Sensitivity + Specificity − 1

Example Calculation

Result: Sensitivity = 85.0%, Specificity = 99.4%

With 85 true positives, 5 false positives, 15 false negatives, and 895 true negatives: sensitivity is 85% (catches 85% of diseased patients) and specificity is 99.4% (correctly identifies 99.4% of healthy patients). LR+ = 152.2, indicating a positive result is very informative.

Tips & Best Practices

The Base Rate Fallacy and Screening Programs

When screening for rare conditions (low prevalence), even highly accurate tests produce more false positives than true positives. If a disease affects 1 in 1,000 people and the test has 99% sensitivity and 99% specificity, a positive result still only means ~9% chance of disease (PPV ≈ 9%). This counter-intuitive result is the base rate fallacy, and the prevalence table in this calculator makes it explicit.

ROC Analysis and Threshold Selection

Sensitivity and specificity depend on the chosen diagnostic threshold. Lowering the threshold increases sensitivity but decreases specificity (more false alarms). The ROC curve plots all possible sensitivity-specificity pairs. Youden's J maximizes the sum of sensitivity and specificity, providing one optimal threshold. Other criteria weight false positives and false negatives differently.

Multi-Step Diagnostic Strategies

In practice, single tests are often insufficient. A common strategy uses a sensitive screening test followed by a specific confirmatory test. The first test catches most cases (high sensitivity); the second test weeds out false positives (high specificity). Serial testing multiplies specificities and reduces overall false positive rate at the cost of some sensitivity.

Sources & Methodology

Last updated:

Frequently Asked Questions

What is the difference between sensitivity and PPV?

Sensitivity = P(test positive | disease present) — how well the test detects disease. PPV = P(disease present | test positive) — how likely disease is given a positive test. They answer different questions and are affected differently by prevalence.

Why does PPV change with prevalence?

In a low-prevalence population, most people are healthy. Even a specific test will produce many false positives from the large healthy population, diluting the true positives. At 0.1% prevalence, even a 99% specific test has only ~8% PPV.

What are likelihood ratios used for?

LR+ tells you how much to increase your estimate of disease probability after a positive test. LR− tells you how much to decrease it after a negative test. They're prevalence-independent, making them more generalizable than PPV/NPV.

What is a good value for sensitivity/specificity?

It depends on the clinical context. Screening tests usually prioritize high sensitivity, while confirmatory tests usually prioritize high specificity. The right tradeoff depends on the cost of false positives versus false negatives.

Can sensitivity and specificity both be 100%?

A perfect test (sensitivity = specificity = 100%) is rare in practice. Most tests trade off between the two. The ROC curve plots this trade-off at different thresholds, and the area under the ROC curve (AUC) summarizes overall discriminating ability.

What is the diagnostic odds ratio?

DOR = (TP × TN) / (FP × FN). It combines sensitivity and specificity into a single measure. DOR > 1 means the test discriminates better than chance. DOR > 100 indicates excellent discrimination. It's useful for comparing tests in meta-analyses.

Related Pages