Advertisement
Advertisement
HEALTH STATISTICS

Sensitivity and Specificity Calculator — with PPV, NPV and likelihood ratios

Enter a diagnostic two-by-two table and see sensitivity, specificity, likelihood ratios, and predictive values recomputed at any prevalence you choose.

Cases where the condition is present by the reference standard and the test said positive.
Condition present, test said negative. These are the cases the test missed.
Condition absent, test said positive. These drive the false alarm burden.
Condition absent by the reference standard and the test correctly said negative.
Predictive values are recomputed at this base rate. Leave it at the study prevalence to reproduce the raw table, or lower it to see screening behaviour.
Sensitivity — true positive rate
0%
 
0%
Specificity
0%
PPV at target prevalence
0%
NPV at target prevalence
0.0
Positive likelihood ratio
Tip: sensitivity and specificity belong to the test. PPV and NPV belong to the test and the population you apply it to. Change nothing but the prevalence field and watch the last two move while the first two stand still.
Advertisement

The sensitivity and specificity calculator above takes the four cells of a diagnostic two-by-two table — true positives, false negatives, false positives and true negatives — and returns the full standard set of test performance measures. That includes sensitivity, specificity, positive and negative predictive values, positive and negative likelihood ratios, accuracy, and Youden's J index. Crucially, it lets you recompute the predictive values at any prevalence you like, because those two numbers change completely depending on who is being tested.

Arb Digital built this page as the clinical-epidemiology counterpart to our confusion matrix calculator. The arithmetic overlaps heavily, but the framing is different and so is the vocabulary. The confusion matrix page uses the machine-learning presentation: precision, recall, F1 score, and a classifier threshold you are tuning. This page uses the medical presentation: sensitivity, specificity, predictive values conditioned on prevalence, and likelihood ratios that update a pretest probability. Use the confusion matrix page when you are evaluating a model; use this one when you are describing how a test behaves in a defined population.

What This Sensitivity and Specificity Calculator Does

It computes eight related quantities from four counts, and it separates them into two groups that behave very differently. The first group — sensitivity, specificity and the two likelihood ratios — describes the test itself. Given a fixed reference standard and a fixed threshold, these numbers do not change when you move the test to a different population. The second group — positive predictive value, negative predictive value and overall accuracy — describes what happens when that test meets a specific base rate, and these numbers move dramatically with prevalence.

The prevalence field is the point of the page. Most published test performance figures come from a validation study where the condition was deliberately over-represented, because that is how you get enough positive cases to estimate sensitivity precisely. The PPV reported in such a study is therefore almost never the PPV you would see if the same test were rolled out to a general population. Typing the real-world prevalence into the field shows you the difference in one step.

This page does not interpret any specific test, name any condition, or suggest what any result means for a person. It is a statistics tool. The numbers it produces describe a table you supply, nothing more.

How to Use It

  1. Get the four counts from a table with a reference standard. Every cell requires knowing the true condition status independently of the test. Without a reference standard there is no sensitivity to measure.
  2. Enter the two condition-present cells first. True positives and false negatives must add up to the number of people who actually had the condition in the study.
  3. Enter the two condition-absent cells. False positives and true negatives must add up to the number who did not have it.
  4. Set the target prevalence. Use the study's own prevalence to reproduce the raw table figures, or type the base rate of the population you actually care about.
  5. Compare the two rows in the bar breakdown. They show predictive value at the study prevalence against predictive value at your target, which is the comparison most published tables omit.

The Formulas and How They're Calculated

Sensitivity is TP ÷ (TP + FN), the proportion of genuinely positive cases the test catches. Specificity is TN ÷ (TN + FP), the proportion of genuinely negative cases it correctly clears. Both are column proportions in the standard table layout, conditioning on the true state.

Predictive values run the other way, conditioning on the test result. Directly from the table, PPV is TP ÷ (TP + FP) and NPV is TN ÷ (TN + FN). To move them to a different prevalence p, the calculator uses the Bayes form: PPV = (Sn × p) ÷ (Sn × p + (1 − Sp) × (1 − p)) and NPV = (Sp × (1 − p)) ÷ (Sp × (1 − p) + (1 − Sn) × p). The likelihood ratios are LR+ = Sn ÷ (1 − Sp) and LR− = (1 − Sn) ÷ Sp.

