Predictive Values and Bayes' Theorem

What a test result means for the person tested. Positive and negative predictive values read from a 2 x 2 table and derived from sensitivity, specificity and prevalence by Bayes' theorem; natural frequencies; why a positive result for a rare condition is often a false alarm, shown at prevalences from 0.5% to 50%; how far the theorem's predictions hold across age groups when sensitivity and specificity themselves vary; why a case-control study cannot give predictive values; and estimating true prevalence from an imperfect test with the Rogan-Gladen correction. Worked on HbA1c and fasting glucose in NHANES adults, with worked problems on a second cut-off, a population with a different prevalence, the prevalence needed for a given predictive value and the correction in two groups.

A test's predictive values, $P(D \mid T^+)$ and $P(D^c \mid T^-)$, follow from its sensitivity, specificity and the prevalence $\pi$ by Bayes' theorem, $\mathrm{PPV} = \pi\,\mathrm{Se}/[\pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp})]$, and the PPV rises and the NPV falls as the prevalence rises. For HbA1c at 6.5% against a fasting glucose of 126 mg/dL or more, in 1,975 undiagnosed NHANES 2017 to 2018 adults (prevalence 5.8%), the PPV is 0.684 and the NPV 0.968; at a prevalence of 0.5% the same test would have a PPV of 0.149. Predictions transfer to a subgroup only as far as sensitivity and specificity do: for adults aged 18 to 39 the predicted PPV is 0.364 and the observed 0.600. A case-control study cannot give predictive values, and the Rogan–Gladen prevalence correction fails where the error rates differ.

An adult without a diabetes diagnosis has a routine blood test, and the HbA1c comes back at 6.6%, above the American Diabetes Association's threshold of 6.5%. How likely is it that this person's fasting glucose is also in the diabetic range? Among adults like those of this unit the answer is about two chances in three: 54 of the 79 adults with a positive result.

Sensitivity and Specificity described the test from the other direction. Among the adults whose fasting glucose was 126 mg/dL or more, 47.0% had a positive HbA1c; among the rest, 98.7% had a negative one. Neither number answers the patient's question. The patient knows the test result, not the disease status, and needs a probability conditioned on the result. That probability is a predictive value. The two directions are the conditional probabilities $P(T^+ \mid D)$ and $P(D \mid T^+)$, which Conditional Probability and the Law of Total Probability showed can differ by a large factor. That article is also the home of Bayes' theorem, which this one applies to a test result.

First we read the predictive values off the 2 by 2 table. Then we rebuild them from sensitivity, specificity and prevalence by Bayes' theorem, and draw the same calculation as natural frequencies. Next we vary the prevalence and watch the meaning of a positive result change, and check the theorem's predictions on age groups of real adults. Finally we see what a case-control study cannot tell us, how to correct a prevalence estimated with an imperfect test, and why a diagnosis needs a second test.

The examples continue with the 1,975 adults of the National Health and Nutrition Examination Survey (NHANES) 2017 to 2018 who had no diabetes diagnosis. The test is HbA1c of 6.5% or more, and the reference standard is a fasting plasma glucose (FPG) of 126 mg/dL or more. The previous article explains that this "diabetes" is a definition based on one measurement.

Predictive values from the table

The 2 by 2 table of the previous article is repeated here:

HbA1c FPG $\ge$ 126 FPG $<$ 126 Total
$\ge 6.5\%$ 54 (TP) 25 (FP) 79
$< 6.5\%$ 61 (FN) 1,835 (TN) 1,896
Total 115 1,860 1,975

Sensitivity and specificity divide by column totals. The predictive values divide by row totals. The positive predictive value is the probability of the condition given a positive result,

$$\mathrm{PPV} = P(D \mid T^+) = \frac{\mathrm{TP}}{\mathrm{TP} + \mathrm{FP}} = \frac{54}{79} = 0.6835,$$

and the negative predictive value is the probability of no condition given a negative result,

$$\mathrm{NPV} = P(D^c \mid T^-) = \frac{\mathrm{TN}}{\mathrm{TN} + \mathrm{FN}} = \frac{1{,}835}{1{,}896} = 0.9678.$$

