Tutorials › Introduction to Statistics › Bayes’ Rule With More Than Two Diagnostic Outcomes

Conditional Probability and Bayes’ Rule · Tutorial 346 of 996

Bayes' Rule With More Than Two Diagnostic Outcomes

Use the likelihood of an observed result and the prior probabilities of several disease categories to calculate the posterior probability for each category.

Beginner 9 min read

What You'll Learn

  • Define a complete set of mutually exclusive disease categories for a diagnostic calculation
  • Distinguish prior probabilities from test-result likelihoods and posterior probabilities
  • Apply Bayes’ rule when there are three or more possible categories
  • Calculate the probability of an observed result by adding across categories
  • Check posterior probabilities and interpret them in the diagnostic context

Why Diagnostic Categories Need More Than a Positive-or-Negative Split

A test result may need to be interpreted across several possible conditions, not just “disease” and “no disease.” For example, a diagnostic pathway might distinguish between two related conditions and neither condition. Once the possible categories are set up, the central question is the same: given the result that was observed, how probable is each category?

Bayes’ rule answers this by combining two kinds of information. A prior probability describes how common each category is before using the observed result. A likelihood describes how often that result occurs within a particular category. The posterior probabilities—the probabilities of the categories after observing the result—are proportional to the prior probabilities multiplied by their respective likelihoods.

Definition: Let \(D_1,\ldots,D_k\) be mutually exclusive and exhaustive diagnostic categories, and let \(R\) denote one particular observed test result. The prior probability of category \(D_i\) is \(P(D_i)\), and the likelihood of result \(R\) in that category is \(P(R\mid D_i)\). The posterior probability of category \(D_i\) given the result is $$ P(D_i\mid R)=\frac{P(D_i)P(R\mid D_i)}{\sum_{j=1}^{k}P(D_j)P(R\mid D_j)}. $$

“Mutually exclusive” means an individual belongs to no more than one category in the model. “Exhaustive” means the categories cover every possible diagnostic state being considered, so their prior probabilities sum to 1. For example, “Condition A,” “Condition B,” and “neither condition” can form a complete set if the conditions cannot occur together and no other state is relevant to the question.

For the formula to apply, the likelihoods must refer to the same observed result and be conditional on the corresponding category. The denominator must be positive: at least one category with positive prior probability must allow the observed result. The formula describes probabilities for the population or model represented by the stated priors and likelihoods; it does not establish that a particular diagnosis caused a particular test result.

How the Calculation Works

For each category, multiply its prior probability by the probability of seeing the result in that category. This product is the joint probability of being in that category and observing the result. Add these products over all categories to find the overall probability of the result. Finally, divide each category’s product by that overall probability.

1
List the categories.
Check that they are mutually exclusive and exhaustive for the question being asked.
2
Record priors and likelihoods.
For every category, state \(P(D_i)\) and the likelihood \(P(R\mid D_i)\) of the result actually observed.
3
Calculate the category weights.
For each category, compute \(P(D_i)P(R\mid D_i)\). These weights need not sum to 1.
4
Normalize and interpret.
Add the weights, divide each one by their sum, and describe the resulting posterior probabilities in context.

This procedure uses the law of total probability in the denominator. The observed result can occur through any one of the categories, and those category-result events are mutually exclusive. Therefore, the result’s overall probability is the sum of its probability within each category, weighted by that category’s prior probability.

Worked Diagnostic Examples

Worked Example: A Positive Result Across Three Categories

Suppose a hypothetical diagnostic model has three exhaustive categories: Condition A, Condition B, and neither condition. The prior probabilities are 0.02, 0.08, and 0.90, respectively. A positive result occurs with probability 0.90 in Condition A, 0.60 in Condition B, and 0.05 in the neither-condition category. Find the posterior probability of each category after a positive result.

Check the setup. The stated priors sum to \(0.02+0.08+0.90=1.00\), and the categories are assumed not to overlap. The likelihoods all refer to the same positive result for the same test. The overall probability of a positive result will be greater than zero.

