Introduction
Diagnostic tests are used throughout clinical medicine to classify patients according to whether a disease, condition, or clinical state is present.
Examples include laboratory assays, imaging tests, pathology tests, biomarkers, screening instruments, clinical prediction rules, and point-of-care devices.
A diagnostic test can produce false-positive and false-negative results. Therefore, simply reporting the percentage of patients correctly classified is often insufficient.
Four fundamental quantities provide a much more informative description:
- Sensitivity
- Specificity
- Positive predictive value (PPV)
- Negative predictive value (NPV)
These measures answer different questions.
The 2×2 Diagnostic Table
The starting point for almost every diagnostic-test calculation is the 2×2 contingency table.
The rows represent the actual or reference-standard disease status. The columns represent the diagnostic-test result.
| Disease Present | Disease Absent | |
|---|---|---|
| Test Positive |
True Positive (TP) Test correctly identifies disease |
False Positive (FP) Test incorrectly indicates disease |
| Test Negative |
False Negative (FN) Test misses disease |
True Negative (TN) Test correctly excludes disease |
True Positives
A true positive occurs when the disease is actually present and the diagnostic test is positive.
For example, if 80 patients truly have a disease and the test correctly identifies 72 of them as positive, then:
False Negatives
A false negative occurs when disease is present but the diagnostic test is negative.
If 8 of the 80 diseased patients receive negative test results:
False negatives are particularly important when missing the disease has serious clinical consequences.
True Negatives
A true negative occurs when the disease is absent and the test is negative.
False Positives
A false positive occurs when the disease is absent but the test result is positive.
False positives can lead to unnecessary diagnostic procedures, treatment, anxiety, cost, and potential harm.
Four Fundamental Measures
| Measure | Question Answered | Formula |
|---|---|---|
| Sensitivity | Among patients with disease, how many test positive? | TP / (TP + FN) |
| Specificity | Among patients without disease, how many test negative? | TN / (TN + FP) |
| PPV | Among patients testing positive, how many actually have disease? | TP / (TP + FP) |
| NPV | Among patients testing negative, how many actually do not have disease? | TN / (TN + FN) |
Sensitivity
Sensitivity measures the ability of a diagnostic test to identify patients who truly have the disease.
The denominator is therefore:
which represents all patients who actually have the disease.
Example: Calculating Sensitivity
Suppose 100 patients truly have a disease. The diagnostic test identifies 90 as positive and misses 10.
Therefore:
The appropriate interpretation is:
Specificity
Specificity measures the ability of a diagnostic test to correctly identify patients who do not have the disease.
The denominator is:
which represents all patients who are truly disease-free.
Example: Calculating Specificity
Suppose 200 patients do not have the disease. The test is negative in 180 and incorrectly positive in 20.
Then:
Sensitivity and Specificity Are Conditional Probabilities
Sensitivity can be written as:
This means the probability of a positive test given that disease is present.
Specificity can be written as:
This means the probability of a negative test given that disease is absent.
This notation is useful because it makes clear that sensitivity and specificity condition on the true disease state.
Positive Predictive Value
Positive predictive value answers a different question.
The denominator:
represents everyone with a positive test.
Therefore PPV asks:
In probability notation:
Negative Predictive Value
Negative predictive value answers the corresponding question for negative tests.
The denominator:
represents everyone with a negative test.
Therefore NPV asks:
In probability notation:
The Complete Worked Example
Consider a diagnostic study involving 1,000 patients. Suppose the reference standard determines that 100 patients have disease and 900 do not. The diagnostic test produces:
| Disease Present | Disease Absent | Total | |
|---|---|---|---|
| Test Positive | 90 | 90 | 180 |
| Test Negative | 10 | 810 | 820 |
| Total | 100 | 900 | 1,000 |
Thus:
Sensitivity
Specificity
Positive Predictive Value
Negative Predictive Value
This produces an important result:
Why PPV and NPV Depend on Prevalence
Suppose a disease is uncommon. Even a highly specific test can generate a substantial number of false-positive results because there are many more disease-free individuals than diseased individuals.
This is one of the most important concepts in diagnostic-test interpretation.
Bayes' Theorem
The relationship between prevalence, test performance, and predictive values can be expressed using Bayes' theorem.
For a positive test:
Using sensitivity and specificity:
Similarly:
Worked Bayes Example
Suppose:
- Sensitivity = 90%
- Specificity = 90%
- Prevalence = 1%
Then:
which gives approximately:
Thus, despite a sensitivity and specificity of 90%, most positive tests would be false positives in this very-low-prevalence population.
Negative Predictive Value at Low Prevalence
When disease prevalence is low, NPV can be extremely high.
Using the same sensitivity and specificity:
the NPV is approximately:
A negative test is therefore highly reassuring in this low-prevalence setting.
Predictive Values Can Change Without Any Change in the Test
Consider the same test used in two populations.
| Population | Prevalence | Sensitivity | Specificity | Approx. PPV |
|---|---|---|---|---|
| Low-risk population | 1% | 90% | 90% | 8.3% |
| Moderate-risk population | 10% | 90% | 90% | 50.0% |
| High-risk population | 50% | 90% | 90% | 90.0% |
The diagnostic test has not changed. The sensitivity and specificity have not changed. Yet the PPV changes dramatically.
Diagnostic Accuracy
Overall diagnostic accuracy is sometimes defined as:
In the 1,000-patient example:
Accuracy can be useful, but it must be interpreted cautiously.
For highly imbalanced outcomes, accuracy can be misleading.
Why Accuracy Alone Can Be Misleading
Suppose a disease occurs in only 1% of a population. A test that simply declares everyone disease-free would have:
accuracy.
Yet its sensitivity would be:
because it detects none of the diseased patients.
False-Positive Rate
The false-positive rate is:
Because specificity is:
we have:
Thus, a specificity of 95% corresponds to a false-positive rate of 5%.
False-Negative Rate
Similarly:
and:
A sensitivity of 95% therefore corresponds to a false-negative rate of 5%.
Likelihood Ratios
Likelihood ratios provide another way to summarize diagnostic-test performance. They are especially useful for moving from a pretest probability to a post-test probability.
The positive likelihood ratio is:
The negative likelihood ratio is:
Interpreting LR+
A larger LR+ provides stronger evidence in favor of disease after a positive test.
For example, if:
then:
A positive result is therefore about nine times as likely in patients with disease as in patients without disease.
Interpreting LR−
A smaller LR− provides stronger evidence against disease after a negative test.
With the same sensitivity and specificity:
Lower LR− values are generally more useful for ruling out disease.
Common Qualitative Likelihood-Ratio Interpretation
| Likelihood Ratio | General Interpretation |
|---|---|
| LR+ > 10 | Large increase in probability |
| LR+ 5–10 | Moderate increase |
| LR+ 2–5 | Small increase |
| LR+ near 1 | Little or no diagnostic information |
| LR− 0.5–1 | Little decrease |
| LR− 0.2–0.5 | Small to moderate decrease |
| LR− 0.1–0.2 | Moderate to large decrease |
| LR− < 0.1 | Large decrease |
These are useful rules of thumb rather than universal clinical thresholds. The appropriate interpretation depends on the clinical context and the consequences of diagnostic error.
Pretest Probability and Post-Test Probability
Likelihood ratios can be used through odds.
First convert probability to odds:
Then:
Finally convert odds back to probability:
Worked Likelihood-Ratio Example
Suppose the pretest probability of disease is 20%.
The pretest odds are:
Suppose the test has:
Then:
Converting back to probability:
Thus, a positive test increases the estimated probability of disease from 20% to approximately 69%.
High Sensitivity and "Rule Out"
A highly sensitive test produces relatively few false negatives.
This can make a negative result useful for ruling out disease, particularly when the pretest probability is appropriate and the test has a sufficiently small LR−.
The traditional mnemonic is:
This mnemonic is only a heuristic. The actual diagnostic value depends on the magnitude of LR− and the patient's pretest probability.
High Specificity and "Rule In"
A highly specific test produces relatively few false positives.
A positive result can therefore be useful for ruling in disease, particularly when LR+ is large.
Again, the likelihood ratio and clinical context are more informative than the mnemonic alone.
Trade-Off Between Sensitivity and Specificity
Many diagnostic tests produce a continuous or ordinal measurement. A threshold is then selected to define a positive result.
Changing the threshold can change sensitivity and specificity.
For example, if a biomarker is considered positive when:
raising the threshold to:
will often reduce the number of positive tests. Depending on the underlying distributions, this may increase specificity while reducing sensitivity.
ROC Curves
A receiver operating characteristic, or ROC, curve displays sensitivity against the false-positive rate across possible thresholds.
The x-axis is:
and the y-axis is:
The diagonal line represents random discrimination. A curve closer to the upper-left corner generally represents better discrimination.
Area Under the ROC Curve
The area under the ROC curve, or AUC, summarizes discrimination across the range of thresholds.
An AUC of:
corresponds to discrimination no better than random classification in the standard binary setting.
An AUC of:
corresponds to perfect discrimination in the sample/population being evaluated.
| AUC | General Interpretation |
|---|---|
| 0.50 | No discrimination beyond chance |
| 0.60–0.70 | Limited discrimination |
| 0.70–0.80 | Moderate discrimination |
| 0.80–0.90 | Good discrimination |
| >0.90 | Excellent discrimination |
Choosing an Optimal Threshold
There is no universally optimal diagnostic threshold.
The appropriate cutoff depends on the clinical objective.
For example, if missing disease is especially harmful, investigators may favor higher sensitivity.
If false positives lead to invasive procedures or substantial harm, higher specificity may be prioritized.
Youden's Index
One commonly used statistical criterion is Youden's index:
The threshold maximizing \(J\) maximizes the vertical distance between the ROC curve and the diagonal reference line.
However, maximizing Youden's index is not automatically equivalent to choosing the clinically optimal cutoff.
Screening Versus Confirmatory Testing
Different clinical applications may prioritize different characteristics.
Screening
Screening programs often place substantial value on sensitivity because missed cases can undermine the purpose of early detection.
Confirmatory Testing
Confirmatory testing may place greater emphasis on specificity because false positives can lead to unnecessary treatment or invasive follow-up.
Sequential Testing
Diagnostic tests are sometimes used sequentially.
For example, a highly sensitive screening test may be followed by a highly specific confirmatory test.
The strategy can reduce the number of people exposed to expensive or invasive confirmatory testing while maintaining a desired level of case detection.
Parallel Testing
In parallel testing, multiple tests may be performed at approximately the same time. Depending on the rule used to classify the combined result, parallel testing can increase sensitivity but may reduce specificity.
The precise operating characteristics depend on the combination rule and the dependence between tests.
Independent Tests and Conditional Probability
When multiple diagnostic tests are combined, investigators should not casually assume statistical independence.
For example, two biomarkers may be biologically correlated.
If tests are correlated, multiplying probabilities as if they were independent can produce incorrect estimates.
Confidence Intervals
Sensitivity and specificity are estimated from finite samples. Therefore, point estimates should generally be accompanied by confidence intervals when inferential reporting is appropriate.
For sensitivity:
The denominator \(TP+FN\) determines the amount of information available for estimating sensitivity.
For specificity:
The denominator \(TN+FP\) determines the amount of information available for estimating specificity.
Why Wald Confidence Intervals Can Be Problematic
A simple normal approximation interval is sometimes written as:
For proportions near 0 or 1, or for small sample sizes, this approximation can perform poorly and can even produce limits outside the interval \([0,1]\).
Wilson or exact binomial intervals may be preferable depending on the analysis objective and reporting requirements.
Sample Size for Sensitivity and Specificity
Diagnostic studies often need sufficient numbers of both disease-positive and disease-negative participants.
If the primary objective is to estimate sensitivity precisely, the number of disease-positive participants is especially important.
If the primary objective is to estimate specificity precisely, the number of disease-negative participants is especially important.
Reference Standards Matter
Sensitivity and specificity require a definition of the "true" disease state. This is commonly established through a reference standard, sometimes called a gold standard.
However, reference standards are not necessarily perfect.
If the reference standard misclassifies disease status, estimates of diagnostic performance can be biased.
Verification Bias
Verification bias can occur when only a subset of participants receive the reference standard.
For example, patients with positive screening results may be much more likely to receive definitive diagnostic confirmation.
If verification is related to the index-test result, estimates of sensitivity and specificity can be distorted.
Spectrum Bias
Diagnostic performance can vary according to the spectrum of patients included in the study.
A study containing only patients with severe disease and healthy controls may produce very different estimates from a study containing:
- Mild disease
- Early disease
- Advanced disease
- Related conditions
- Healthy individuals
Therefore, diagnostic performance estimates should be interpreted in the population in which the study was conducted.
Prevalence and Generalizability
Sensitivity and specificity are often more transportable than PPV and NPV because predictive values depend directly on disease prevalence.
However, even sensitivity and specificity can change across populations if disease spectrum, comorbidities, treatment status, specimen characteristics, or test implementation differ.
Diagnostic Odds Ratio
Another summary measure is the diagnostic odds ratio, or DOR:
Equivalently:
Higher values generally indicate better discriminatory performance.
However, DOR can be less intuitive for clinical interpretation than sensitivity, specificity, or likelihood ratios.
Comparing Two Diagnostic Tests
Suppose Test A and Test B are being evaluated against the same reference standard.
| Measure | Test A | Test B |
|---|---|---|
| Sensitivity | 92% | 85% |
| Specificity | 82% | 94% |
| LR+ | 5.1 | 14.2 |
| LR− | 0.10 | 0.16 |
Neither test is universally "better."
Test A has greater sensitivity and a smaller LR−. Test B has greater specificity and a larger LR+.
The preferred test depends on the clinical purpose.
Interactive 2×2 Calculator
The following calculator converts a diagnostic 2×2 table into the major performance measures.
Diagnostic Test Calculator
Enter the four cells of a 2×2 diagnostic table. The calculator reports sensitivity, specificity, PPV, NPV, accuracy, false-positive rate, false-negative rate, LR+, and LR−.
R Implementation
Diagnostic performance can be calculated directly from a 2×2 table in R.
tp <- 90 fp <- 90 fn <- 10 tn <- 810 sensitivity <- tp / (tp + fn) specificity <- tn / (tn + fp) ppv <- tp / (tp + fp) npv <- tn / (tn + fn) accuracy <- (tp + tn) / (tp + fp + fn + tn) fpr <- fp / (fp + tn) fnr <- fn / (tp + fn) lr_positive <- sensitivity / (1 - specificity) lr_negative <- (1 - sensitivity) / specificity results <- data.frame( Sensitivity = sensitivity, Specificity = specificity, PPV = ppv, NPV = npv, Accuracy = accuracy, FPR = fpr, FNR = fnr, LR_Positive = lr_positive, LR_Negative = lr_negative ) results
Using a Confusion Matrix in R
Suppose the observed reference-standard status and test result are stored as binary variables.
table( Reference = reference_status, Test = test_result )
For example:
tab <- table( Reference = reference_status, Test = test_result ) tab
The exact indexing depends on how the factor levels are coded, so production programs should explicitly verify which cell represents TP, FP, FN, and TN.
Using the yardstick Package
The yardstick package provides functions for
classification metrics.
library(yardstick) sens_vec( truth = truth, estimate = estimate ) spec_vec( truth = truth, estimate = estimate ) ppv_vec( truth = truth, estimate = estimate ) npv_vec( truth = truth, estimate = estimate )
Factor-level definitions should be checked carefully so that the positive class is specified correctly.
ROC Analysis in R
The pROC package is commonly used for ROC analysis.
library(pROC) roc_object <- roc( response = disease_status, predictor = biomarker ) plot(roc_object) auc(roc_object)
A threshold can then be investigated using:
coords(
roc_object,
x = "best",
best.method = "youden",
ret = c(
"threshold",
"sensitivity",
"specificity"
)
)
Diagnostic-Test Reporting
A diagnostic-study report should make the denominators and reference standard clear.
For example:
What Should Be Reported With Sensitivity and Specificity?
- The reference standard
- The study population
- The number of disease-positive participants
- The number of disease-negative participants
- The diagnostic threshold
- Sensitivity
- Specificity
- Confidence intervals where appropriate
- PPV and NPV when clinically relevant
- Prevalence or disease prevalence in the study population
- Handling of indeterminate or missing results
Indeterminate Test Results
Some diagnostic tests produce an indeterminate, equivocal, or invalid result.
Such results should not simply be discarded without a prespecified rationale.
Possible analysis strategies include:
- Repeat testing
- Classification according to a prespecified rule
- Separate reporting of indeterminate results
- Best-case and worst-case sensitivity analyses
- Exclusion with transparent documentation
Missing Reference-Standard Results
Missing disease-status information creates a more fundamental problem because the true classification is unknown.
If participants with missing reference-standard results differ systematically from those with complete data, complete-case diagnostic estimates can be biased.
The missing-data strategy should therefore be considered as part of the statistical analysis plan.
Paired Comparison of Diagnostic Tests
When two diagnostic tests are applied to the same patients, their results are paired.
Simple comparison of two independent proportions may therefore be inappropriate.
For paired binary outcomes, methods such as McNemar's test can be relevant for certain comparative questions.
The choice of method depends on whether the objective is to compare sensitivity, specificity, predictive performance, overall classification, or another endpoint.
Diagnostic Test Versus Prognostic Model
Diagnostic performance should be distinguished from prognostic performance.
| Concept | Diagnostic Model | Prognostic Model |
|---|---|---|
| Primary question | Is the condition present? | What outcome will occur? |
| Typical outcome | Current disease status | Future event or outcome |
| Common measures | Sensitivity, specificity, PPV, NPV | Calibration, discrimination, time-dependent measures |
| ROC/AUC | Common | Also possible, with appropriate methods |
Diagnostic Versus Screening Performance
A test evaluated in a highly selected diagnostic population may not perform the same way in population screening.
For example, a diagnostic clinic may contain many patients with symptoms, comorbidities, or a high pretest probability. A population-screening program may contain mostly healthy individuals.
As prevalence and disease spectrum change, predictive values and potentially other operating characteristics can change.
Common Interpretation Errors
- Confusing sensitivity with PPV. Sensitivity asks how the test behaves among people with disease. PPV asks how disease status behaves among people with positive tests.
- Confusing specificity with NPV. Specificity conditions on disease absence; NPV conditions on a negative test.
- Ignoring prevalence. PPV and NPV can change substantially when prevalence changes.
- Using accuracy alone. Accuracy can be misleading when disease prevalence is highly imbalanced.
- Calling a test "90% accurate" without defining the metric. Accuracy, sensitivity, specificity, and predictive values are different quantities.
- Assuming PPV is intrinsic to the test. PPV depends on the testing population and disease prevalence.
- Assuming a high AUC guarantees clinical usefulness. Discrimination does not automatically establish clinical utility.
- Choosing a threshold solely from statistical optimization. Clinical consequences and decision objectives matter.
- Ignoring the reference standard. Diagnostic performance estimates depend on how disease status is defined.
- Ignoring indeterminate or missing results. These observations can materially affect estimates.
A Simple Memory Framework
The Denominator Is the Key
One of the easiest ways to avoid mistakes is to identify the denominator before remembering the formula.
| Measure | Denominator | Population in Denominator |
|---|---|---|
| Sensitivity | TP + FN | Everyone with disease |
| Specificity | TN + FP | Everyone without disease |
| PPV | TP + FP | Everyone testing positive |
| NPV | TN + FN | Everyone testing negative |
One-Sentence Definitions
Clinical Interpretation Example
Suppose a test has:
It is tempting to conclude that a positive result means there is a 95% probability that the patient has disease.
That conclusion is incorrect.
The 95% sensitivity does not describe the probability of disease given a positive test. The relevant quantity is PPV.
PPV must incorporate disease prevalence.
Worked Example at 1% Prevalence
Imagine screening 10,000 people for a disease with 1% prevalence. Thus:
people have disease and:
do not.
With sensitivity and specificity both equal to 90%:
| Disease | No Disease | |
|---|---|---|
| Positive | 90 | 990 |
| Negative | 10 | 8910 |
Therefore:
while:
The same test can therefore have a very high NPV and a relatively low PPV in a low-prevalence screening population.
Why This Matters in Screening
When screening millions of people for a relatively uncommon disease, even a small false-positive rate can produce a large number of false-positive results.
This does not necessarily mean the test is poor.
It means that screening is often a two-stage process:
- Identify potential cases.
- Confirm positive results with an appropriate diagnostic strategy.
Prevalence Is Not the Same as Sample Proportion in Every Setting
In a diagnostic study, the proportion of participants with disease may have been intentionally selected by the investigators.
For example, a case-control-style diagnostic study might enroll equal numbers of diseased and non-diseased participants even though the disease prevalence in clinical practice is much lower.
In such a design, the observed PPV and NPV may not represent the values that would occur in the target population.
Reporting Diagnostic Performance in a Clinical Study
A strong report should allow the reader to reconstruct the underlying classification.
At minimum, report:
- Number of participants evaluated
- Number with disease according to the reference standard
- Number without disease
- True positives
- False positives
- False negatives
- True negatives
- Sensitivity
- Specificity
- Confidence intervals where appropriate
- Diagnostic threshold
- Reference-standard definition
Suggested Diagnostic Performance Table
| Measure | Estimate | 95% CI |
|---|---|---|
| Sensitivity | 90.0% | 82.4%–95.1% |
| Specificity | 90.0% | 88.0%–91.8% |
| PPV | 50.0% | — |
| NPV | 98.8% | — |
| LR+ | 9.00 | — |
| LR− | 0.11 | — |
The exact confidence intervals should be calculated from the underlying data using an appropriate method rather than copied from an illustrative example.
Quality-Control Checklist
Practical Comparison of the Four Measures
| Measure | Starts With | Ends With | Main Use |
|---|---|---|---|
| Sensitivity | True disease | Positive test | Detect disease |
| Specificity | No disease | Negative test | Exclude disease correctly |
| PPV | Positive test | True disease | Interpret positive result |
| NPV | Negative test | No disease | Interpret negative result |
Summary
Sensitivity, specificity, positive predictive value, and negative predictive value are among the foundational measures of diagnostic-test performance.
The most important distinction is the direction of conditioning.
Sensitivity asks:
Specificity asks:
PPV asks:
NPV asks:
The first two describe test performance conditional on disease status. The latter two describe disease status conditional on the test result.
Key Formulas at a Glance
| Measure | Formula |
|---|---|
| Sensitivity | \(TP/(TP+FN)\) |
| Specificity | \(TN/(TN+FP)\) |
| PPV | \(TP/(TP+FP)\) |
| NPV | \(TN/(TN+FN)\) |
| Accuracy | \((TP+TN)/N\) |
| False-positive rate | \(1-Sp\) |
| False-negative rate | \(1-Se\) |
| LR+ | \(Se/(1-Sp)\) |
| LR− | \((1-Se)/Sp\) |
| Diagnostic odds ratio | \(LR+/LR-\) |
| Youden's index | \(Se+Sp-1\) |
References
Altman, D.G. and Bland, J.M. (1994). Diagnostic tests 1: Sensitivity and specificity. BMJ, 308, 1552.
Altman, D.G. and Bland, J.M. (1994). Diagnostic tests 2: Predictive values. BMJ, 309, 102.
Bossuyt, P.M., Reitsma, J.B., Bruns, D.E., et al. (2015). STARD 2015: An updated list of essential items for reporting diagnostic
accuracy studies. BMJ, 351, h5527.
Deeks, J.J. and Altman, D.G. (2004). Diagnostic tests 4: Likelihood ratios. BMJ, 329, 168–169.
Zweig, M.H. and Campbell, G. (1993). Receiver-operating characteristic (ROC) plots: a fundamental evaluation
tool in clinical medicine. Clinical Chemistry, 39(4), 561–577.
McNeil, B.J. and Hanley, J.A. (1984). Statistical approaches to the analysis of receiver operating
characteristic (ROC) curves. Medical Decision Making, 4(2), 137–150.