Take the defaults. With TP = 180 and FN = 20, sensitivity is 180 ÷ 200 = 90%. With TN = 640 and FP = 160, specificity is 640 ÷ 800 = 80%. The study itself had 200 positives out of 1,000, a prevalence of 20%, giving a raw PPV of 180 ÷ 340 = 52.9% and a raw NPV of 640 ÷ 660 = 97.0%. Now set the target prevalence to 2%, a plausible general-population figure. PPV falls to (0.90 × 0.02) ÷ (0.90 × 0.02 + 0.20 × 0.98) = 0.018 ÷ 0.214 = 8.4%. The test did not change. Nine out of ten positives are now false alarms purely because the condition became rarer. The likelihood ratios, by contrast, stay fixed at LR+ = 0.90 ÷ 0.20 = 4.5 and LR− = 0.10 ÷ 0.80 = 0.125, which is exactly why they are the preferred summary in clinical epidemiology. The StatPearls chapter on Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios works through the same relationships in detail.

Advertisement

Base Rates: The Whole Reason This Page Exists

If you take one idea away, take this one. A positive test result does not mean the condition is present with probability equal to the test's accuracy. It means the condition is present with a probability that depends jointly on the test and on how common the condition was before testing. When the condition is rare, the group of people without it is so much larger than the group with it that even a small false positive rate produces more false alarms than the true positive rate produces real detections.

The arithmetic is unarguable and the intuition is stubbornly wrong. Run the defaults with a target prevalence of 0.1% and PPV drops to about 0.45% — roughly one real case in every 220 positives. Raise the target to 50% and PPV climbs to 81.8%. Identical test, identical threshold, identical sensitivity and specificity; the meaning of a positive result swings across two orders of magnitude. The classic Clinical Methods chapter on Sensitivity, Specificity, and Predictive Value demonstrates the same effect with a worked cardiac example and a figure plotting predictive value against pretest probability.

This is why the phrase "the test is 95% accurate" is close to meaningless on its own. Accuracy is a weighted blend of sensitivity and specificity with the study prevalence as the weight, so it inherits every population dependency of PPV without being transparent about it. On an imbalanced table, a test that always answers negative scores extremely well on accuracy while detecting nothing at all. Our Bayes' theorem calculator runs the same update from the probability side if you prefer to start with a pretest probability rather than a table.

Sensitivity and Specificity Always Trade Against Each Other

Almost every diagnostic test is a continuous measurement forced into a binary answer by a cut-off. Move that cut-off down and you catch more true cases — sensitivity rises — but you also sweep in more people without the condition, so specificity falls. Move it up and the reverse happens. The two numbers are not independent quality scores; they are two points on a single curve, and quoting one without the other is uninformative.

Which end of the trade-off is right depends entirely on the cost of each error. Where missing a case is far worse than a false alarm and there is a confirmatory follow-up available, a high-sensitivity, lower-specificity cut-off makes sense. Where a false positive triggers something invasive, expensive or irreversible, specificity carries more weight. The important discipline is to state which error you are optimising against before you look at the numbers, not after.

Youden's J index, reported in the bars below the grid, is sensitivity + specificity − 1. It ranges from 0 for a test that performs no better than chance to 1 for a perfect test, and it is often used to pick the cut-off that maximises overall discrimination. It weights the two error types equally, which is a strong assumption and frequently the wrong one, so treat it as a summary rather than a decision rule.

Why Likelihood Ratios Are the More Portable Number

Likelihood ratios have a property predictive values lack: they are independent of prevalence, and they multiply. LR+ tells you how many times more likely a positive result is in someone with the condition than in someone without it. Convert a pretest probability into odds, multiply by the likelihood ratio, convert back, and you have the post-test probability for that individual — no table, no population assumption.

The rough convention is that an LR+ above 10 or an LR− below 0.1 produces large, often decisive shifts in probability; values between 0.5 and 2 barely move anything. The default table's LR+ of 4.5 is moderate: it multiplies pretest odds by four and a half, which is meaningful when the pretest probability was already substantial and nearly worthless when it was tiny. That single sentence captures why the same test is genuinely useful in a symptomatic clinic and close to useless as a population screen.