For the adult with an HbA1c of 6.6%, the answer is about two chances in three. A third of the positive results in this population belong to adults whose fasting glucose is below 126. (The 6.6% is treated here only as "positive"; Likelihood Ratios for Diagnostic Tests uses the value itself.)

Like sensitivity and specificity, these are proportions, and the Wilson intervals of Confidence Intervals for a Proportion apply. The PPV is 0.684 (0.575, 0.776) on 79 positives, and the NPV 0.9678 (0.9589, 0.9749) on 1,896 negatives.

There is a condition on reading predictive values straight from the table. The table must be a sample of the population in which the test is used, with cases and non-cases in their natural proportions, as in this cross-sectional sample. When it is not, the predictive values must be computed instead, by the theorem below.

Bayes' theorem for a test result

When only the behavior of the test and the frequency of the condition are known, Bayes' theorem gives the predictive values. Here is the idea in one sentence. Out of the whole population, work out the share who are true positives and the share who are false positives; the PPV is the first share over their sum.

The formal version. Three quantities describe a test in a population:

  • the prevalence $\pi = P(D)$;
  • the sensitivity $\mathrm{Se} = P(T^+ \mid D)$;
  • the specificity $\mathrm{Sp} = P(T^- \mid D^c)$.

The events $D$ and $D^c$ partition the population, so the law of total probability gives the probability of a positive result:

$$P(T^+) = P(D)\,P(T^+ \mid D) + P(D^c)\,P(T^+ \mid D^c) = \pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp}).$$

The definition of conditional probability, with the multiplication rule in the numerator, then gives Bayes' theorem in the form used for diagnostic tests:

$$\mathrm{PPV} = P(D \mid T^+) = \frac{P(D)\,P(T^+ \mid D)}{P(T^+)} = \frac{\pi\,\mathrm{Se}}{\pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp})}.$$

Here $P(T^+ \mid D^c) = 1 - \mathrm{Sp}$ by the complement rule for conditional probabilities, and the formula needs $P(T^+) > 0$.

For the negative predictive value the two steps are repeated with a negative result. Given the condition, a negative result is the complement of a positive one, so $P(T^- \mid D) = 1 - \mathrm{Se}$, and $P(T^- \mid D^c) = \mathrm{Sp}$ by definition. The law of total probability with the same partition gives the probability of a negative result:

$$P(T^-) = P(D)\,P(T^- \mid D) + P(D^c)\,P(T^- \mid D^c) = \pi\,(1 - \mathrm{Se}) + (1 - \pi)\,\mathrm{Sp}.$$

The definition of conditional probability, with the multiplication rule $P(D^c \cap T^-) = P(D^c)\,P(T^- \mid D^c)$ in the numerator, then gives

$$\mathrm{NPV} = P(D^c \mid T^-) = \frac{P(D^c)\,P(T^- \mid D^c)}{P(T^-)} = \frac{(1 - \pi)\,\mathrm{Sp}}{(1 - \pi)\,\mathrm{Sp} + \pi\,(1 - \mathrm{Se})},$$

provided $P(T^-) > 0$.

The numerator of the PPV is the share of the whole population that is a true positive. The second term of the denominator is the share that is a false positive. In the NPV the numerator is the share that is a true negative, and the second term of the denominator the share that is a false negative.

Back to the NHANES adults, with $\pi = 0.0582$, $\mathrm{Se} = 0.4696$ and $\mathrm{Sp} = 0.9866$. The true positives are $0.0582 \times 0.4696 = 0.02734$ of the population, and the false positives $0.9418 \times 0.0134 = 0.01266$. Together they are $P(T^+) = 0.04000$, which is $79/1{,}975$, and

$$\mathrm{PPV} = \frac{0.02734}{0.02734 + 0.01266} = 0.6835,$$

