Bayesian diagnostic test analysis — sensitivity, specificity, PPV, NPV, likelihood ratios, and post-test probability
When a patient tests positive for a disease, that result does not tell you the probability that the patient actually has the disease. That probability depends on three things: how sensitive the test is, how specific it is, and how common the disease is in the population being tested. Our free Medical Test Probability Calculator applies Bayes' theorem to compute every key diagnostic metric from your inputs — giving you a complete picture of a test's real-world performance. The most clinically actionable output is post-test probability. If a patient's pre-test probability (disease prevalence in the relevant population) is 5% and the test comes back positive, what is the probability they actually have the disease? If the answer is still only 30%, that means 70% of positive results are false positives — a critical fact that should guide clinical decisions. Our calculator computes post-test probability for both positive and negative test results using the Fagan equation: post-test probability is derived from pre-test odds multiplied by the likelihood ratio. Positive Predictive Value (PPV) is the probability that a patient testing positive truly has the disease. Negative Predictive Value (NPV) is the probability that a patient testing negative truly does not have the disease. Unlike sensitivity and specificity, which are intrinsic test characteristics, PPV and NPV vary with disease prevalence — a critically important nuance that this calculator makes visible. The prevalence slider lets you explore how PPV and NPV change as you adjust the background probability of disease, demonstrating why the same test performs very differently in a high-risk screening versus a low-risk population. Likelihood ratios (LR+ and LR−) are the most powerful single-number summaries of diagnostic test performance. LR+ measures how much more likely a positive result is in a diseased patient compared to a healthy one; LR− measures how much more likely a negative result is in a diseased patient. An LR+ above 10 provides very strong evidence to rule in a diagnosis; an LR− below 0.1 provides very strong evidence to rule it out. Values in between indicate progressively weaker evidence. Our calculator displays color-coded interpretation badges for both LR values. For users working with study data, the Raw Counts input mode accepts the four cells of the 2×2 contingency table directly: True Positives (TP), False Positives (FP), False Negatives (FN), and True Negatives (TN). All metrics are then derived from these counts, giving you sensitivity, specificity, prevalence, and all downstream values in a single calculation. To help with intuition, we include two visualizations that research shows improve Bayesian reasoning. The 2×2 contingency table shows the breakdown of outcomes for a reference population of 1,000 people with color-coded cells. The natural frequency icon array represents 100 people as colored dots — green for true positives, amber for false negatives, red for false positives, and gray for true negatives — making the abstract probabilities immediately concrete and comparable. Ten real-world clinical presets let you instantly load published sensitivity and specificity values for common tests including COVID-19 rapid antigen, high-sensitivity troponin, D-dimer for pulmonary embolism, mammography for breast cancer, PSA for prostate cancer, HbA1c for type 2 diabetes, rapid strep test, HIV ELISA, and urine pregnancy test. Simply select a preset, enter your population's prevalence, and the full analysis appears immediately. The step-by-step Bayesian walkthrough panel (expandable) shows every calculation stage: pre-test probability, conversion to pre-test odds, likelihood ratio application, post-test odds, and final post-test probability conversion. This is ideal for students learning evidence-based medicine, clinicians explaining results to patients, or anyone wanting to understand the mathematics behind the headline numbers.
Understanding Medical Test Probability
What Is Bayesian Reasoning in Diagnostic Testing?
Bayesian reasoning in diagnostic testing means updating your probability estimate based on new evidence — in this case, a test result. Before the test, you have a prior probability (the pre-test probability, which is essentially the prevalence of the disease in your patient's risk group). After performing the test, Bayes' theorem tells you exactly how much to update that probability based on the test result and the test's known performance characteristics (sensitivity and specificity). The result is the posterior probability — the post-test probability of disease. This framework is foundational to evidence-based medicine because it explains why a positive test does not necessarily mean you have the disease, especially when the disease is rare or the test has a high false-positive rate.
How Are the Metrics Calculated?
Sensitivity is computed as TP / (TP + FN) — the proportion of diseased patients who test positive. Specificity is TN / (FP + TN) — the proportion of healthy patients who test negative. PPV = (Sensitivity × Prevalence) / (Sensitivity × Prevalence + (1 − Specificity) × (1 − Prevalence)). NPV = (Specificity × (1 − Prevalence)) / ((1 − Sensitivity) × Prevalence + Specificity × (1 − Prevalence)). Likelihood ratios are LR+ = Sensitivity / (1 − Specificity) and LR− = (1 − Sensitivity) / Specificity. The Bayesian update works by converting prevalence to pre-test odds (p / (1-p)), multiplying by the likelihood ratio to get post-test odds, then converting back to probability (odds / (1 + odds)). Accuracy = Sensitivity × Prevalence + Specificity × (1 − Prevalence). F1-score = 2 × (PPV × Sensitivity) / (PPV + Sensitivity).
Why Does Prevalence Matter So Much?
Disease prevalence — the pre-test probability — has a profound effect on PPV and NPV, even for tests with excellent sensitivity and specificity. Consider a test with 99% sensitivity and 99% specificity applied to a disease with 1% prevalence: the PPV is only about 50%, meaning half of positive results are false positives. The same test applied to a population where 50% have the disease yields a PPV of over 99%. This paradox (sometimes called the base rate fallacy or the false positive paradox) is why mass population screening for rare conditions, even with high-quality tests, can generate large numbers of false positives that lead to unnecessary anxiety, follow-up testing, and potentially harmful interventions. Understanding this relationship is essential for ordering and interpreting any diagnostic test.
Limitations et mises en garde
This calculator assumes the published sensitivity and specificity values for a test are applicable to your specific patient population, testing context, and operator skill level — which may not always be the case. Sensitivity and specificity can vary substantially between studies, laboratory conditions, disease severity spectrum, and the pre-analytical handling of samples. The prevalence input requires you to estimate the pre-test probability for your specific patient, which involves clinical judgment that goes beyond what any calculator can provide. Confidence intervals on sensitivity and specificity are not shown here for brevity, but they can be wide for small studies and should be considered. This tool is intended for educational and decision-support purposes and should not replace clinical judgment or professional medical advice.
Comment Utiliser Ce Calculateur
Choisissez votre mode d'entrée
Select 'Sensitivity / Specificity' if you have published test performance values from the literature (most common). Select 'Raw Counts' if you are analyzing study data with a 2×2 contingency table (True Positives, False Positives, False Negatives, True Negatives). You can also load a clinical preset from the dropdown to automatically fill in validated sensitivity and specificity values for common tests like COVID-19 rapid antigen or high-sensitivity troponin.
Enter Sensitivity, Specificity, and Prevalence
In Sensitivity/Specificity mode, enter the sensitivity and specificity as percentages (0–100). These are intrinsic test properties that do not vary with population. Then enter the prevalence — this is the pre-test probability of disease for your specific patient context. For example, use 5% for a low-risk screening population and 40% for a symptomatic patient with risk factors. Use the prevalence slider for quick exploration. In Raw Counts mode, enter the four cells of the 2×2 table from your dataset.
Select Positive or Negative Test Result
Toggle between 'Positive Test' and 'Negative Test' to see the post-test probability for each scenario. The ProgressRing hero display and comparison bars update instantly to reflect the selected test outcome. This lets you answer both questions: 'What is the probability of disease if the test is positive?' and 'What is the probability of disease if the test is negative?'
Interpret the Results
Focus on post-test probability (the hero ring) — this is the most clinically relevant output, directly answering the question 'What is the probability of disease given this test result?' Review PPV and NPV for predictive value context. Check the LR+ and LR− interpretation badges: green badges indicate strong diagnostic evidence, amber indicates moderate, gray indicates weak. Expand the 'Bayesian Step-by-Step Walkthrough' panel to see every calculation step. Export or print the full results table for documentation.
Questions Fréquemment Posées
Why does a positive test not mean I definitely have the disease?
A positive test result only shifts your probability of having the disease — it does not confirm it. Whether a positive result likely indicates disease depends on three factors: the test's sensitivity, its specificity, and the pre-test probability (prevalence in your population). When disease prevalence is low, even a highly specific test will generate many false positives for every true positive, because the large number of healthy people being tested means even a small false-positive rate produces many incorrect results. This is the base rate fallacy. The Positive Predictive Value (PPV) captures this reality: it tells you what fraction of positive results represent true disease, which can be surprisingly low for rare conditions even with excellent tests.
What is the difference between sensitivity and specificity?
Sensitivity (also called the True Positive Rate or Recall) is the probability that the test correctly identifies a patient who has the disease. A test with 95% sensitivity will correctly detect 95 out of 100 diseased patients and miss 5 (false negatives). Specificity (also called the True Negative Rate) is the probability that the test correctly identifies a patient who does not have the disease. A test with 95% specificity will correctly clear 95 out of 100 healthy patients and falsely flag 5 (false positives). High sensitivity is most important for ruling out a diagnosis (a negative result on a sensitive test means disease is very unlikely). High specificity is most important for ruling in a diagnosis (a positive result on a specific test means disease is very likely).
What are likelihood ratios and why are they useful?
Likelihood ratios summarize how much a test result changes the probability of disease. The Positive Likelihood Ratio (LR+) equals Sensitivity / (1 − Specificity). It tells you how many times more likely a positive test result is in a diseased patient compared to a healthy one. An LR+ above 10 indicates very strong evidence to rule in disease; between 5–10 is strong; 2–5 is moderate; 1–2 is weak. The Negative Likelihood Ratio (LR−) equals (1 − Sensitivity) / Specificity. An LR− below 0.1 provides very strong evidence to rule out disease. Likelihood ratios are useful because they can be applied to any pre-test probability via the Fagan equation, making them more versatile than PPV and NPV, which change with prevalence.
How does disease prevalence affect PPV and NPV?
Prevalence has a dramatic effect on Positive Predictive Value (PPV) and Negative Predictive Value (NPV). Consider a test with 99% sensitivity and 99% specificity: at 1% prevalence, PPV is only about 50% — half of positives are false alarms. At 10% prevalence, PPV rises to about 92%. At 50% prevalence, PPV reaches nearly 99%. Conversely, NPV decreases as prevalence increases, because more diseased patients are missed. This is why population-level screening programs for rare diseases require careful consideration: the same test that is highly predictive in a high-risk clinic may generate unacceptable numbers of false positives in a low-prevalence general population. Use the prevalence slider in this calculator to see how your specific values shift.
What is the difference between PPV and sensitivity?
Sensitivity and PPV answer different questions about the test. Sensitivity asks: 'Among all patients who have the disease, what fraction does the test correctly identify?' It is a property of the test itself and does not depend on prevalence. PPV asks: 'Among all patients who test positive, what fraction actually have the disease?' PPV depends not only on the test's sensitivity and specificity but critically on the prevalence of disease in the population being tested. Sensitivity is determined once, during test validation studies. PPV must be recalculated for each clinical setting based on the local disease rate. A test can have high sensitivity but very low PPV if disease is rare — making sensitivity alone an incomplete guide to interpreting a positive result.
What is the Fagan nomogram used in this calculator?
The Fagan nomogram (developed by Terrence Fagan in 1975) is a graphical tool for applying Bayes' theorem to diagnostic testing. It has three vertical scales: pre-test probability, likelihood ratio, and post-test probability. Drawing a straight line from the pre-test probability through the likelihood ratio gives the post-test probability at the intersection with the third scale. Our calculator performs this calculation algebraically: pre-test odds = prevalence / (1 − prevalence), post-test odds = pre-test odds × LR, and post-test probability = post-test odds / (1 + post-test odds). The step-by-step walkthrough panel in the results section shows each of these stages explicitly, making the calculation transparent and educational.