Find the category weights. Multiply each prior by the positive-result likelihood for that category:

$$ \begin{aligned} \text{Condition A: }&0.02(0.90)=0.018\\ \text{Condition B: }&0.08(0.60)=0.048\\ \text{Neither: }&0.90(0.05)=0.045 \end{aligned} $$

The overall probability of a positive result is \(0.018+0.048+0.045=0.111\). Thus, the posterior probabilities are:

$$ \begin{aligned} P(\text{A}\mid +)&=\frac{0.018}{0.111}=0.1622\\ P(\text{B}\mid +)&=\frac{0.048}{0.111}=0.4324\\ P(\text{neither}\mid +)&=\frac{0.045}{0.111}=0.4054 \end{aligned} $$

After a positive result, the model assigns about 16.2% probability to Condition A, 43.2% to Condition B, and 40.5% to neither condition. The three posteriors sum to 1. A positive result does not make the category with the highest likelihood automatically the most probable diagnosis: the priors also matter. Here Condition B has the largest posterior probability, even though the likelihood of a positive result is higher in Condition A, because Condition B has a larger prior probability.

Worked Example: An Indeterminate Result

Consider three hypothetical categories: Condition C, Condition D, and neither condition, with priors 0.10, 0.20, and 0.70. A test can report positive, negative, or indeterminate. Its conditional probabilities are shown below. Find the posterior probabilities after an indeterminate result.

CategoryPriorPositive likelihoodNegative likelihoodIndeterminate likelihood
Condition C0.100.750.150.10
Condition D0.200.600.200.20
Neither condition0.700.050.900.05

Check the setup. The priors sum to 1.00. For each category, the probabilities of the three possible test outcomes also sum to 1.00, so the likelihoods are consistent with the stated set of outcomes. We use only the likelihood of the observed indeterminate result.

The category weights are \(0.10(0.10)=0.010\) for Condition C, \(0.20(0.20)=0.040\) for Condition D, and \(0.70(0.05)=0.035\) for neither condition. Therefore,

$$ P(\text{indeterminate})=0.010+0.040+0.035=0.085. $$

Dividing each weight by 0.085 gives:

$$ \begin{aligned} P(\text{C}\mid \text{indeterminate})&=\frac{0.010}{0.085}=0.1176\\ P(\text{D}\mid \text{indeterminate})&=\frac{0.040}{0.085}=0.4706\\ P(\text{neither}\mid \text{indeterminate})&=\frac{0.035}{0.085}=0.4118 \end{aligned} $$

In this hypothetical model, after an indeterminate result the posterior probability of Condition D is about 47.1%, the probability of Condition C is about 11.8%, and the probability of neither condition is about 41.2%. The result does not have to be positive or negative for Bayes’ rule to apply; it can be any defined outcome with a likelihood in each category.

Why the Denominator Includes Every Category

The denominator is not an optional adjustment. It converts the joint probabilities for the observed result and each category into probabilities conditional on that result. A short derivation shows why the same denominator is used for every category.

By the definition of conditional probability, \(P(D_i\mid R)=P(D_i\cap R)/P(R)\), provided \(P(R)>0\). The multiplication rule gives \(P(D_i\cap R)=P(D_i)P(R\mid D_i)\). Since the categories partition all possibilities, the events \(D_1\cap R,\ldots,D_k\cap R\) are mutually exclusive and together make up \(R\). Adding their probabilities gives \(P(R)=\sum_{j=1}^{k}P(D_j)P(R\mid D_j)\). Substituting these two expressions yields Bayes’ rule for any number of categories:

$$ P(D_i\mid R) =\frac{P(D_i\cap R)}{P(R)} =\frac{P(D_i)P(R\mid D_i)} {\sum_{j=1}^{k}P(D_j)P(R\mid D_j)}. $$