the value read from the table. For the negative result, the true negatives are $0.9418 \times 0.9866 = 0.92911$ of the population and the false negatives $0.0582 \times 0.5304 = 0.03089$. Together they are $P(T^-) = 0.96000$, which is $1{,}896/1{,}975$, and $\mathrm{NPV} = 0.92911/0.96000 = 0.9678$. (The products use the unrounded inputs.) On the population that produced the three inputs, the theorem simply reproduces the table. Its use is to transfer a test's sensitivity and specificity, measured in one study, to a population with a different prevalence. When the unknown is a parameter instead of a condition, the same theorem turns a prior distribution into a posterior one (Priors, Posteriors and Conjugate Families).

Natural frequencies

The same calculation is easier to follow in counts. Imagine 10,000 adults like these. At a prevalence of 5.8%, 582 have the condition and 9,418 do not. The test is positive in 47.0% of the 582, about 273 people, and in 1.34% of the 9,418, about 127. Of the 400 positives, 273 have the condition, a proportion of 0.68.

Bayes' theorem as natural frequencies for 10,000 adults with the NHANES prevalence of 5.8%; the first branches split by the reference standard, the second by the test. Notice that the PPV uses only the two positive leaves, 273 true and 127 false: it is the share of all positives that are true, 273 of 400.
Bayes' theorem as natural frequencies for 10,000 adults with the NHANES prevalence of 5.8%; the first branches split by the reference standard, the second by the test. Notice that the PPV uses only the two positive leaves, 273 true and 127 false: it is the share of all positives that are true, 273 of 400.

The tree is the law of total probability drawn as in the previous unit, scaled by 10,000. Gigerenzer and Hoffrage (1995) showed that the Bayesian computation is simpler in such frequency formats than with probabilities. Participants with no training in statistics reached the Bayesian answer far more often when a problem was posed in frequencies, for up to half of all their inferences.

Prevalence and the false alarm

The tree used the NHANES prevalence. What happens to the same test in a population where the condition is rarer, or more common? Sensitivity and specificity do not involve the prevalence, but the predictive values depend on it strongly.

Example (the same test where the condition is rare). Keep the test exactly as it is, and lower the prevalence from 5.8% to 0.5%. A positive result then no longer means the condition more often than not: it means it about one time in seven. Holding the test fixed and changing only $\pi$:

Prevalence PPV NPV Per 10,000: TP FP FN TN
0.5% 0.149 0.9973 23 134 27 9,816
2% 0.416 0.9891 94 132 106 9,668
5.8% (NHANES) 0.684 0.9678 273 127 309 9,291
20% 0.897 0.8815 939 108 1,061 7,892
50% 0.972 0.6503 2,348 67 2,652 4,933

When the condition is rare, almost everyone tested is free of it. Even a small false positive rate, applied to that large group, yields more false alarms than the true cases can supply. At a prevalence of 0.5%, the 1.34% false positive rate produces 134 false positives against 23 true ones, and a positive result means the condition with probability 0.15.

The table's pattern holds for every test with positive sensitivity and specificity.

Proposition. For a test with $\mathrm{Se} > 0$ and $\mathrm{Sp} > 0$, and a prevalence $0 < \pi < 1$, write $o = \pi/(1 - \pi)$ for the odds of the condition. Then

$$\mathrm{PPV} = \frac{1}{1 + \dfrac{1 - \mathrm{Sp}}{\mathrm{Se}} \cdot \dfrac{1}{o}}, \qquad \mathrm{NPV} = \frac{1}{1 + \dfrac{1 - \mathrm{Se}}{\mathrm{Sp}} \cdot o}.$$

So as the prevalence rises, the PPV rises if $\mathrm{Sp} < 1$ and the NPV falls if $\mathrm{Se} < 1$.

Proof. Divide the numerator and the denominator of the PPV formula by $\pi\,\mathrm{Se}$, and those of the NPV formula by $(1 - \pi)\,\mathrm{Sp}$. The odds $o = \pi/(1 - \pi)$ increase with $\pi$, since the numerator grows and the denominator shrinks. In the PPV the second term of the denominator is a positive constant times $1/o$, which decreases, so the PPV increases. In the NPV it is a positive constant times $o$, which increases, so the NPV decreases. $\square$

Written as odds, the PPV formula says that a positive result multiplies $o$ by $\mathrm{Se}/(1 - \mathrm{Sp})$. With two statistical models in place of the condition and its absence, the same rule defines the Bayes factor (Bayes Factors and Posterior Model Probabilities, Theorem 1).

