Untitled
Sensitivity, Specificity, and the 2x2 Contingency Table
- Key definitions
- Sensitivity (true positive rate): the probability that the test is positive given the person is infected.
- Specificity (true negative rate): the probability that the test is negative given the person is not infected.
- False positive rate:
- False negative rate:
- The 2x2 contingency table perspective
- Rows typically correspond to actual infection status: Infected (I) vs Not Infected (¬I)
- Columns correspond to test result: Positive (+) vs Negative (−)
- The four cells: TP, FP, FN, TN
- How to fill the table for a theoretical population (example uses 10,000 people)
- Given: Infection prevalence (base rate) and test characteristics (Se, Sp)
- Step 1: Compute counts by status
- Infected:
- Not infected:
- Step 2: Fill TP and FN using sensitivity
- Step 3: Fill TN and FP using specificity
- Step 4: Column margins (total positives, total negatives)
- Worked example 1: HIV test in the United States (low prevalence)
- Given values
- Total population: 10,000
- Prevalence (base rate):
- Infected: ; Not infected:
- Sensitivity: ; Specificity: ; False positive rate:
- Cell counts
- True positives:
- False negatives:
- True negatives:
- False positives:
- Margins
- Total positives:
- Total negatives:
- Probabilities of interest
- Positive Predictive Value (PPV):
- Interpretation: among those who test positive, about 6.01% are actually infected.
- Proportion infected among positives: same as PPV, ≈ 0.0601 (6.01%).
- Proportion not infected among positives (false positives proportion): (≈ 93.99%).
- Probability of infection among those who test negative: (≈ 0.089%).
- Probability that a negative result is actually infected is very low; conversely, a positive result is often a false positive when prevalence is very low.
- Note on interpretation in exam context
- Even with decent sensitivity and specificity, very low prevalence yields a low PPV; the test is not very useful for ruling in disease in a population with low base rate.
- Worked example 2: South Africa vs USA comparison (higher prevalence)
- South Africa (Eswatini-like scenario) base rate:
- Population: 10,000
- Infected: ; Not infected:
- Same test characteristics:
- Cell counts
- TP:
- FN:
- TN:
- FP:
- Margins
- Total positives:
- Total negatives:
- Conditional probabilities for positives
- PPV:
- About 87.8% of positive tests are true positives in this higher-prevalence setting.
- Proportion of positives that are not infected: (≈ 12.34%).
- Conditional probabilities for negatives
- Probability a negative is infected:
- Very small, but nonzero depending on prevalence.
- Takeaway from SA vs USA
- Higher prevalence improves PPV substantially; the same test yields far more reliable positives in high-prevalence populations.
- Summary formulas to remember (for any base rate p, Se, Sp)
- True positives:
- False negatives:
- True negatives:
- False positives:
- Positive test count:
- Negative test count:
- Positive Predictive Value:
- Probability that a positive is infected: same as PPV
- Probability that a negative is infected:
- Probability that a negative is not infected (NPV):
- Connecting to two-categorical-variable problems (the unemployment/degree example)
- Given a population of 10,000 with two categories in one variable (degree) and a second variable (unemployment)
- Base rates (marginals)
- No college degree: → counts:
- College degree: → counts:
- Conditional probabilities for unemployment within each degree group
- Among NoDeg, unemployed proportion: → unemployed count:
- Among College, unemployed proportion: → unemployed count:
- Margins and totals
- Unemployed total:
- Employed total:
- NoDeg unemployed proportion among unemployed:
- College unemployed proportion among unemployed:
- Overall unemployment rate in the year:
- Additional checks
- Unemployed given NoDeg: (given in data)
- Unemployed given College: (given in data)
- Practical interpretation tips for exam problems
- Do not round intermediate results before finishing the table
- Always start with the base rate (prevalence) before applying sensitivity and specificity
- When asked about predictive values, express results as probabilities (or percentages) and interpret in context
- Be careful about what the numerator and denominator represent when forming probabilities from a contingency table (A ∩ B vs A given B, etc.)
- Optional exercise references mentioned in the material
- Houston flights example (page 55 of notes) as a similar probability exercise
- A follow-up exercise: a second, non-medical two-category probability example using a 10,000-person hypothetical
- Brief note on the broader concepts discussed
- Statistical model vs statistic: a model is a mathematical description of data generation; a statistic is a summary value computed from a sample to estimate a model parameter
- Independence model: two categorical variables A and B are independent if the value of A does not affect the distribution of B; e.g., weather vs day of week independence can be explored with simulations
- The goal of these exercises is to develop intuition for how probabilities propagate through a model and how base rates influence decision-making in diagnostics and policy