The probability that two subsequent events will happen is a ratio compounded of the probability of the 1st and the probability of the 2d on supposition the 1st happens. (Bayes 1763)1
Suppose we know that an event \(A\) occurred and want calculate the probability that \(B\) also occurred. The conditional probability of \(B\) given \(A\) is \[
\Pr(B \given{} A) = \frac{\Pr(A \cap B)}{\Pr(A)}.
\tag{2.1}\] Note that this is well-defined only if \(\Pr(A) > 0\). Conditional probabilities given \(A\) are just probabilities where the original sample space \(\Omega\) has been replaced with an event \(A \subseteq \Omega\). Everything we have learned about probabilities applies to all of the conditional probabilities given the same event \(A\). Conditional probability is arguably the most important mathematical tool in epidemiology.
2.1 Contingency tables
In statistics, a contingency table classifies individuals by two discrete variables, one that defines the rows and one that defines the columns. Each cell in the table contains the number of individuals who are in the intersection of the corresponding categories of the row and column variables. These numbers are called cell counts. The margins of the table contain row or column totals.
2.1.1 2x2 tables
In epidemiology, a 2x2 table is a contingency table based on a binary exposure variable and a binary disease outcome. We denote exposure by \(X = 1\) and no exposure by \(X = 0\), and we denote disease by \(D = 1\) and no disease by \(D = 0\). The precise definition of “disease” depends on context. In descriptive epidemiology, \(D_i = 1\) might mean that person \(i\) is a prevalent case of disease. In analytic epidemiology, \(D_i = 1\) might mean that person \(i\) had an onset of disease in an interval \((t_\text{start}, t_\text{stop}]\) on a relevant time scale. We put exposure in the rows and disease in the columns,2 and the exposure and disease categories are ordered so that individuals with \(X = 1\) and \(D = 1\) go in the top left corner. This is the most common arrangement in epidemiologic research, but it is not universal.
Table 2.1 shows an example of a 2x2 table. There are \(a\) individuals with both exposure and disease, \(b\) individuals with exposure but not disease, \(c\) individuals with disease but no exposure, and \(d\) individuals with neither. In the rows, there are \(r_1 = a + b\) exposed individuals and \(r_0 = c + d\) unexposed individuals. In the columns, there are \(k_1 = a + c\) individuals who had a disease onset and \(k_0 = b + d\) individuals who did not. The row and column totals are called the margins of the table. The total number of individuals is \(n = a + b + c + d\).
Table 2.1: 2x2 table of exposure (\(X\)) and disease (\(D\)).
\(D = 1\)
\(D = 0\)
Total
\(X = 1\)
\(a\)
\(b\)
\(r_1 = a + b\)
\(X = 0\)
\(c\)
\(d\)
\(r_0 = c + d\)
Total
\(k_1 = a + c\)
\(k_0 = b + d\)
\(n = a + b + c + d\)
2.1.2 Joint and marginal probabilities
Here, we assume that Table 2.1 represents our entire population \(\Omega\) and our experiment is to randomly sample an individual \(\omega \in \Omega\) and measure their exposure status \(X(\omega)\) and their disease status \(D(\omega)\). Probabilities involving both \(X\) and \(D\) are called joint probabilities, and they can be calculated using the cell counts. In Table 2.1, the four joint probabilities are \[
\begin{aligned}
\Pr(X = 1 \text{ and } D = 1) &= a / n, \\
\Pr(X = 1 \text{ and } D = 0) &= b / n, \\
\Pr(X = 0 \text{ and } D = 1) &= c / n, \\
\Pr(X = 0 \text{ and } D = 0) &= d / n.
\end{aligned}
\] Together, these probabilities defined the joint distribution of the random variables \(X\) and \(D\) via their joint probability mass function (PMF).
Probabilities involving \(X\) or \(D\) alone are called marginal probabilities because they are calculated using the margins of the table. In Table 2.1, the marginal probabilities for exposure \(X\) are \[
\begin{aligned}
\Pr(X = 1) &= r_1 / n, \\
\Pr(X = 0) &= r_0 / n.
\end{aligned}
\] Together, these define the marginal distribution of \(X\), which is Bernoulli(\(r_1 / n\)). The marginal probabilities for disease \(D\) are \[
\begin{aligned}
\Pr(D = 1) &= k_1 / n, \\
\Pr(D = 0) &= k_0 / n.
\end{aligned}
\] Together, these define the marginal distribution of \(D\), which is Bernoulli(\(k_1 / n\)).
2.1.3 Conditional probabilities
Joint and marginal probabilities can be used to calculate conditional probabilities, which have a joint probability in the numerator and a marginal probability in the denominator. As before, we assume that Table 2.1 represents our entire population \(\Omega\) and our experiment is to randomly sample an individual \(\omega \in \Omega\) and measure \(X(\omega)\) and \(D(\omega)\). In Table 2.1, the conditional probability of disease given exposure is \[
\Pr(D = 1 \given{} X = 1)
= \frac{Pr(D = 1 \vand X = 1)}{\Pr(X = 1)}
= \frac{a / n}{r_1 / n}
= \frac{a}{r_1},
\] and the conditional probability of disease given no exposure is \[
\Pr(D = 1 \given{} X = 0)
= \frac{Pr(D = 1 \vand X = 0)}{\Pr(X = 0)}
= \frac{c / n}{r_0 / n}
= \frac{c}{r_0},
\] Similarly, the conditional probability of exposure given disease is \[
\Pr(X = 1 \given{} D = 1)
= \frac{\Pr(X = 1 \vand D = 1)}{\Pr(D = 1)}
= \frac{a / n}{k_1 / n}
= \frac{a}{k_1},
\] and the conditional probabilty of exposure given no disease is \[
\Pr(X = 1 \given{} D = 0)
= \frac{\Pr(X = 1 \vand D = 0)}{\Pr(D = 0)}
= \frac{b / n}{k_0 / n}
= \frac{b}{k_0}.
\] In all cases, the table total cancels out and we get a calculation in one row (for conditional probabilities given \(X\)) or one column (for conditional probabilities given \(D\)).
2.2 Multiplication of conditional probabilities
Equation 2.1 can be rearranged into \[
\Pr(A \cap B) = \Pr(B \given{} A) \Pr(A),
\tag{2.2}\] exactly as described by Bayes at the beginning of this chapter (if we let \(A\) be the “1st event” and \(B\) be the “2d”). This depends only on the definition of conditional probability in Equation 2.1, not on any assumptions about the relationship between the events \(A\) and \(B\). This multiplication rule for conditional probabilities extends to any number of events. For three events \(A\), \(B\), and \(C\) such that \(B \cap C\) and \(C\) have probabilities greater than zero, we have \[\begin{aligned}
\Pr(A \cap B \cap C)
&= \Pr(A \given{} B \cap C) \Pr(B \cap C) \\
&= \Pr(A \given{} B \cap C) \Pr(B \given{} C) \Pr(C).
\end{aligned}\] To ensure that all of these conditional probabilities are well-defined, we need \(B \cap C\) and \(C\) to have probabilities greater than zero. In practice, \(\Pr(A \given{} B \cap C)\) is usually written \(\Pr(A \given{} B, C)\).
2.2.1 Decision trees
Figure 2.1 shows an example of a decision tree. The root of the tree is on the left and the leaves of the tree are on the right. Each node where two or more branches meet represents a decision. In the example, the root represents the decision \(A\) or \(A^C\) (i.e., not \(A\)). The two nodes connected to the root each represent the decision \(B\) or \(B^C\) (i.e., not \(B\)). Each branch of the tree is labeled with the conditional probability of the branch given the event that it branches out from. Because of the multiplication rule for conditional probabilities, the probability of each leaf is equal to the product of the probabilities along the branches connecting it to the root.
Figure 2.1: A decision tree for events \(A\) and \(B\). The probability of each leaf is found by multiplying the probabilities along the branches leading from the leaf back to the root.
2.2.2 Independence of events
The events \(A\) and \(B\) are independent if \[
\Pr(A \cap B) = \Pr(A) \Pr(B).
\tag{2.3}\] When two events are independent, the occurrence (or not) of one event tells us nothing about whether the other event occurred: If \(\Pr(A) > 0\), equation Equation 2.3 is equivalent to \(\Pr(B \given{} A) = \Pr(B)\). If \(\Pr(B) > 0\), it is equivalent to \(\Pr(A \given{} B) = \Pr(A)\). If \(A\) and \(B\) are not independent, the occurrence of \(A\) contains information about the occurrence of \(B\) and vice versa.
Independence of events \(A\) and \(B\) implies that the events \(A\) and \(B^\comp\) are also independent: \[
\begin{aligned}
\Pr\bigl(A \cap B^\comp\bigr)
&= \Pr(A) - \Pr(A \cap B) \\
&= \Pr(A) - \Pr(A) \Pr(B) \\
&= \Pr(A) \big(1 - \Pr(B)\big) \\
&= \Pr(A) \Pr\bigl(B^\comp\bigr).
\end{aligned}
\] A similar argument shows that \(A^\comp\) and \(B\) are independent. Because \(A^\comp \cap B^\comp = (A \cup B)^\comp\) by DeMorgan’s laws (see Section 1.1.5), \[
\begin{aligned}
\Pr\bigl(A^\comp \cap B^\comp\bigr)
&= 1 - \Pr(A \cup B) \\
&= 1 - \Pr(A) - \Pr(B) - \Pr(A \cap B) \\\
&= 1 - \Pr(A) - \Pr(B) - \Pr(A) \Pr(B) \\
&= \big(1 - \Pr(A)\big) \big(1 - \Pr(B)\big) \\
&= \Pr\bigl(A^\comp\bigr) \Pr\bigl(B^\comp\bigr).
\end{aligned}
\] Therefore, independence of two events implies independence between any combination of themselves or their complements.
2.3 Sensitivity and specificity
In the epidemiology of screening and diagnostic tests, several of the most important concepts are conditional probabilities. If we classify disease status into diseased (\(D^+\)) and nondiseased (\(D^-\)) and the test result into positive (\(T^+\)) and negative (\(T^-\)), we have the four possible combinations Table 2.2.
Table 2.2: Disease status (\(D^+\)/\(D^-\)) and test result (\(T^+\)/\(T^-\)).
\(T^+\)
\(T^-\)
\(D^+\)
True positive
False negative
\(D^-\)
False positive
True negative
The sensitivity of a test is the conditional probability that the test is positive given that the individual tested has the disease: \[
\sens = \Pr(T^+ \given{} D^+).
\] The specificity of a test is the conditional probability that the test is negative given that the individual tested does not have the disease: \[
\spec = \Pr(T^- \given{} D^-).
\] In both cases, we are conditioning on the disease status of the individual being tested. These concepts were introduced by Yerushalmy (1947) in a comparison of different types of chest X-rays for tuberculosis case detection.
Maximizing either sensitivity or specificity alone does not necessarily lead to good screening or diagnostic test: A test where everyone tests positive has perfect sensitivity but zero specificity, and a test where everyone tests negative has perfect specificity but zero sensitivity. There is almost always a tradeoff where higher sensitivity leads to lower specificity and vice versa.
2.3.1 Example: Diabetes testing
Remein and Wilkerson (1961) describe an early study of diabetes screening conducted by the United States Public Health Service in Boston City Hospital between 1954 and 1957. They recruited early-morning patients who were not febrile or acutely ill. Those willing to participate gave urine and blood samples. Next, they were given a meal meant to approximate an average breakfast or light lunch (a sandwich, 5 grams of butter, 60 grams of cheese, and three filled cookies). After the meal, they gave further urine and blood samples at one, two, and three hours after eating. The samples were analyzed using four different blood tests and six different urine tests. Participants returned for a follow-up visit between 3 and 21 days after the screening tests, where a definitive diagnosis of diabetes was made using an oral glucose tolerance test and a physical examination according to criteria established by a group of experts.
A total of 595 participants completed both visits. Table 2.3 is a reconstruction of the data for the Somogyi-Nelson blood test based on the 580 participants (70 with diabetes and 510 without) who took the test at all four time points. In the table, a positive test is defined as a blood glucose concentration above 130 mg/dL (milligrams per deciliter).
Table 2.3: Sensitivity and specificity of the Somogyi-Nelson blood glucose test for diabetes where \(T^+\) corresponds to a concentration above 130 mg/dL.
## Table 2 from Remein and Wilkerson (Journal of Chronic Disease, 1961)# function to generate numbers based on sensitivity and specificityRWtable <-function(sens, spec, n1=70, n0=510) {# arguments: sensitivity, specificity,# n1 is number of diabetics, n0 is number of nondiabetics tp <-round(sens * n1) fp <-round((1- spec) * n0) tn <-round(spec * n0) fn <-round((1- sens) * n1)return(c(truepos = tp, falsepos = fp, trueneg = tn, falseneg = fn))}RWtable(0.443, 0.990) # before mealRWtable(0.786, 0.906) # one hour afterRWtable(0.643, 0.969) # two hours afterRWtable(0.486, 0.998) # three hours after
The tradeoff between sensitivity and sensitivity in choosing a clinical measurement cutoff to distinguish positive and negative tests can be seen using a receiver operating characteristic (ROC) curve (Lusted 1971a, 1971b; Swets 1988; Zweig and Campbell 1993). These curves were originally used in World War II to analyze the performance of radar systems locating ships and airplanes. They were applied to diagnostic tests in the late 1950s in the first attempt to automate the classification of Pap smears to detect cervical cancer (Bostrom, Sawyer, and Tolles 1959; Lusted 1984; Bengtsson and Malm 2014).
Each combination of a clinical measurement and a cutoff between positive and negative tests defines a diagnostic or screening test that has a sensitivity \(\sens \in [0, 1]\) and a specificity \(\spec \in [0, 1]\). The horizontal axis of an ROC curve plots \[
1 - \spec = \Pr(T^+ \given{} D^-),
\] and its vertical axis plots \(\sens = \Pr(T^+ \given{} D^+)\). The test corresponds to a point \((1 - \spec, \sens)\) in the unit square \([0, 1] \times [0, 1]\). The best tests correspond to points close to the top left corner \((0, 1)\), which represents a test with perfect specificity (so \(1 - \spec = 0\)) and perfect sensitivity.
For a sequence of cutoffs, a given clinical measurement produces a curve connecting the points produced by the tests based on it. Figure 2.2 shows four ROC curves based on data from Remein and Wilkerson (1961): one for the Somogyi-Nelson blood glucose measurement before the meal and one each for the measurements one, two, and three hours after the meal. For all four measurements, the curves are based on the combinations of sensitivity and specificity for glucose concentration cutoffs from 70 mg/dL to 200 mg/dL. In these tests, using a higher glucose concentration cutoff to define a positive test leads to lower sensitivity and higher specificity.
Figure 2.2: ROC curves for Somogyi-Nelson blood tests conducted before the meal and at 1-3 hours after the meal. Cutoff values for the before-meal curve are labeled, and the points corresponding to the 130 mg/dL cutoff along the curve for each blood glucose measurement are circled.
ROC curves for different clinical measurements can be compared using the area under the curve (AUC), which is the area between the x-axis \([0, 1]\) and the ROC curve. Greater AUC corresponds to a measurement that is better able to distinguish between disease and no disease (Bamber 1975; Hanley and McNeil 1982). For a test that is positive when a clinical measurement is above a given cutoff, the AUC is the probability that a person with disease has a higher value than a person without disease.3 In this example, it is the probability that a true diabetic has a higher blood glucose concentration than a true nondiabetic at the time blood glucose concentration is measured. A measurement that was always higher (or always lower) for individuals with disease than individuals without disease would have \(\text{AUC} = 1\). The AUCs in Figure 2.2 show clearly that the tests one and two hours after the meal, which have curves above and to the left of the other two curves, better distinguish between diabetics and nondiabetics than the tests before and three hours after the meal. This is biologically plausible: Before the meal, there is no glucose load. Three hours after the meal, the glucose from the meal has largely been absorbed.
## areas under the ROC curves# load Somogyi-Nelson test data generated for Figure 2.2 (if needed)# The argument can contain a path before the file name.SNdat <-read.csv("SNdat.csv")auc <-function(x, y) {# x is an increasing list of specificities# y is a decreasing list of sensitivities roc <-approxfun(c(1, 1- x, 0), c(1, y, 0), ties ="max") area <-integrate(function(x) roc(x), 0, 1)return(area)}auc(SNdat$spec_pre, SNdat$sens_pre)auc(SNdat$spec_1hr, SNdat$sens_1hr)auc(SNdat$spec_2hr, SNdat$sens_2hr)auc(SNdat$spec_3hr, SNdat$sens_3hr)
The test one hour after the meal with a 130 mg/dL cutoff has a good combination of sensitivity and specificity. It is near the top left corner, where perfect tests live. If a diagnostic test was completely useless, the test results (\(T^+\) or \(T^-\)) would be independent of disease status (\(D^+\) or \(D^-\)). In that case, \[
\Pr(T^+ \given{} D^+) = \Pr(T^+ \given{} D^-) = \Pr(T^+).
\] Thus, the ROC curve for a useless test follows the diagonal line from the lower left corner \((0, 0)\) to the upper right corner \((1, 1)\), and it has an AUC of 0.5. Tests below the diagonal on an ROC curve are worse than useless: the definitions of positive and negative should be reversed.
The sensitivity and specificity of a test tell us how accurate it is with a given definition of positive and negative. The ROC curve shows us how this accuracy depends on the cutoff between positive and negative tests, and the area under the curve shows us how well the underlying clinical measurement (e.g., blood glucose concentration) can distinguish between people with and without disease. However, the best cutoff for a test depends on its purpose, the population to be tested, and the benefit of identifying a true positive or negative versus the harm of a false positive or negative (Blumberg 1957; Kessel 1962).
2.4 Law of total probability
Suppose \(A_1, \ldots, A_n\) are disjoint events such that their union is \(\Omega\). This is called a partition of \(\Omega\). An important special case is when we partition \(\Omega\) into \(A\) and \(A^\comp\).
Let \(B\) be another event. Every \(\omega \in B\) is in exactly one of the \(A_i\). For each \(i\), \(B \cap A_i\) is the part of \(B\) that is contained in \(A_i\). The event \(B\) is the union of these subsets: \[
B = \bigcup_{i = 1}^n (B \cap A_i).
\] Because \(A_i\) are disjoint, so are the subsets \(B \cap A_i\). By the addition rule for probabilities of disjoint sets, we have \[
\Pr(B) = \sum_{i = 1}^n \Pr(B \cap A_i)
\] which is the sum of the \(\Pr(B \cap A_i)\).4 Using the multiplication rule for conditional probabilities in Equation 2.2 on each \(\Pr(B \cap A_i)\), we get \[
\Pr(B) = \sum_{i = 1}^n \Pr(B \given{} A_i) \Pr(A_i).
\] This is called the law of total probability.
2.4.1 Example: probability of a positive or negative test
We can use the law of total probability to calculate the probability of a positive or negative test based on the sensitivity and specificity of the test and the prevalence of disease. Because all individuals either do or do not have the disease,5 we have \[
T^+ = (T^+ \cap D^+) \cup (T^+ \cap D^-).
\] These two groups are mutually exclusive, so \[
\Pr(T^+) = \Pr(T^+ \cap D^+) + \Pr(T^+ \cap D^-).
\] We can calculate each probability on the right-hand side using the multiplication rule in Equation 2.2: \[
\begin{aligned}
\Pr(T^+ \cap D^+)
&= \Pr(T^+ \given{} D^+) \Pr(D^+)
= \text{sensitivity} \times \text{prevalence},\\
\Pr(T^+ \cap D^-)
&= \Pr(T^+ \given{} D^-) \Pr(D^-)
= (1 - \text{specificity}) \times (1 - \text{prevalence}).
\end{aligned}
\] Putting everything together, we get \[
\begin{aligned}
\Pr(T^+)
&= \Pr(T^+ \given{} D^+) \Pr(D^+) + \Pr(T^+ \given{} D^-) \Pr(D^-) \\
&= \text{sensitivity} \times \text{prevalence}
+ (1 - \text{specificity}) \times (1 - \text{prevalence}).
\end{aligned}
\tag{2.4}\] A similar chain of reasoning shows that \[
\Pr(T^-) = (1 - \text{sensitivity}) \times \text{prevalence} + \text{specificity} \times (1 - \text{prevalence}),
\] which equals \(1 - \Pr(T^+)\).
Figure 2.3 shows how the probability of a positive test depends on the prevalence of disease using the example of the Somogyi-Nelson test one hour after the meal in Table 2.3. With a cutoff of 130 mg/dL, the test has a sensitivity of 0.786 and a specificity of 0.906. At low prevalences, the test overestimates the prevalence of diabetes due to imperfect specificity. A high prevalences, it underestimates the prevalence of diabetes due to imperfect sensitivity. The errors cancel out somewhere near a prevalence of 30%.
Code
testpos.R
## probability of testing positive as a function of prevalence# function to generate testing datatdat <-function(prev, sens=0.786, spec=0.906) {# defaults are sensitivity and sensitivity one hour after the meal truepos <- sens * prev falsepos <- (1- spec) * (1- prev) trueneg <- spec * (1- prev) falseneg <- (1- spec) * prev pos <- truepos + falsepos neg <-1- pos ppv <- truepos / pos npv <- trueneg / negreturn(data.frame(prev = prev, sens = sens, spec = spec,truepos = truepos, falsepos = falsepos,trueneg = trueneg, falseneg = falseneg,pos = pos, neg = neg, ppv = ppv, npv = npv))}tdat_1hr <-tdat(seq(0, 1, by = .01))write.csv(tdat_1hr, "R/tdat_1hr.csv", row.names =FALSE)# plotplot(tdat_1hr$prev, tdat_1hr$pos, type ="n", xlim =c(0, 1), ylim =c(0, 1),xlab ="Prevalence of disease = Pr(D+)",ylab ="Probability of positive test = Pr(T+)")polygon(c(tdat_1hr$prev, 1, 0), c(tdat_1hr$pos, 0, 0),border =NA, col ="gray")polygon(c(tdat_1hr$prev, 1, 0), c(tdat_1hr$falsepos, 0, 0),border =NA, col ="darkgray")grid()lines(tdat_1hr$prev, tdat_1hr$falsepos, col ="gray")lines(tdat_1hr$prev, tdat_1hr$pos)abline(0, 1, lty ="dotted")text(0.1, 0.02, adj =c(0, 0), label ="False positives")text(0.2, 0.1, adj =c(0, 0), label ="True positives")
Figure 2.3: The probability of a positive Somogyi-Nelson diabetes test one hour after the meal as a function of the hypothetical prevalence of diabetes. The black dotted line shows the true prevalence of diabetes.
2.4.2 Standardization
In epidemiology, it is often useful to think of our sample space \(\Omega\) as a population and the outcomes \(\omega \in \Omega\) as individuals. The sets \(A_1, \ldots, A_n\) into which we partition the sample space are disjoint subpopulations (e.g., age groups). Let \(\Pr(D \given{} A_i)\) be the prevalence of disease in subpopulation \(A_i\) at a given time point. Then the overall prevalence of disease is \[
\Pr(D) = \sum_{i = 1}^n \Pr(D \given{} A_i) \Pr(A_i).
\tag{2.5}\] This application of the law of total probability is called standardization. By changing the \(\Pr(A_i)\), we can use the subpopulation prevalences to calculate the prevalence of disease in a population with any desired composition of subpopulations. Equation 2.5 can also be used to calculate population-level risk from the subpopulation-specific risks in any given time interval. In the form of standardization, the law of total probability is one of the most important tools in epidemiology.
2.5 Bayes’ rule
Bayes’ rule (Bayes 1763) relates the conditional probabilities \(\Pr(A \given{} B)\) and \(\Pr(B \given{} A)\): \[
\Pr(A \given{} B) = \frac{\Pr(B \cap A)}{\Pr(B)} = \frac{\Pr(B \given{} A) \Pr(A)}{\Pr(B)}.
\tag{2.6}\] In the denominator, the law of total probability is often used to calculate \(\Pr(B)\) via partitioning \(\Omega\) into \(A\) and \(A^\comp\). This gives us \[
\Pr(A \given{} B) = \frac{\Pr(B \given{} A) \Pr(A)}{\Pr(B \given{} A) \Pr(A) + \Pr(B \given{} A^\comp) \Pr(A^\comp)}.
\] Bayes’ rule is an incredibly useful application of conditional probabilities, and it forms the theoretical foundation for Bayesian statistical inference.
2.5.1 Positive and negative predictive values
Sensitivity and specificity tell us how disease status predicts the result of a test, but they do not tell us how to interpret a test result. If you test positive, it is important to know the conditional probability that you truly have disease given that you tested positive. This is called the positive predictive value (PPV): \[
\text{PPV} = \Pr(D^+ \given{} T^+).
\] If you test negative, it is important to know the conditional probability that you are truly disease-free given that you tested negative. This is called the negative predictive value (NPV): \[
\text{NPV} = \Pr(D^- \given{} T^-).
\] These terms were introduced by Vecchio (1966). Table 2.4 shows the PPV and NPV for the Somogyi-Nelson diabetes tests from Table 2.3.
Table 2.4: PPV and NPV of the Somogyi-Nelson blood glucose test for diabetes where \(T^+\) corresponds to a concentration above 130 mg/dL.
\(T^+\)
\(T^-\)
PPV and NPV
Before meal
\(D^+\)
31
39
\(\text{PPV} = 31 / 36 \approx 0.861\)
\(D^-\)
5
505
\(\text{NPV} = 505 / 544 \approx 0.928\)
Total
36
544
One hour after meal
\(D^+\)
55
15
\(\text{PPV} = 55 / 103 \approx 0.534\)
\(D^-\)
48
462
\(\text{NPV} = 462 / 477 \approx 0.969\)
Total
103
477
Two hours after meal
\(D^+\)
45
25
\(\text{PPV} = 45 / 61 \approx 0.738\)
\(D^-\)
16
494
\(\text{NPV} = 494 / 519 \approx 0.952\)
Total
61
519
Three hours after meal
\(D^+\)
34
36
\(\text{PPV} = 34 / 35 \approx 0.971\)
\(D^-\)
1
509
\(\text{NPV} = 509 / 545 \approx 0.934\)
Total
35
545
Vecchio (1966) showed that the PPV and NPV depend on the prevalence of disease as well as the sensitivity and specificity of the test. To calculate the PPV and NPV, we use Bayes’ rule to switch the conditional probabilities from \(\Pr(T \given{} D)\) to \(\Pr(D \given{} T)\). From the definition of PPV and Bayes’ rule, we get \[
\Pr(D^+ \given{} T^+)
= \frac{\Pr(T^+ \cap D^+)}{\Pr(T^+)}
= \frac{\Pr(T^+ \given{} D^+) \Pr(D^+)}{\Pr(T^+)}.
\] The sensitivity of the test and the prevalence of disease are in the numerator, and \(\Pr(T+)\) is in Equation 2.4. Putting this all together, we get \[
\text{PPV}
= \frac{\text{sensitivity} \times \text{prevalence}}{\text{sensitivity} \times \text{prevalence}
+ (1 - \text{specificity}) \times (1 - \text{prevalence})}.
\] The numerator is the probability of a true positive test, and the denominator is the probability of a (true or false) positive test. By a similar argument, \[
\text{NPV} = \frac{\text{specificity} \times (1 - \text{prevalence})}{\text{specificity} \times (1 - \text{prevalence})
+ (1 - \text{sensitivity}) \times \text{prevalence}}.
\label{eq:npv}
\] The numerator is the probability of a true negative test, and the denominator is the probability of a (true or false) negative test.
Figure 2.4 shows how the positive and negative predictive values of a test depend on the prevalence of disease for the Somogyi-Nelson test before the meal and one hour after the meal in Remein and Wilkerson (1961). With a cutoff of 130 mg/dL, the sensitivity and specificity are \(0.443\) and \(0.990\) before the meal and \(0.786\) and \(0.906\) one hour after the meal. If prevalence equals zero, the PPV is zero and the NPV equals one because no one has disease. As prevalence increases, PPV increases and NPV decreases. If the prevalence equals one, the PPV is one and the NPV is zero because everyone has disease. A perfect test would have PPV and NPV equal to one at all prevalences.
Code
predval.R
## Predictive values as a function of prevalence# uses tdat_1hr data and tdat() function from Figure 2.3 (testpos.R)# tdat_1hr <- read.csv("tdat_1hr.csv")# generate data using the sensitivity and specificity of the pre-meal testtdat_pre <-tdat(seq(0, 1, by = .01), sens =0.443, spec =0.990)# plot of PPV and NPV as a function of diabetes prevalenceplot(tdat_1hr$prev, tdat_1hr$ppv, type ="n", xlim =c(0, 1), ylim =c(0, 1),xlab ="Prevalence of disease = Pr(D+)",ylab ="Predictive value = Pr(D | T)")grid()lines(tdat_1hr$prev, tdat_1hr$ppv)lines(tdat_1hr$prev, tdat_1hr$npv, lty ="dashed")lines(tdat_pre$prev, tdat_pre$ppv, col ="darkgray")lines(tdat_pre$prev, tdat_pre$npv, lty ="dashed", col ="darkgray")legend("bottom", lty =c("solid", "dashed", "solid", "dashed"),col =c("darkgray", "darkgray", "black", "black"),bg ="white", inset =0.05,legend =c("PPV before meal", "NPV before meal","PPV 1 hour after", "NPV 1 hour after"))
Figure 2.4: Positive and negative predictive values of the Somogyi-Nelson diabetes test before the meal (gray) and one hour after the meal (black) as a function of diabetes prevalence.
2.5.2 Likelihood ratios*
For a probability \(p\), the odds is \[
\theta = \frac{p}{1 - p}.
\] While a probability lives in \([0, 1]\), the odds can go from zero (for \(p = 0\)) to infinity (as \(p\) approaches one). There is a one-to-one relationship between probabilities and odds, so we can calculate the probability of an event if we know the odds. If the odds is \(\theta\), the corresponding probability is \[
p = \frac{\theta}{1 + \theta}.
\] Odds and odds ratios have an important role in epidemiology and statistical inference. In a Bayesian statistical framework, odds ratios give us a simple way to update our knowledge about the probability of an event given new information.
Suppose we know the prevalence of a disease in a population \(\Omega\). We randomly sample an individual \(\omega \in \Omega\) and give them a diagnostic test. If we randomly sample an individual \(\omega\) from a population \(\Omega\), the odds that \(\omega\) has disease is \[
\frac{\Pr(D^+)}{1 - \Pr(D^+)}
= \frac{\Pr(D^+)}{\Pr(D^-)}.
\] where \(\Pr(D^+)\) is the prevalence of disease. This is called the prior odds of disease. If \(\omega\) tests positive for the disease, the conditional odds that they have disease is \[
\frac{PPV}{1 - PPV}
= \frac{\Pr(D^+ \given{} T^+)}{\Pr(D^- \given{} T^+)}
= \frac{\Pr(D^+ \cap T^+)}{\Pr(D^- \cap T^+)},
\] where we have cancelled out \(\Pr(T^+)\) from the numerator and the denominator in the last expression. This is called the posterior odds of disease. The second expression above shows that the probability corresponding to the posterior odds is the PPV.
Using the multiplication rule for conditional probabilities, we get \[
\frac{\Pr(D^+ \cap T^+)}{\Pr(D^- \cap T^+)}
= \frac{\Pr(T^+ \given D^+) \Pr(D^+)}{\Pr(T^+ \given D^-) \Pr(D^-)}
= \frac{\text{sensitivity}}{1 - \text{specificity}}
\times \frac{\Pr(D^+)}{\Pr(D^-)}.
\] The term \(\text{sensitivity} / (1 - \text{specificity})\) is called the likelihood ratio. If our individual \(\omega\) tests positive for disease, \[
\text{posterior odds of } D^+
= \text{likelihood ratio} \times \text{prior odds of } D^+.
\] The likelihood ratio is a measure of how much we learn from a positive test result, and it does not depend on the prevalence of disease [Lusted (1971b); Swets (1973); Fagan (1975); Albert (1982); Zweig and Campbell (1993)}. Because an ROC curve plots sensitivity on the vertical axis and \(1 - \text{specificity}\) on the horizontal axis, the likelihood ratio for a given test is the slope of the line from the point \((0, 0)\) to the point representing the test.
Table 2.5 shows the prior odds, likelihood ratio, posterior odds, and PPV for the Somogyi-Nelson blood glucose tests for diabetes from 580 participants (70 with diabetes and 510 without) in Remein and Wilkerson (1961). Note that the tests with the highest likelihood ratios come from the glucose measurements that had the lowest AUCs in Figure 2.2. These tests have high likelihood ratios despite their low sensitivity because they have specificities near one. The test with the best combination of sensitivity and specificity in Table 2.3 has the lowest likelhood ratio. Like other summaries of diagnostic test performance, the likelihood ratio by itself does not determine the best test for a given purpose.
Table 2.5: Prior odds, likelihood ratios, posterior odds, and PPV for the Somogyi-Nelson blood glucose test for diabetes where \(T^+\) corresponds to a concentration above 130 mg/dL.
Test
Prior odds
Likelihood ratio
Posterior odds
PPV
Before meal
\(70 / 510 \approx 0.137\)
45.171
\(31 / 5 = 6.200\)
\(31 / 36 \approx 0.861\)
1 hour after
\(70 / 510 \approx 0.137\)
8.348
\(55 / 48 \approx 1.146\)
\(55 / 103 \approx 0.534\)
2 hours after
\(70 / 510 \approx 0.137\)
20.491
\(45 / 16 \approx 2.813\)
\(45 / 61 \approx 0.738\)
3 hours after
\(70 / 510 \approx 0.137\)
247.714
\(34 / 1 = 34.000\)
\(34 / 35 \approx 0.971\)
Albert, Adelin. 1982. “On the Use and Computation of Likelihood Ratios in Clinical Chemistry.”Clinical Chemistry 28 (5): 1113–19.
Bamber, Donald. 1975. “The Area Above the Ordinal Dominance Graph and the Area Below the Receiver Operating Characteristic Graph.”Journal of Mathematical Psychology 12 (4): 387–415.
Bayes, Thomas. 1763. “LII. An Essay Towards Solving a Problem in the Doctrine of Chances. By the Late Rev. Mr. Bayes, FRS Communicated by Mr. Price, in a Letter to John Canton, AMFRS.”Philosophical Transactions of the Royal Society of London 53: 370–418.
Bengtsson, Ewert, and Patrik Malm. 2014. “Screening for Cervical Cancer Using Automated Analysis of PAP-Smears.”Computational and Mathematical Methods in Medicine 2014: 842037.
Blumberg, Mark S. 1957. “Evaluating Health Screening Procedures.”Operations Research 5 (3): 351–60.
Bostrom, RC, HS Sawyer, and WE Tolles. 1959. “Instrumentation for Automatically Prescreening Cytological Smears.”Proceedings of the IRE 47 (11): 1895–1900.
Fagan, Terrence J. 1975. “Nomogram for Bayes’s Theorem.”New England Journal of Medicine 293 (5): 257.
Hanley, James A, and Barbara J McNeil. 1982. “The Meaning and Use of the Area Under a Receiver Operating Characteristic (ROC) Curve.”Radiology 143 (1): 29–36.
Kessel, Elton. 1962. “Diabetes Detection: An Improved Approach.”Journal of Chronic Diseases 15 (12): 1109–21.
Lusted, Lee B. 1971a. “Decision-Making Studies in Patient Management.”New England Journal of Medicine 284 (8): 416–24.
———. 1971b. “Signal Detectability and Medical Decision-Making.”Science 171 (3977): 1217–19.
———. 1984. “ROC Recollected.”Medical Decision Making 4: 131–35.
Remein, Quentin R, and Hugh LC Wilkerson. 1961. “The Efficiency of Screening Tests for Diabetes.”Journal of Chronic Diseases 13 (1): 6–21.
Rothman, Kenneth J. 1981. “Induction and Latent Periods.”American Journal of Epidemiology 114 (2): 253–59.
Swets, John A. 1973. “The Relative Operating Characteristic in Psychology: A Technique for Isolating Effects of Response Bias Finds Wide Use in the Study of Perception and Cognition.”Science 182 (4116): 990–1000.
———. 1988. “Measuring the Accuracy of Diagnostic Systems.”Science 240 (4857): 1285–93.
Vecchio, Thomas J. 1966. “Predictive Value of a Single Diagnostic Test in Unselected Populations.”New England Journal of Medicine 274 (21): 1171–73.
Yerushalmy, Jacob. 1947. “Statistical Problems in Assessing Methods of Medical Diagnosis, with Special Reference to X-Ray Techniques.”Public Health Reports (1896-1970) 62 (40): 1432–49.
Zweig, Mark H, and Gregory Campbell. 1993. “Receiver-Operating Characteristic (ROC) Plots: A Fundamental Evaluation Tool in Clinical Medicine.”Clinical Chemistry 39 (4): 561–77.
Thomas Bayes (1701-1761) was an English Presbyterian minister from a family of Nonconformists (i.e., Protestants who did not observe the rules of the Church of England). He studied logic and theology at the University of Edinburgh and served as a minister in Tunbridge Wells near Kent, England. He was elected a Fellow of the Royal Society in 1742 for his defense of Newton’s calculus against a 1734 book called The Analyst: A Discourse Addressed to an Infidel Mathematician by Bishop George Berkeley (1685-1753). Late in life, Bayes became interested in probability and “inverse probability” (statistics). This essay was published posthumously, and it has had a profound effect on modern statistics.↩︎
This is partly to respect the linear algebra convention that rows come before columns in matrix indices, so \(M_{ij}\) is the entry in row \(i\) and column \(j\) of the matrix \(M\). In analytic epidemiology, exposure must occur before any disease that it causes, so we let the exposure define the rows.↩︎
For a test that is positive when a clinical measurement is below a given cutoff, it is the probability that a person with disease has a lower value than a person without disease. Bamber (1975) showed that the AUC is closely related to the Wilcoxon rank sum statistic for the null hypothesis that the diseased and nondiseased have the same distribution for the measurement on which the test is based.↩︎
The symbol \(\Sigma\), which is an upper-case Greek letter \(\sigma\) (sigma), stands for a sum. For products, we use \(\Pi\), which is an upper-case Greek letter \(\pi\) (pi).↩︎
Many diseases are complex processes (Rothman 1981), making any binary classification of disease status somewhat arbitrary. Here, we assume that we have an operational definition of disease status that allows a reasonable binary classification.↩︎