The StatPearls entry on Prevalence sets out how prevalence is defined and measured, which matters because the target prevalence you type above is only as good as the source it came from. A guessed prevalence produces a guessed PPV.

Where the Four Counts Go Wrong Before You Even Start

Every number on this page inherits the quality of the reference standard. If the standard used to classify true condition status is itself imperfect, sensitivity and specificity are biased in ways that are hard to sign, let alone correct. When the reference standard is only applied to people who already tested positive — a very common study design — you get verification bias, which inflates sensitivity and deflates specificity, sometimes severely.

Spectrum bias is the other frequent problem. A test validated on clearly advanced cases against obviously healthy controls will report excellent sensitivity and specificity that collapse in a real clinic full of borderline, early or atypical presentations. The published figures are not wrong; they simply describe a population that does not resemble the one you care about. Before trusting a table, check who was in it. Sample precision is a separate question again, and our confidence interval calculator and sample size calculator handle that side — a sensitivity of 90% from 20 cases and from 2,000 cases are very different claims.

Need this level of rigour applied to your own data?

Arb Digital's analysts read conversion tests, lead scoring models and attribution data the way this page reads a diagnostic table — base rate first, headline number second.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Quoting a study's PPV as if it were universal — predictive values are specific to the prevalence of the population tested and travel badly to any other setting.
  • Swapping the false positive and false negative cells — the two are not interchangeable, and transposing them silently swaps sensitivity with specificity.
  • Reporting accuracy alone — it blends both error types with the study prevalence as the weight, so it hides exactly the information a reader needs.
  • Comparing tests at different cut-offs — a test with higher sensitivity may simply be using a looser threshold, not performing better.
  • Ignoring the reference standard — verification bias and spectrum bias distort every figure on the page, and no amount of arithmetic afterwards will fix them.

Related Free Tools From Arb Digital

Work the same four counts in machine-learning terms with the confusion matrix calculator, update a pretest probability directly with the Bayes' theorem calculator, put a range around an observed rate with the confidence interval calculator, plan how many cases you need with the sample size calculator, test a difference with the p-value calculator, or size the sampling error with the margin of error calculator. The full free online tools hub lists every statistics tool we publish.

Frequently Asked Questions

What is the difference between sensitivity and specificity?

Sensitivity is the proportion of people who truly have the condition that the test flags as positive. Specificity is the proportion of people who truly do not have it that the test correctly clears as negative. They measure two separate error types.

Why do PPV and NPV change with prevalence?

Because they condition on the test result rather than the true state. When a condition is rare, the much larger group without it generates more false positives than the small group with it generates true positives, so the same test yields a far lower PPV.

How do you calculate sensitivity from a two-by-two table?

Divide the true positives by the sum of true positives and false negatives. That denominator is everyone who genuinely had the condition according to the reference standard.

What is a good likelihood ratio?

By common convention a positive likelihood ratio above 10 or a negative likelihood ratio below 0.1 produces a large shift in probability, while values between 0.5 and 2 shift it very little. They are useful because they do not depend on prevalence.

How is this different from a confusion matrix calculator?

The arithmetic overlaps but the framing differs. A confusion matrix page reports precision, recall and F1 for evaluating a classifier. This page reports sensitivity, specificity and prevalence-adjusted predictive values, the vocabulary used for diagnostic tests.

What is Youden's J index?

Sensitivity plus specificity minus one. It ranges from zero for a test no better than chance to one for a perfect test, and it is sometimes used to select a cut-off. It weights both error types equally, which is often an unrealistic assumption.

Why is overall accuracy a weak summary?

Accuracy is a prevalence-weighted blend of sensitivity and specificity. On an imbalanced table a test that always answers negative can score very highly while detecting nothing, so accuracy can look excellent for a useless test.

Can I use this calculator to interpret my own test result?

No. This is a statistics tool that describes a table of counts you supply. Interpreting an individual result requires a qualified clinician who knows the specific test, the reference standard and the relevant pretest probability.

This page explains a statistical calculation for educational purposes only. It is not medical advice, it does not diagnose anything, and no result from it should be used to interpret a real diagnostic test without a qualified healthcare professional.

Advertisement
Advertisement

Take it further