Setting the PPV equal to a target $t$ and solving for the prevalence gives the prevalence at which the target is reached. From $t\,[\pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp})] = \pi\,\mathrm{Se}$, collecting the terms in $\pi$,

$$\pi = \frac{t\,(1 - \mathrm{Sp})}{(1 - t)\,\mathrm{Se} + t\,(1 - \mathrm{Sp})}.$$

For HbA1c the PPV reaches one half at a prevalence of 2.8%, and 0.9 at 20.5%.

The negative result moves the other way. It becomes more reassuring as the condition becomes rarer, and less so as it becomes common. At 50% prevalence a negative HbA1c still leaves a probability of 0.35 that the fasting glucose is in the diabetic range.

PPV and NPV of HbA1c at 6.5% as functions of prevalence (log scale), from Bayes' theorem with the overall sensitivity 0.470 and specificity 0.987. Follow the PPV curve leftward: it falls below one half at 2.8%. The markers, observed PPVs with 95% Wilson intervals in three age groups whose prevalences are 1.6%, 6.5% and 10.3%, rise less steeply than the curve.
PPV and NPV of HbA1c at 6.5% as functions of prevalence (log scale), from Bayes' theorem with the overall sensitivity 0.470 and specificity 0.987. Follow the PPV curve leftward: it falls below one half at 2.8%. The markers, observed PPVs with 95% Wilson intervals in three age groups whose prevalences are 1.6%, 6.5% and 10.3%, rise less steeply than the curve.

The common misreading has a name. Ignoring the prevalence when interpreting a positive result is called base-rate neglect. It treats $P(D \mid T^+)$ as if it were the sensitivity, or as if it were the specificity: "the test is 98.7% specific, so a positive result is 98.7% certain." It is the $P(A \mid B)$ against $P(B \mid A)$ confusion of the previous unit, and the base rate is what connects the two.

What a negative result says

Example (how much a negative result lowers the probability). Before testing, the probability of the condition is the prevalence, 0.0582. The NPV is 0.968, which sounds reassuring, but a negative HbA1c lowers the probability of the condition by a little under half. After a negative result it is $1 - \mathrm{NPV} = 61/1{,}896 = 0.0322$, a fall of 45%, to 0.55 times the prevalence. But most of the cases in the population (61 of 115) are among the negatives. A test with low sensitivity cannot rule a condition out, however high its NPV looks in a low-prevalence population.

The theorem within subgroups

The usual way to apply Bayes' theorem in practice is to take sensitivity and specificity from a published study, and combine them with the prevalence of the patient's own group. The NHANES data allow a test of that practice, and it holds only in part: the predicted negative predictive values are close to the observed ones, and the predicted positive predictive values are not. The prevalence of the condition rises with age, and each age group can be treated as a new population:

Age Prevalence Observed PPV (Wilson 95%) Bayes PPV Observed NPV Bayes NPV
18–39 12/743 = 0.0162 6/10 = 0.600 (0.313, 0.832) 0.364 727/733 = 0.9918 0.9913
40–59 41/628 = 0.0653 18/29 = 0.621 (0.440, 0.773) 0.709 576/599 = 0.9616 0.9638
60 and over 62/604 = 0.1026 30/40 = 0.750 (0.598, 0.858) 0.800 532/564 = 0.9433 0.9421

The negative predictive values agree closely. The positive ones move in the predicted direction, rising with prevalence, but by less than the theorem says. The young adults' PPV is higher than predicted, and the older adults' lower.

Part of the difference is sampling error, since the young group has only 10 positives and its interval is wide. Part is the lesson of the previous article: sensitivity and specificity are not constant across groups.

  • The young adults. Their specificity was 0.9945, so their false positive rate, 4 of 731 or 0.0055, was well under half the overall 0.0134. When the condition is rare the false positives come almost entirely from that rate, so the PPV is very sensitive to it. Their sensitivity, 0.500 against 0.470 overall, pushes the same way, but only slightly.
  • The two older groups. Their specificity was 0.981 to 0.982, below the overall value, and their PPVs fall short of the prediction.