This also explains why the posterior probabilities sum to 1: their numerators add up to the denominator. If the calculation does not produce posteriors summing to 1 (apart from rounding), check the category list, the likelihoods, and the denominator.

Worked Example: Updating Four Categories With Natural Frequencies

Suppose a hypothetical population has four exhaustive categories: Condition E (1%), Condition F (4%), Condition G (15%), and none of these conditions (80%). A particular test-result pattern, called Pattern X, occurs in 80% of people with E, 50% with F, 20% with G, and 2% of those with none. Find the probability of each category after Pattern X.

Check the setup. The priors sum to \(0.01+0.04+0.15+0.80=1.00\), and each likelihood is for the same Pattern X. To make the arithmetic concrete, imagine 100,000 people with these modeled proportions. The category counts are 1,000, 4,000, 15,000, and 80,000.

Apply each likelihood to its category count. Pattern X is expected in \(1{,}000(0.80)=800\) people with E; \(4{,}000(0.50)=2{,}000\) with F; \(15{,}000(0.20)=3{,}000\) with G; and \(80{,}000(0.02)=1{,}600\) with none. The total with Pattern X is \(800+2{,}000+3{,}000+1{,}600=7{,}400\).

The posterior probabilities are the corresponding counts divided by 7,400:

$$ \begin{aligned} P(\text{E}\mid X)&=\frac{800}{7400}=0.1081\\ P(\text{F}\mid X)&=\frac{2000}{7400}=0.2703\\ P(\text{G}\mid X)&=\frac{3000}{7400}=0.4054\\ P(\text{none}\mid X)&=\frac{1600}{7400}=0.2162 \end{aligned} $$

Thus the modeled probability of Condition G after Pattern X is about 40.5%, the largest posterior among these four categories. The natural-frequency calculation is the same as multiplying each prior by its likelihood and dividing by the total weight; the counts simply make those operations visible.

Common Pitfalls and a Reliable Check

The most common denominator error is to divide by the likelihood for just one category, or to add likelihoods without weighting them by the priors. Neither gives the probability of the observed result across the whole population. The correct denominator is the sum of the prior-times-likelihood products across every category in the partition.

  • Do not confuse likelihoods with posteriors. \(P(R\mid D_i)\) asks how likely the result is within category \(D_i\); \(P(D_i\mid R)\) asks how likely the category is after the result.
  • Do not omit a relevant category. If the categories are not exhaustive, their weighted likelihoods will not account for all ways the result can occur.
  • Do not treat overlapping diagnoses as mutually exclusive. If categories can occur together, they are not a partition as stated. The model must represent the possible combinations as separate categories or be formulated differently.
  • Do not choose a category from the likelihood alone. The posterior depends on both the likelihood and the prior. A high likelihood can be outweighed by a sufficiently small prior.

A practical check is to verify that the priors sum to 1, that each likelihood refers to the observed result in the stated category, and that all category weights appear in the denominator. Then confirm that the posterior probabilities sum to 1 and that the final interpretation names the observed result and the diagnostic categories.

Key takeaway: With three or more mutually exclusive diagnostic categories, multiply each category’s prior probability by the likelihood of the observed result, add those products across all categories, and divide each product by that sum. The result is a complete set of posterior probabilities.

Check Your Understanding

For each question, focus on how the categories and likelihoods enter the calculation.

  1. A model has three exhaustive categories with priors 0.10, 0.30, and 0.60. For an observed result, their likelihoods are 0.80, 0.40, and 0.10. What is the overall probability of that result?
  2. Using the information in Question 1, calculate the posterior probability of the second category.
  3. Why must the denominator include a prior-times-likelihood product for every category in an exhaustive partition?
  4. A diagnostic result has likelihood 0.70 in one category and 0.20 in another. Can you determine which category has the larger posterior probability from those likelihoods alone? Explain.
  5. A model lists three diagnosis categories, but a person can belong to both the first and second categories. What condition needed for the formula as stated has not been met?