Diagnostic Test Calculator: Zero to Hero Tutorial
This tutorial takes you from the foundations of diagnostic testing through sensitivity, specificity, predictive values, likelihood ratios, ROC concepts, calculator use, clinical interpretation, reporting, and common mistakes. It is written for clinical, public health, laboratory, and research contexts where an index test is compared with a reference standard.
Table of Contents
- Prerequisites and Background Concepts
- What Is Diagnostic Test Evaluation?
- Diagnostic Study Design
- The Mathematics Behind Diagnostic Accuracy
- Assumptions and Bias
- Using the Diagnostic Test Calculator
- Predictive Values and Prevalence
- Likelihood Ratios and Clinical Decisions
- ROC Curves and Threshold Selection
- Worked Examples
- Common Mistakes and How to Avoid Them
- Troubleshooting
- Quick Reference Cheat Sheet
1. Prerequisites and Background Concepts
1.1 Index Test and Reference Standard
The index test is the test being evaluated. The reference standard is the best available method for classifying true disease status. Diagnostic accuracy depends on how well the index test agrees with the reference standard.
1.2 Disease Status and Test Status
Diagnostic test evaluation uses a 2x2 table:
| Disease + | Disease - | Total | |
|---|---|---|---|
| Test + | TP | FP | TP+FP |
| Test - | FN | TN | FN+TN |
| Total | TP+FN | FP+TN | n |
Where:
- TP = true positive.
- FP = false positive.
- FN = false negative.
- TN = true negative.
1.3 Screening vs. Diagnosis
Screening is applied to people without known disease to identify who needs follow-up. Diagnosis is applied when disease is suspected. The same test can have different clinical value in these settings because prevalence and consequences differ.
2. What Is Diagnostic Test Evaluation?
Diagnostic test evaluation asks:
How well does this test classify disease compared with a reference standard?
The answer requires more than one metric. Sensitivity and specificity describe test classification performance. Predictive values describe what test results mean in a particular population. Likelihood ratios describe how much a result shifts disease probability.
3. Diagnostic Study Design
3.1 Ideal Design
An ideal diagnostic accuracy study:
- Enrolls a representative spectrum of patients.
- Applies the index test and reference standard to all participants.
- Blinds test interpreters to the other result.
- Uses a clinically credible reference standard.
- Reports uncertainty with confidence intervals.
3.2 Common Sources of Design Error
| Bias | What happens |
|---|---|
| Spectrum bias | Test evaluated in patients unlike the target population |
| Verification bias | Only some participants receive the reference standard |
| Incorporation bias | Index test is part of the reference standard |
| Review bias | Test readers know the reference result |
| Selection bias | Diseased and non-diseased groups are sampled unrealistically |
4. The Mathematics Behind Diagnostic Accuracy
4.1 Sensitivity
Sensitivity is the proportion of diseased people correctly testing positive:
High sensitivity is useful when missing disease is costly.
4.2 Specificity
Specificity is the proportion of non-diseased people correctly testing negative:
High specificity is useful when false positives are costly.
4.3 Predictive Values
Positive predictive value:
Negative predictive value:
4.4 Likelihood Ratios
Positive likelihood ratio:
Negative likelihood ratio:
4.5 Diagnostic Odds Ratio
The diagnostic odds ratio summarizes test discrimination:
Higher values indicate better discrimination, but DOR is less directly clinical than likelihood ratios.
5. Assumptions and Bias
Diagnostic accuracy estimates assume:
- Disease status is classified by a valid reference standard.
- The same reference standard is applied consistently.
- Test and disease statuses are independent observations.
- The study population matches the intended clinical population.
- The index test threshold is pre-specified or clearly justified.
When these assumptions fail, accuracy can look better than it will be in practice.
6. Using the Diagnostic Test Calculator
Step-by-Step Guide
Step 1: Define the clinical question.
Example: "How well does a rapid antigen test detect PCR-confirmed infection?"
Step 2: Identify the reference standard.
Use the best available disease classification method.
Step 3: Build the 2x2 table.
| Disease + | Disease - | |
|---|---|---|
| Test + | TP | FP |
| Test - | FN | TN |
Step 4: Enter raw counts.
Use counts, not percentages.
Step 5: Review all outputs.
Read sensitivity, specificity, PPV, NPV, LR+, LR-, and confidence intervals.
Step 6: Translate the result clinically.
State what a positive and negative result mean in the population studied.
7. Predictive Values and Prevalence
PPV and NPV depend strongly on prevalence:
As prevalence falls, PPV usually falls and NPV usually rises. This is why screening programs can generate many false positives even with a good test.
8. Likelihood Ratios and Clinical Decisions
Likelihood ratios help move from pre-test probability to post-test probability.
Rules of thumb:
| Value | Interpretation |
|---|---|
| LR+ > 10 | Strong evidence for disease |
| LR+ 5 to 10 | Moderate evidence for disease |
| LR+ 2 to 5 | Weak evidence for disease |
| LR+ = 1 | No diagnostic value |
| LR- < 0.1 | Strong evidence against disease |
| LR- 0.1 to 0.2 | Moderate evidence against disease |
Likelihood ratios are often more transportable than predictive values because they are less directly tied to prevalence.
9. ROC Curves and Threshold Selection
When a test has a continuous score, the threshold determines sensitivity and specificity. Lowering the threshold usually increases sensitivity and lowers specificity.
Youden's Index:
The threshold with the highest balances sensitivity and specificity, but clinical costs may justify a different threshold.
AUC interpretation:
| AUC | Interpretation |
|---|---|
| 0.5 | No discrimination |
| 0.7 to 0.8 | Acceptable |
| 0.8 to 0.9 | Excellent |
| > 0.9 | Outstanding |
10. Worked Examples
Example 1: Rapid Test vs. PCR
| Disease + | Disease - | |
|---|---|---|
| Test + | 90 | 30 |
| Test - | 10 | 870 |
Interpretation: A positive result provides strong evidence for disease, while a negative result provides strong evidence against disease in this population.
Example 2: Low-Prevalence Screening
Assume sensitivity 90%, specificity 95%, and prevalence 1%.
Among 10,000 screened people:
- Expected diseased: 100.
- True positives: 90.
- False negatives: 10.
- Non-diseased: 9,900.
- False positives: 495.
- True negatives: 9,405.
Even with a good test, most positive results are false positives when prevalence is low.
11. Common Mistakes and How to Avoid Them
Mistake 1: Treating Sensitivity as PPV
Sensitivity answers "Among diseased people, how many test positive?" PPV answers "Among positive tests, how many truly have disease?"
Mistake 2: Ignoring Prevalence
Predictive values change across populations.
Mistake 3: Using Accuracy Alone
Accuracy can be misleading when disease is rare.
Mistake 4: Evaluating Only Obvious Cases and Healthy Controls
This can exaggerate test performance.
Mistake 5: Choosing a Threshold After Seeing Results Without Saying So
Threshold optimization should be transparent and validated.
12. Troubleshooting
| Problem | Likely cause | What to do |
|---|---|---|
| PPV is unexpectedly low | Low prevalence | Review expected false positives |
| Accuracy is high but sensitivity is poor | Disease is rare | Focus on sensitivity and specificity |
| LR values are undefined | Specificity or sensitivity is 0 or 1 | Check sparse cells and exact intervals |
| Results do not generalize | Spectrum bias | Evaluate in target population |
| Sensitivity and specificity trade off | Threshold issue | Review ROC curve and clinical costs |
13. Quick Reference Cheat Sheet
| Metric | Formula | Meaning |
|---|---|---|
| Sensitivity | Detects disease | |
| Specificity | Excludes non-disease | |
| PPV | Positive result credibility | |
| NPV | Negative result credibility | |
| LR+ | Evidence from positive test | |
| LR- | Evidence from negative test | |
| Youden's J | Threshold balance |
Reporting Template
Compared with [reference standard], [index test] had sensitivity [value], specificity [value], PPV [value], NPV [value], LR+ [value], and LR- [value] in a population with [prevalence] disease prevalence.
Final Checklist
- Define the index test.
- Define the reference standard.
- Enter TP, FP, FN, and TN correctly.
- Report confidence intervals.
- Interpret PPV and NPV in context of prevalence.
- Discuss verification, spectrum, and threshold bias.