Using the young adults' own sensitivity and specificity, the theorem gives their PPV exactly, 0.600, as it must. Their specificity rests on only 4 false positives, so the gap between 0.600 and 0.364 is a pattern to note rather than a precise measurement. Transferring accuracy from one population to another is only as good as the assumption that the test behaves the same way in both.

Example (a common misstatement: sensitivity and specificity do not depend on the population). The rule "predictive values depend on prevalence, sensitivity and specificity do not" is true of prevalence alone. Sensitivity and specificity do not change when the proportions of people with and without the condition change. They can still differ between populations whose cases, or whose non-cases, are of different kinds, as the specificities 0.9945 and 0.981 of the age groups show.

When predictive values cannot be read from a study

The previous article imitated a diagnostic case-control study. It took 264 diagnosed adults with high fasting glucose as cases and 444 young adults with normal glucose as controls.

Example (a predictive value that is not one). In that sample, 223 cases and 1 control were positive. The ratio $223/224 = 0.996$ is not the PPV of HbA1c in that setting, and it is not a predictive value of anything. The proportion of cases in the sample, $264/708 = 0.373$, was fixed by the investigator's choice of how many of each to recruit. The PPV depends on that proportion, as the prevalence table above shows. A case-control design can estimate sensitivity and specificity, with the spectrum caveats of the previous article, but not predictive values. To obtain them, the sensitivity and specificity must be combined by Bayes' theorem with a prevalence from another source. This is the diagnostic counterpart of the result in Relative Risk and the Odds Ratio that a case-control study cannot estimate a risk.

Estimating prevalence with an imperfect test

Surveys often estimate how common a condition is by testing a sample. An imperfect test then gives the wrong answer, and Bayes' arithmetic can partly repair it.

The proportion testing positive, the apparent prevalence, is by total probability

$$\pi_a = P(T^+) = \pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp}).$$

The equation is linear in $\pi$. Collecting the terms in $\pi$ gives $\pi_a = \pi\,(\mathrm{Se} + \mathrm{Sp} - 1) + (1 - \mathrm{Sp})$, and solving it, for a test with $\mathrm{Se} + \mathrm{Sp} \ne 1$, gives the estimator of Rogan and Gladen (1978):

$$\hat{\pi} = \frac{\pi_a - (1 - \mathrm{Sp})}{\mathrm{Se} + \mathrm{Sp} - 1} = \frac{\pi_a + \mathrm{Sp} - 1}{\mathrm{Se} + \mathrm{Sp} - 1}.$$

Its denominator is Youden's index, which ROC Curves for Diagnostic Tests uses to choose a threshold. In the NHANES adults the apparent prevalence of the condition by HbA1c is $79/1{,}975 = 0.0400$. The correction gives back the true 0.0582, as it must on the data that supplied $\mathrm{Se}$ and $\mathrm{Sp}$. Applied to the age groups with the overall sensitivity and specificity:

Age Apparent Corrected True
18–39 10/743 = 0.0135 0.0000 0.0162
40–59 29/628 = 0.0462 0.0718 0.0653
60 and over 40/604 = 0.0662 0.1157 0.1026

The correction moves the estimates of the two older groups the right way but overshoots. In the youngest it gives a prevalence of zero (0.00004 before rounding), for a group in which 1.6% have the condition. Two features of the estimator explain this.

  • It amplifies error. Dividing by $\mathrm{Se} + \mathrm{Sp} - 1 = 0.4561$ multiplies any error in the apparent prevalence by 2.2, including sampling error.
  • It subtracts the false positive rate. The numerator removes $1 - \mathrm{Sp} = 0.0134$ from the apparent prevalence, so an apparent prevalence at or below that rate gives an estimate of zero or less. The young adults' apparent prevalence, 0.0135, is barely above it. Their specificity, 0.9945, was higher than the overall value, so fewer of their positives were false than the correction assumed.

A negative estimate is truncated to zero in practice. The formula is reliable only when sensitivity and specificity are known for the population being surveyed. Language Models as Judges applies the same correction to scores graded by a language model, with its variance when the sensitivity and specificity are themselves estimated from a sample.

