Bayes’ theorem in this visualization
Bayes’ theorem turns the probability of a result given a cause into the probability of the cause given the result: for any event with . Here is having a disease and a test result; the test is described by its sensitivity and specificity , the population by its prevalence . A square divides the population by both into four areas in proportion, and an evidence ruler under it shows the same update as a step in odds.
Why can a positive from an accurate test still leave the disease unlikely? The sensitivity is the chance that a sick person tests positive; a person who has tested positive needs the reverse, the chance of being sick. To get it, keep only the people who tested positive and treat them as the whole group: the sick are this share of them.
The denominator is : true positives from the few who are sick plus false positives from the many who are not. When the disease is rare, a small false-positive rate applied to nearly everyone can outnumber the true positives. That is what the lever shows: the two shaded blocks become the whole square, and the width of the sick block is the answer.
What does the test itself contribute? Divide the formula for the sick by the same one for the healthy and cancels: the posterior odds are the prior odds times the likelihood ratio , and after a negative times . The ratio belongs to the test, the prior odds to the people tested. The ruler is scaled by the logarithm of the odds, so multiplying becomes adding (as on a slide rule, logarithm) and a result is a step of fixed length from wherever the prior is. From a rare disease far to the left, a test with a finite takes one step that may not reach the middle; only a test with no false positives has an infinite one. A negative from a useful test () steps the other way, but the step is the same length wherever it starts: the more likely the disease beforehand, the higher the chance that remains, unless the test never misses a sick person ().
What does another positive tell you? Suppose that, among the sick and among the healthy separately, repeated results are independent and the test performs the same each time. Then each positive multiplies the odds by the same , and after positives the odds are the prior odds times ; in the square each positive splits the group again and keeps the part that tested positive once more. Real repeated tests often break this assumption: an error that comes from the person, such as an antibody that happens to react with the test, tends to come back, and a second positive then adds less than the formula says.
Things to notice
- The areas are probabilities and the numbers expected counts: averages over many groups of this size, not what any one group must contain.
- Sensitivity and specificity stay fixed here when the prevalence changes. In practice a test can perform differently in different groups, such as people with and without symptoms.
Controls
- The prevalence can also be dragged along the top of the square or by the ▲ under the ruler; the triangles beside the square set sensitivity and specificity in whole percents, the wheels in steps of 0.1%.