Premed · Premed · Statistics Biostatistics
Lecture 7: Conditional Probability and Bayes' Theorem
Statistics / Biostatistics
Learning Objectives
By the end of this lecture, students will be able to:
- Define and calculate conditional probability
- Apply the multiplication rule using conditional probabilities
- State and apply Bayes' theorem
- Use the law of total probability
- Apply Bayes' theorem to interpret diagnostic test results (positive and negative predictive values)
Lecture Content
I. Conditional Probability
Conditional probability is the probability of event A occurring given that event B has already occurred, defined as P(A|B) = P(A and B) / P(B), provided P(B) > 0. The "given" condition restricts the sample space to only those outcomes where B occurs. A crucial point is that P(A|B) is generally not equal to P(B|A). In clinical reasoning, P(disease | positive test) differs from P(positive test | disease), and confusing these two quantities is a very common error known as the prosecutor's fallacy or base-rate neglect.
Consider an example with 200 patients: 50 have diabetes, 30 have hypertension, and 10 have both. P(diabetes | hypertension) = P(both) / P(hypertension) = (10/200) / (30/200) = 10/30 = 0.333, while P(hypertension | diabetes) = (10/200) / (50/200) = 10/50 = 0.200. Although the same data are used, the two conditional probabilities are quite different.
II. Independence Revisited
Two events A and B are independent if and only if P(A|B) = P(A), or equivalently P(B|A) = P(B), which also means P(A and B) = P(A) * P(B). In plain terms, if knowing B occurred does not change the probability of A, the events are independent. In clinical data, exposures and outcomes are usually dependent -- indeed, the hypothesis being tested is often precisely whether a dependence exists.
III. The Law of Total Probability
If events B1, B2, ..., Bk form a partition of the sample space (meaning they are mutually exclusive and exhaustive), then the probability of any event A can be calculated as P(A) = P(A|B1)P(B1) + P(A|B2)P(B2) + ... + P(A|Bk)*P(Bk). This law allows the computation of the overall probability of A by conditioning on all possible scenarios.
As a clinical example, suppose three hospitals refer patients: Hospital 1 (40% of referrals), Hospital 2 (35%), and Hospital 3 (25%), with infection rates of 5%, 8%, and 3% respectively. The overall infection rate is 0.40(0.05) + 0.35(0.08) + 0.25(0.03) = 0.020 + 0.028 + 0.0075 = 0.0555, or 5.55%.
<image>A tree diagram illustrating the law of total probability. Three initial branches represent three referring hospitals with their proportions (40%, 35%, 25%). Each splits into "Infection" and "No infection" branches with respective probabilities. The terminal nodes show joint probabilities, and a summary box at the bottom sums the infection branches to obtain the total probability of infection (5.55%).</image>
IV. Bayes' Theorem
Bayes' theorem provides a way to "reverse" conditional probabilities. It is stated as P(B|A) = [P(A|B) P(B)] / P(A). Using the law of total probability to expand the denominator, this becomes P(B|A) = [P(A|B) P(B)] / [P(A|B) P(B) + P(A|B^c) P(B^c)]. The theorem updates prior beliefs with new evidence to obtain a posterior probability.
The components have specific names. P(B) is the prior probability, representing the probability of B before observing A. P(A|B) is the likelihood, representing the probability of observing A if B is true. P(B|A) is the posterior probability, the updated probability of B after observing A. P(A) is the marginal probability of A and serves as a normalizing constant.
V. Bayes' Theorem in Diagnostic Testing
The most important clinical application of Bayes' theorem is in diagnostic testing. Let D+ denote disease present, D- denote disease absent, T+ denote test positive, and T- denote test negative. Sensitivity equals P(T+ | D+), specificity equals P(T- | D-), and prevalence equals P(D+), which serves as the prior probability of disease.
The positive predictive value (PPV) is P(D+ | T+) = [Sensitivity Prevalence] / [Sensitivity Prevalence + (1 - Specificity) (1 - Prevalence)]. The negative predictive value (NPV) is P(D- | T-) = [Specificity (1 - Prevalence)] / [Specificity (1 - Prevalence) + (1 - Sensitivity) Prevalence].
The key insight is that PPV and NPV depend critically on disease prevalence. A high-sensitivity test applied to a low-prevalence population will produce many false positives and a low PPV. This is why screening tests must be carefully evaluated in the specific target population.
<image>A 2x2 contingency table for diagnostic testing. Rows: Test Positive, Test Negative. Columns: Disease Present (D+), Disease Absent (D-). Cells labeled: True Positive (TP), False Positive (FP), False Negative (FN), True Negative (TN). Marginal totals shown. Formulas for sensitivity (TP/(TP+FN)), specificity (TN/(TN+FP)), PPV (TP/(TP+FP)), and NPV (TN/(TN+FN)) are listed beside the table. Below, an arrow shows how Bayes' theorem connects sensitivity/specificity to PPV/NPV through prevalence.</image>
VI. Worked Example: Screening for a Rare Disease
Suppose a disease has a prevalence of 1% (P(D+) = 0.01), a test has sensitivity of 99% (P(T+ | D+) = 0.99) and specificity of 95% (P(T- | D-) = 0.95). What is the PPV?
The total probability of a positive test is P(T+) = (0.99)(0.01) + (0.05)(0.99) = 0.0099 + 0.0495 = 0.0594. Therefore, PPV = 0.0099 / 0.0594 = 0.167, or only 16.7%. Despite the test's excellent sensitivity, most positive results are false positives when prevalence is low. This counterintuitive result is one of the most important lessons in clinical biostatistics.
The implications are clear: confirmatory testing is essential after positive screening results, and the pre-test probability established through clinical judgment profoundly affects the interpretation of any test result.
VII. Prior and Posterior Probability in Clinical Reasoning
Clinicians implicitly use Bayesian reasoning every day. History and physical examination establish a pre-test (prior) probability, and diagnostic tests update this to a post-test (posterior) probability. Likelihood ratios provide another way to perform this update. The positive likelihood ratio is LR+ = Sensitivity / (1 - Specificity), and the negative likelihood ratio is LR- = (1 - Sensitivity) / Specificity. These convert pre-test odds to post-test odds via the formula: post-test odds = pre-test odds * likelihood ratio.
An LR+ greater than 10 or an LR- less than 0.1 is considered strong evidence for ruling in or ruling out disease, respectively.
<image>A Fagan nomogram (likelihood ratio nomogram). Three vertical axes: pre-test probability (left), likelihood ratio (center), and post-test probability (right). A line is drawn from a pre-test probability of 25% through a positive likelihood ratio of 10, landing on a post-test probability of approximately 77%. A second line from 25% through a negative likelihood ratio of 0.05 lands on approximately 2%. Labels explain each axis, and clinical interpretation is annotated at each endpoint.</image>
VIII. Common Pitfalls
Several cognitive errors plague clinical reasoning about conditional probability. Base-rate neglect occurs when clinicians ignore the prevalence when interpreting a positive test. Confusion of the inverse involves assuming that P(D+|T+) equals P(T+|D+). Overconfidence in single test results leads to decisions without considering the need for confirmatory testing. Ignoring pre-test probability means ordering tests without clinical indication, which inflates the false positive rate. A solid understanding of Bayes' theorem protects clinicians from all of these cognitive errors.