Example (a common misstatement: the corrected value is the true prevalence). The quantity $(\pi_a + \mathrm{Sp} - 1)/(\mathrm{Se} + \mathrm{Sp} - 1)$ is sometimes presented as "the true prevalence." It is an estimate, and it has two limits. It can fall outside the range from 0 to 1: for a test with $\mathrm{Se} + \mathrm{Sp} > 1$ it is negative when the apparent prevalence is below the false positive rate $1 - \mathrm{Sp}$, and above 1 when the apparent prevalence exceeds the sensitivity. And it equals the true prevalence only when the sensitivity and specificity used are those of the population surveyed, as the age groups above and Problem 4 below show.

Sequential testing

The ADA requires a second abnormal result to confirm a diagnosis in the absence of unequivocal hyperglycemia (ADA, 2025). The arithmetic of this article explains why. After one positive HbA1c in this population, the probability of the condition is 0.684. That probability is the "prevalence" in which the second test is interpreted. A confirmatory test with the same sensitivity and specificity, applied to the positives, would by Bayes' theorem raise the probability to

$$\frac{0.684 \times 0.4696}{0.684 \times 0.4696 + 0.316 \times 0.0134} = 0.987,$$

if its errors were independent of the first test's within each disease group. That condition is strong, because repeating the same test on the same person tends to repeat its errors.

Summary

Quantity Formula
Positive predictive value $P(D \mid T^+) = \mathrm{TP}/(\mathrm{TP} + \mathrm{FP}) = \pi\,\mathrm{Se} / [\pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp})]$
Negative predictive value $P(D^c \mid T^-) = \mathrm{TN}/(\mathrm{TN} + \mathrm{FN}) = (1 - \pi)\,\mathrm{Sp} / [(1 - \pi)\,\mathrm{Sp} + \pi\,(1 - \mathrm{Se})]$
Probability of a positive result $P(T^+) = \pi\,\mathrm{Se} + (1 - \pi)(1 - \mathrm{Sp})$
Corrected prevalence (Rogan–Gladen) $\hat\pi = (\pi_a + \mathrm{Sp} - 1)/(\mathrm{Se} + \mathrm{Sp} - 1)$
Prevalence at which $\mathrm{PPV} = t$ $\pi = t\,(1 - \mathrm{Sp})/[(1 - t)\,\mathrm{Se} + t\,(1 - \mathrm{Sp})]$

Worked problems

These problems are posed on the unit's own data, the 1,975 NHANES adults, and each is solved from the results above; none is taken from the course text. Unless a problem says otherwise, the test is HbA1c at 6.5%, with sensitivity 0.4696 and specificity 0.9866. The script recomputes every number.

Problem 1. At the lower cut-off of 6.0%, HbA1c is positive in 86 of the 115 adults with the condition and in 217 of the 1,860 without. Find the predictive values from the table, rebuild the PPV with Bayes' theorem, and compare both values with those at 6.5%.

From the table. There are $86 + 217 = 303$ positives and $29 + 1{,}643 = 1{,}672$ negatives, so

$$\mathrm{PPV} = \frac{86}{303} = 0.2838, \qquad \mathrm{NPV} = \frac{1{,}643}{1{,}672} = 0.9827.$$

The Wilson 95% interval for the PPV is $(0.236,\ 0.337)$.

By Bayes' theorem. The sensitivity is $86/115 = 0.7478$ and the false positive rate $217/1{,}860 = 0.1167$. The true positives are $0.0582 \times 0.7478 = 0.04354$ of the population and the false positives $0.9418 \times 0.1167 = 0.10987$ (products of the unrounded inputs). Their sum is $P(T^+) = 0.15342$, which is $303/1{,}975$, and

$$\mathrm{PPV} = \frac{0.04354}{0.04354 + 0.10987} = 0.2838.$$

The comparison. Lowering the cut-off raises the sensitivity from 0.470 to 0.748 and the NPV from 0.9678 to 0.9827: after a negative result the probability of the condition is 0.0173 instead of 0.0322. The price is in the positive results. At 6.5% two positives in three have the condition, and at 6.0% fewer than three in ten do, because the false positive rate is nearly nine times as large (0.1167 against 0.0134) and applies to the 94% of adults who do not have the condition.

