Skip to content
All apps

Bayes' theorem & base rates

About this app

A mosaic of prevalence × sensitivity/specificity: why a positive test for a rare disease is often no reason to panic. The false-positive area beats the hit area — posterior P(D∣+) live, the base-rate fallacy made visible.

The statistics

Bayes’ theorem reverses a conditional probability: from a test’s sensitivity P(+|D) it gives P(D|+), the probability of actually having the disease after a positive result. P(D|+) = P(+|D)·P(D) / [P(+|D)·P(D) + P(+|¬D)·P(¬D)]. The key ingredient is the base rate P(D), the prevalence. For a rare disease there are so many healthy people that even a small false-positive rate produces more false positives than true positives. Ignoring this is the base rate fallacy.

What you see

A unit square represents the whole population: on the left the sick group, as wide as the prevalence, on the right the healthy group. Each column is split by test result, giving four fields: true positive, false positive, false negative and true negative. A second chart shows the step from prior to posterior. A values panel lists prior, sensitivity, specificity, P(D|+) and P(D|−) and the four counts per 10,000 people, with Bayes’ formula alongside.

Things to try

Load the rare disease example: with 1 % prevalence, 99 % sensitivity and 95 % specificity the false-positive field is larger than the true-positive field, and P(D|+) lies far below the sensitivity. Then push the prevalence up and watch the posterior rise sharply. Raise the specificity to 99.9 % and compare which slider has more effect. The common disease example shows the situation when the condition is widespread.

Frequently asked questions

What does Bayes’ theorem say?
Bayes’ theorem links the conditional probabilities P(A|B) and P(B|A): P(A|B) = P(B|A)·P(A)/P(B). It describes how a starting probability (prior) is updated by new information into a posterior. In the medical example it turns a test’s accuracy into the probability of being ill after a positive result.
What is the base rate fallacy?
The base rate fallacy is neglecting how common a feature is in the population. A typical case is equating a test’s sensitivity with the probability of being ill after a positive result. For rare diseases that probability is often much lower, because many positive results come from healthy people.
What is the difference between sensitivity and specificity?
Sensitivity P(+|D) is the share of sick people the test correctly flags as positive. Specificity P(−|¬D) is the share of healthy people it correctly classifies as negative. One minus specificity is the false-positive rate.
What can I set in the Bayes app?
You set prevalence, sensitivity and specificity with sliders or load the rare and common disease examples. The mosaic, the step from prior to posterior, P(D|+), P(D|−) and the counts per 10,000 people update instantly.

Subject: Statistics

More from Statistics

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps