Ask Mallard
Analysis method

Sensitivity and specificity

5 min read

A diagnostic two-by-two table estimates sensitivity, specificity and predictive values at one fixed threshold, each with its own uncertainty.

Fit

When to use it, and when not to

Use it when

  • You have a binary test result and a reference diagnosis for the same patients.
  • You need accuracy estimates at a threshold fixed before examining outcomes.

Not when

Before you start

What you need

Decide these first
  1. Four labeled countsRecord true positives, false negatives, false positives and true negatives against the same reference standard.
  2. How patients entered the samplePredictive values require the intended population prevalence. A case-control sample fixes the disease fraction by design.
  3. A fixed threshold and target conditiontargetSpecify what counts as a positive test and a positive reference diagnosis.
  4. Missing and indeterminate resultsKeep their counts and reasons. Choose a missing-data method under a stated assumption; do not silently discard difficult cases.
It rests on these
  1. The reference standard is credible and read independently.How to check: Name its errors, blinding and timing. An imperfect reference distorts accuracy.
  2. Verification does not depend on an unobserved diagnosis.How to check: Check whether everyone received the reference standard. Partial verification needs a justified correction.
  3. Each patient contributes one independent pair of results.How to check: For repeated lesions, visits or clustered sampling, use cluster-aware intervals rather than independent binomial intervals.
  4. The complete table is representative under the stated missingness assumption.How to check: Complete-case analysis needs justification. Under missing at random, consider imputation or weighting; assess missing not at random with sensitivity analyses.

Plain language

How it works

Arrange test-positive and test-negative rows against reference-positive and reference-negative columns. Sensitivity is true positives divided by all reference positives. Specificity is true negatives divided by all reference negatives. Positive predictive value uses all test positives; negative predictive value uses all test negatives.

Choose the interval for the estimator

For an independent, complete cohort table, each is a single binomial proportion. Wilson or Clopper-Pearson intervals fit those estimators. Predictive values standardized to external prevalence need intervals that also reflect the estimated inputs. Mercaldo and colleagues address that different sampling problem.

From reference results to the table
A diagnostic accuracy study. Consecutive eligible people all receive both the index test and the reference standard, and the results form a two-by-two table. A dashed path shows partial verification, where only people with a positive index test get the reference standard, which distorts the estimates.Diagnostic accuracy: everyone gets both testsConsecutive eligible peopleIndex testReference standardTwo-by-two table: index test result against reference standard resultPartial verification:reference only ifpositiveSampling obvious cases and healthy volunteers instead of consecutive eligible people exaggerates apparentaccuracy.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Worked example

A worked example

Invented for illustration
Setting
1,000 consecutive patients each receive a binary index test and a blinded reference standard. There are no missing or indeterminate results.
Question
What are the four accuracy estimates and their uncertainty at this fixed threshold?
Approach
The table contains 85 true positives, 15 false negatives, 180 false positives and 720 true negatives. Use separate Wilson intervals for each proportion.
Result
Sensitivity is 85.0% (95% Wilson interval 76.7% to 90.7%). Specificity is 80.0% (95% Wilson interval 77.3% to 82.5%). Positive predictive value is 32.1% (95% Wilson interval 26.7% to 37.9%). Negative predictive value is 98.0% (95% Wilson interval 96.7% to 98.8%).
What it means
The sample prevalence is 10.0%. Of 265 positive tests, 85 identify disease; of 735 negative tests, 720 correctly exclude it.

In practice

Recent studies PubMed search · not vetted

Searching PubMed…

Watch out

Common mistakes

The one to remember

Sensitivity and specificity condition on reference diagnosis; predictive values condition on test result and depend on prevalence. Independent-binomial intervals need independent patients and a credible reference standard. A case-control table cannot directly estimate population predictive values.

  • Using the same denominator for every estimate.Instead: Sensitivity uses reference-positive people; specificity uses reference-negative people. Predictive values condition on the observed test result.
  • Transporting predictive values from a case-control sample.Instead: Use target prevalence and a suitable variance method. A Wilson interval for a simple proportion does not cover an externally standardized estimate.
  • Treating high specificity as a high chance that a positive test is correct.Instead: That chance is positive predictive value, which also depends on prevalence.

Inside Mallard

How Mallard uses this

Mallard’s diagnostic calculator reports these four proportions with Wilson intervals. The method registry links diagnostic accuracy to this article and code.

Code example in Mallard: Diagnostic accuracy with Wilson intervals (diagnostic-accuracy-wilson).
Sample size: Mallard sizes the main comparison with dx accuracy. It does not size adjustment or any secondary analysis.
Calculators: Diagnostic 2×2, Sens, Spec, Youden (§6.1).
Atlas node analysis.sensitivity_specificity, the id a plan cue records.

How to report it

Report all four cells, sampling, reference standard, threshold, missing results, prevalence and each estimate with its named interval method. A reporting guideline is not a design manual: use it to make the study transparent, not as a substitute for careful design. Check the target journal's own requirements as well, which this page cannot know.

Code for this method
Loading…

Work it out

Related Learn pages

Related designs and methods

Evidence

Sources & further reading

  1. Two-sided confidence intervals for the single proportion: comparison of seven methods. (opens in a new tab) · Stat Med · doi 10.1002/(sici)1097-0258(19980430)17:8<857::aid-sim777>3.0.co;2-e
  2. Confidence intervals for predictive values with an emphasis to case-control studies. (opens in a new tab) · Stat Med · doi 10.1002/sim.2677
Prepared with AI assistance. PubMed records checked by title, authors, year and available DOI on 2026-11-07: record verified, confirm it supports this use. No independent professional approval is claimed. Newcombe compares single-proportion intervals. Mercaldo studies predictive-value intervals, especially with case-control sampling; that paper does not justify a naive cohort interval for externally standardized values.
Last source review: 2026-11-07
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.