Problem 2. The same test is used in a population where 10% of adults have the condition. Find the PPV and the NPV, and lay the calculation out for 10,000 adults.

In probabilities. With $\pi = 0.10$,

$$\mathrm{PPV} = \frac{0.10 \times 0.4696}{0.10 \times 0.4696 + 0.90 \times 0.0134} = \frac{0.04696}{0.04696 + 0.01210} = 0.7952,$$

$$\mathrm{NPV} = \frac{0.90 \times 0.9866}{0.90 \times 0.9866 + 0.10 \times 0.5304} = \frac{0.88790}{0.88790 + 0.05304} = 0.9436.$$

The terms are shown to five places, and the quotients are computed from the unrounded terms.

In natural frequencies. Of 10,000 adults, 1,000 have the condition and 9,000 do not. The test is positive in 47.0% of the 1,000, about 470, and negative in the other 530. It is positive in 1.34% of the 9,000, about 121, and negative in the other 8,879. So there are $470 + 121 = 591$ positives, of whom 470 have the condition, a share of 0.795, and $530 + 8{,}879 = 9{,}409$ negatives, of whom 8,879 do not, a share of 0.9437. The last digit differs from the exact 0.9436 because the counts are rounded to whole people.

Compared with the NHANES prevalence of 5.8%, the PPV is higher (0.795 against 0.684) and the NPV lower (0.944 against 0.968), the directions the proposition above requires.

Problem 3. A clinic wants a positive HbA1c to mean the condition at least four times in five. In what populations does the test achieve that?

By the proposition the PPV rises with the prevalence, so the answer is every population whose prevalence is at least the value at which the PPV equals 0.8. With $t = 0.8$ in the formula for that prevalence,

$$\pi = \frac{0.8 \times 0.0134}{0.2 \times 0.4696 + 0.8 \times 0.0134} = \frac{0.01075}{0.09391 + 0.01075} = 0.10273.$$

So the prevalence must be at least 10.27%. No NHANES age group quite reaches it. The oldest, adults aged 60 and over, comes closest, with a prevalence of $62/604 = 0.10265$, just below the threshold. Bayes' theorem gives that group a PPV of 0.7999, which rounds to the 0.800 of the age table but falls short of 0.8. The observed PPV in that group was 0.750, lower still because the group's own specificity is lower than the overall value. A threshold computed from the overall sensitivity and specificity is only as good as their transfer to the group.

Problem 4. Of the 1,975 adults, 1,942 have a body mass index (BMI) on record: 731 with a BMI of 30 or more, of whom 51 have a positive HbA1c, and 1,211 with a BMI below 30, of whom 26 do. Estimate the prevalence of the condition in each group with the Rogan–Gladen correction, using the overall sensitivity and specificity. Then compare the estimates with the true prevalences, 71 of 731 and 42 of 1,211.

The corrections. The apparent prevalences are $51/731 = 0.0698$ and $26/1{,}211 = 0.0215$. With $1 - \mathrm{Sp} = 0.0134$ and $\mathrm{Se} + \mathrm{Sp} - 1 = 0.4561$,

$$\hat\pi_{\ge 30} = \frac{0.0698 - 0.0134}{0.4561} = 0.1235, \qquad \hat\pi_{< 30} = \frac{0.0215 - 0.0134}{0.4561} = 0.0176.$$

(The quotients are computed from unrounded values; the rounded ones shown give 0.124 and 0.018.)

The comparison.

Group Apparent Corrected True Sensitivity in the group Specificity in the group
BMI $\ge 30$ 0.0698 0.1235 71/731 = 0.0971 36/71 = 0.5070 645/660 = 0.9773
BMI $< 30$ 0.0215 0.0176 42/1,211 = 0.0347 16/42 = 0.3810 1,159/1,169 = 0.9914

In the group with a BMI of 30 or more the correction moves the estimate the right way and overshoots, from 0.0698 past the true 0.0971 to 0.1235. In the other group it moves the estimate the wrong way, from 0.0215 down to 0.0176, when the truth is 0.0347. The last two columns say why. The correction assumes a false positive rate of 0.0134 and a sensitivity of 0.4696 in both groups. In the first group the false positive rate is $15/660 = 0.0227$, so more of the positives are false than the correction removes, and the sensitivity, 0.5070, is higher than assumed, so the test finds more of the cases than the correction allows for. Both push the estimate up. Putting right one assumption at a time shows their sizes: with the group's own false positive rate and the overall sensitivity the estimate is 0.1053, and with the group's own sensitivity and the overall specificity it is 0.1141, against 0.1235 with neither and the true 0.0971 with both. In the second group the sensitivity is only 0.3810, so the test finds fewer of the cases than the correction assumes, and the false positive rate is $10/1{,}169 = 0.0086$, so the correction removes too much. Both push the estimate down: with the group's own false positive rate alone it is 0.0280, and with its own sensitivity alone 0.0218, against 0.0176 with neither and the true 0.0347 with both. That the estimate falls below the apparent prevalence at all has a simple cause. With the overall sensitivity and specificity, the correction leaves an apparent prevalence of $(1 - \mathrm{Sp})/(2 - \mathrm{Se} - \mathrm{Sp}) = 0.0247$ unchanged, raises every larger one and lowers every smaller one, and 0.0215 is smaller. With each group's own sensitivity and specificity the formula returns the true prevalence exactly, as it must, and the script confirms it.

What we have learned

The adult with an HbA1c of 6.6% has about a two-in-three chance of a diabetic fasting glucose in this population, 54 of 79 positives. Bayes' theorem rebuilds that number from sensitivity, specificity and prevalence. It also shows that at a prevalence of 0.5% the same test would mean the condition only 15% of the time. False alarms from the large healthy group swamp the few true cases. The theorem's predictions hold within age groups only as well as the test's accuracy is constant across them, and a case-control study cannot supply predictive values at all.

The probability form of the theorem mixes what describes the patient (the prevalence) with what describes the test. Likelihood Ratios for Diagnostic Tests separates the two and writes sequential testing as a chain of multiplications. It also measures how far the independence assumption behind the 0.987 above fails for two real measurements.

In Python

def ppv(prev, se, sp):
    return prev * se / (prev * se + (1 - prev) * (1 - sp))

def npv(prev, se, sp):
    return (1 - prev) * sp / ((1 - prev) * sp + prev * (1 - se))

se, sp = 54 / 115, 1835 / 1860                 # HbA1c >= 6.5% against FPG >= 126 mg/dL
for prev in (0.005, 0.02, 115 / 1975, 0.2, 0.5):
    print(f'{prev:.3f}  PPV {ppv(prev, se, sp):.3f}  NPV {npv(prev, se, sp):.4f}')

Every number in this article is computed by tools/experiments/applied-statistics/predictive-values-and-bayes-theorem.py in the site's repository, from the NHANES files loaded by screendata.py.

References

  • American Diabetes Association Professional Practice Committee (2025). 2. Diagnosis and classification of diabetes: Standards of Care in Diabetes–2025. Diabetes Care, 48(Suppl. 1), S27–S49. https://doi.org/10.2337/dc25-S002 record · 7 pages
  • Gigerenzer, G., and Hoffrage, U. (1995). How to improve Bayesian reasoning without instruction: Frequency formats. Psychological Review, 102(4), 684–704. record
  • National Center for Health Statistics (2020). National Health and Nutrition Examination Survey 2017–2018: DEMO_J, DIQ_J, GLU_J and GHB_J data files. Centers for Disease Control and Prevention. https://wwwn.cdc.gov/nchs/nhanes/continuousnhanes/default.aspx?BeginYear=2017 record · 109 pages
  • Pagano, M., Gauvreau, K., and Mattie, H. (2022). Principles of Biostatistics (3rd ed.). CRC Press. The course text. record · 48 pages
  • Rogan, W. J., and Gladen, B. (1978). Estimating prevalence from the results of a screening test. American Journal of Epidemiology, 107(1), 71–76. record · 2 pages

Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 7 revisions