Sensitivity and specificity are statistical measures of the performance of a binary classification test that are widely used:
The terms “true positive”, “false positive”, “true negative”, and “false negative” refer to the result of a test and the correctness of the classification. For example, if the condition is a disease, “true positive” means “correctly diagnosed as diseased”, “false positive” means “incorrectly diagnosed as diseased”, “true negative” means “correctly diagnosed as not diseased”, and “false negative” means “incorrectly diagnosed as not diseased”. Thus, if a test's sensitivity is 97% and its specificity is 92%, its rate of false negatives is 3% and its rate of false positives is 8%. In a diagnostic test, sensitivity is a measure of how well a test can identify true positives. Sensitivity can also be referred to as the recall, hit rate, or true positive rate. It is the percentage, or proportion, of true positives out of all the samples that have the condition (true positives and false negatives). The sensitivity of a test can help to show how well it can classify samples that have the condition.
In a test, specificity is a measure of how well a test can identify true negatives. Specificity is also referred to as selectivity or true negative rate, and it is the percentage, or proportion, of the true negatives out of all the samples that do not have the condition (true negatives and false positives).
In a "good" test (one that attempts to identify with precision people who have the condition), the false positives should be very low. That is, people who are identified as having a condition should be highly likely to truly have the condition. This is because people who are identified as having a condition (but do not have it, in truth) may be subjected to: more testing (which could be expensive); stigma (e.g. HIV positive test); anxiety (e.g., I'm sick...I might die).
For all testing, both diagnostic and screening, there is a trade-off between sensitivity and specificity. Higher sensitivities will mean lower specificities and vice versa.
The terms "sensitivity" and "specificity" were introduced by American biostatistician Jacob Yerushalmy in 1947.^{[1]}
Sources: Fawcett (2006),^{[2]} Piryonesi and El-Diraby (2020),^{[3]} Powers (2011),^{[4]} Ting (2011),^{[5]} CAWCR,^{[6]} D. Chicco & G. Jurman (2020, 2021),^{[7]}^{[8]} Tharwat (2018).^{[9]} |
Imagine a study evaluating a test that screens people for a disease. Each person taking the test either has or does not have the disease. The test outcome can be positive (classifying the person as having the disease) or negative (classifying the person as not having the disease). The test results for each subject may or may not match the subject's actual status. In that setting:
After getting the numbers of true positives, false positives, true negatives, and false negatives, the sensitivity and specificity for the test can be calculated. If it turns out that the specificity is high then any person the test classifies as positive is likely to be a true positive. On the other hand, if the sensitivity is high then any person the test classifies as negative is likely to be a true negative. An NIH web site has a discussion of how these ratios are calculated.^{[10]}
Main article: Confusion matrix |
Consider a group with P positive instances and N negative instances of some condition. The four outcomes can be formulated in a 2×2 contingency table or confusion matrix, as well as derivations of several metrics using the four outcomes, as follows:
Predicted condition | ^{Sources:} ^{[11]}^{[12]}^{[13]}^{[14]}^{[15]}^{[16]}^{[17]}^{[18]} | ^{.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:100%}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}viewtalkedit} | ||||
Total population = P + N | Predicted condition positive (PP) |
Predicted condition negative (PN) |
Informedness, bookmaker informedness (BM) = TPR + TNR − 1 | Prevalence threshold (PT) = √TPR · FPR − FPR/TPR − FPR | ||
Actual condition positive (P) |
True positive (TP), hit |
False negative (FN), Type II error, miss, underestimation |
True positive rate (TPR), recall, sensitivity (SEN), probability of detection, hit rate, power = TP/P = 1 − FNR | False negative rate (FNR), miss rate = FN/P = 1 − TPR | ||
Actual condition negative (N) |
False positive (FP), Type I error, false alarm, overestimation |
True negative (TN), correct rejection |
False positive rate (FPR), probability of false alarm, fall-out = FP/N = 1 − TNR | True negative rate (TNR), specificity (SPC), selectivity = TN/N = 1 − FPR | ||
Prevalence = P/P + N | Positive predictive value (PPV), precision = TP/PP = 1 − FDR | False omission rate (FOR) = FN/PN = 1 − NPV | Positive likelihood ratio (LR+) = TPR/FPR | Negative likelihood ratio (LR−) = FNR/TNR | ||
Accuracy (ACC) = TP + TN/P + N | False discovery rate (FDR) = FP/PP = 1 − PPV | Negative predictive value (NPV) = TN/PN = 1 − FOR | Markedness (MK), deltaP (Δp) = PPV + NPV − 1 | Diagnostic odds ratio (DOR) = LR+/LR− | ||
Balanced accuracy (BA) = TPR + TNR/2 | F_{1} score = 2 · PPV · TPR/PPV + TPR = 2TP/2TP + FP + FN | Fowlkes–Mallows index (FM) = √PPV·TPR | Matthews correlation coefficient (MCC) = √TPR·TNR·PPV·NPV − √FNR·FPR·FOR·FDR |
Threat score (TS), critical success index (CSI) = TP/TP + FN + FP |
Consider the example of a medical test for diagnosing a condition. Sensitivity refers to the test's ability to correctly detect ill patients who do have the condition.^{[19]} In the example of a medical test used to identify a condition, the sensitivity (sometimes also named the detection rate in a clinical setting) of the test is the proportion of people who test positive for the disease among those who have the disease. Mathematically, this can be expressed as:
A negative result in a test with high sensitivity is useful for ruling out disease.^{[19]} A high sensitivity test is reliable when its result is negative, since it rarely misdiagnoses those who have the disease. A test with 100% sensitivity will recognize all patients with the disease by testing positive. A negative test result would definitively rule out presence of the disease in a patient. However, a positive result in a test with high sensitivity is not necessarily useful for ruling in disease. Suppose a 'bogus' test kit is designed to always give a positive reading. When used on diseased patients, all patients test positive, giving the test 100% sensitivity. However, sensitivity does not take into account false positives. The bogus test also returns positive on all healthy patients, giving it a false positive rate of 100%, rendering it useless for detecting or "ruling in" the disease.
The calculation of sensitivity does not take into account indeterminate test results. If a test cannot be repeated, indeterminate samples either should be excluded from the analysis (the number of exclusions should be stated when quoting sensitivity) or can be treated as false negatives (which gives the worst-case value for sensitivity and may therefore underestimate it).
Consider the example of a medical test for diagnosing a disease. Specificity relates to the test's ability to correctly reject healthy patients without a condition. Specificity of a test is the proportion of who truly do not have the condition who test negative for the condition. Mathematically, this can also be written as:
A positive result in a test with high specificity is useful for ruling in disease. The test rarely gives positive results in healthy patients. A positive result signifies a high probability of the presence of disease.^{[20]} A test with 100% specificity will recognize all patients without the disease by testing negative, so a positive test result would definitely rule in the presence of the disease. However, a negative result from a test with a high specificity is not necessarily useful for ruling out disease. For example, a test that always returns a negative test result will have a specificity of 100% because specificity does not consider false negatives. A test like that would return negative for patients with the disease, making it useless for ruling in disease.
A test with a higher specificity has a lower type I error rate.
The above graphical illustration is meant to show the relationship between sensitivity and specificity. The black, dotted line in the center of the graph is where the sensitivity and specificity are the same. As one moves to the left of the black, dotted line the sensitivity increases, reaching its maximum value of 100% at line A, and the specificity decreases. The sensitivity at line A is 100% because at that point there are zero false negatives, meaning that all the positive test results are true positives. When moving to the right, the opposite applies, the specificity increases until it reaches the B line and becomes 100% and the sensitivity decreases. The specificity at line B is 100% because the number of false positives is zero at that line, meaning all the negative test results are true negatives.
The middle solid line in both figures that show the level of sensitivity and specificity is the test cutoff point. Moving this line resulting in the trade-off between the level of sensitivity and specificity as previously described. The left-hand side of this line contains the data points that have the condition (the blue dots indicate the false negatives). The right-hand side of the line shows the data points that do not have the condition (red dots indicate false positives). The total number of data points is 80. 40 of them have a medical condition and are on the left side. The rest is on the right side and do not have the medical condition.
For the figure that shows high sensitivity and low specificity, the number of false negatives is 3, and the number of data point that has the medical condition is 40, so the sensitivity is (40 − 3) / (37 + 3) = 92.5%. The number of false positives is 9, so the specificity is (40 − 9) / 40 = 77.5%. Similarly, the number of false negatives in another figure is 8, and the number of data point that has the medical condition is 40, so the sensitivity is (40 − 8) / (37 + 3) = 80%. The number of false positives is 3, so the specificity is (40 − 3) / 40 = 92.5%.
The red dot indicates the patient with the medical condition. The red background indicates the area where the test predicts the data point to be positive. The true positive in this figure is 6, and false negatives of 0 (because all positive condition is correctly predicted as positive). Therefore the sensitivity is 100% (from 6 / (6 + 0)). This situation is also illustrated in the previous figure where the dotted line is at position A (the left-hand side is predicted as negative by the model, the right-hand side is predicted as positive by the model). When the dotted line, test cut-off line, is at position A, the test correctly predicts all the population of the true positive class, but it will fail to correctly identify the data point from the true negative class.
Similar to the previously explained figure, the red dot indicates the patient with the medical condition. However, in this case, the green background indicates that the test predicts that all patients are free of the medical condition. The number of data point that is true negative is then 26, and the number of false positives is 0. This result in 100% specificity (from 26 / (26 + 0)). Therefore, sensitivity or specificity alone cannot be used to measure the performance of the test.
In medical diagnosis, test sensitivity is the ability of a test to correctly identify those with the disease (true positive rate), whereas test specificity is the ability of the test to correctly identify those without the disease (true negative rate). If 100 patients known to have a disease were tested, and 43 test positive, then the test has 43% sensitivity. If 100 with no disease are tested and 96 return a completely negative result, then the test has 96% specificity. Sensitivity and specificity are prevalence-independent test characteristics, as their values are intrinsic to the test and do not depend on the disease prevalence in the population of interest.^{[21]} Positive and negative predictive values, but not sensitivity or specificity, are values influenced by the prevalence of disease in the population that is being tested. These concepts are illustrated graphically in this applet Bayesian clinical diagnostic model which show the positive and negative predictive values as a function of the prevalence, the sensitivity and specificity.
It is often claimed that a highly specific test is effective at ruling in a disease when positive, while a highly sensitive test is deemed effective at ruling out a disease when negative.^{[22]}^{[23]} This has led to the widely used mnemonics SPPIN and SNNOUT, according to which a highly specific test, when positive, rules in disease (SP-P-IN), and a highly 'sensitive' test, when negative rules out disease (SN-N-OUT). Both rules of thumb are, however, inferentially misleading, as the diagnostic power of any test is determined by both its sensitivity and its specificity.^{[24]}^{[25]}^{[26]}
The tradeoff between specificity and sensitivity is explored in ROC analysis as a trade off between TPR and FPR (that is, recall and fallout).^{[27]} Giving them equal weight optimizes informedness = specificity + sensitivity − 1 = TPR − FPR, the magnitude of which gives the probability of an informed decision between the two classes (> 0 represents appropriate use of information, 0 represents chance-level performance, < 0 represents perverse use of information).^{[28]}
The sensitivity index or d' (pronounced 'dee-prime') is a statistic used in signal detection theory. It provides the separation between the means of the signal and the noise distributions, compared against the standard deviation of the noise distribution. For normally distributed signal and noise with mean and standard deviations and , and and , respectively, d' is defined as:
An estimate of d' can be also found from measurements of the hit rate and false-alarm rate. It is calculated as:
where function Z(p), p ∈ [0, 1], is the inverse of the cumulative Gaussian distribution.
d' is a dimensionless statistic. A higher d' indicates that the signal can be more readily detected.
Fecal occult blood screen test outcome | ^{viewtalkedit} | ||||
Total population (pop.) = 2030 |
Test outcome positive | Test outcome negative | Accuracy (ACC) = (TP + TN) / pop.
= (20 + 1820) / 2030 ≈ 90.64% |
F_{1} score = 2 × precision × recall/precision + recall
≈ 0.174 | |
Patients with bowel cancer (as confirmed on endoscopy) |
Actual condition positive |
True positive (TP) = 20 (2030 × 1.48% × 67%) |
False negative (FN) = 10 (2030 × 1.48% × (100% − 67%)) |
True positive rate (TPR), recall, sensitivity = TP / (TP + FN)
= 20 / (20 + 10) ≈ 66.7% |
False negative rate (FNR), miss rate = FN / (TP + FN)
= 10 / (20 + 10) ≈ 33.3% |
Actual condition negative |
False positive (FP) = 180 (2030 × (100% − 1.48%) × (100% − 91%)) |
True negative (TN) = 1820 (2030 × (100% − 1.48%) × 91%) |
False positive rate (FPR), fall-out, probability of false alarm = FP / (FP + TN)
= 180 / (180 + 1820) = 9.0% |
Specificity, selectivity, true negative rate (TNR) = TN / (FP + TN)
= 1820 / (180 + 1820) = 91% | |
Prevalence = (TP + FN) / pop.
= (20 + 10) / 2030 ≈ 1.48% |
Positive predictive value (PPV), precision = TP / (TP + FP)
= 20 / (20 + 180) = 10% |
False omission rate (FOR) = FN / (FN + TN)
= 10 / (10 + 1820) ≈ 0.55% |
Positive likelihood ratio (LR+) = TPR/FPR
= (20 / 30) / (180 / 2000) ≈ 7.41 |
Negative likelihood ratio (LR−) = FNR/TNR
= (10 / 30) / (1820 / 2000) ≈ 0.366 | |
False discovery rate (FDR) = FP / (TP + FP)
= 180 / (20 + 180) = 90.0% |
Negative predictive value (NPV) = TN / (FN + TN)
= 1820 / (10 + 1820) ≈ 99.45% |
Diagnostic odds ratio (DOR) = LR+/LR−
≈ 20.2 |
Related calculations
This hypothetical screening test (fecal occult blood test) correctly identified two-thirds (66.7%) of patients with colorectal cancer.^{[a]} Unfortunately, factoring in prevalence rates reveals that this hypothetical test has a high false positive rate, and it does not reliably identify colorectal cancer in the overall population of asymptomatic people (PPV = 10%).
On the other hand, this hypothetical test demonstrates very accurate detection of cancer-free individuals (NPV ≈ 99.5%). Therefore, when used for routine colorectal cancer screening with asymptomatic adults, a negative result supplies important data for the patient and doctor, such as ruling out cancer as the cause of gastrointestinal symptoms or reassuring patients worried about developing colorectal cancer.
Sensitivity and specificity values alone may be highly misleading. The 'worst-case' sensitivity or specificity must be calculated in order to avoid reliance on experiments with few results. For example, a particular test may easily show 100% sensitivity if tested against the gold standard four times, but a single additional test against the gold standard that gave a poor result would imply a sensitivity of only 80%. A common way to do this is to state the binomial proportion confidence interval, often calculated using a Wilson score interval.
Confidence intervals for sensitivity and specificity can be calculated, giving the range of values within which the correct value lies at a given confidence level (e.g., 95%).^{[33]}
In information retrieval, the positive predictive value is called precision, and sensitivity is called recall. Unlike the Specificity vs Sensitivity tradeoff, these measures are both independent of the number of true negatives, which is generally unknown and much larger than the actual numbers of relevant and retrieved documents. This assumption of very large numbers of true negatives versus positives is rare in other applications.^{[28]}
The F-score can be used as a single measure of performance of the test for the positive class. The F-score is the harmonic mean of precision and recall:
In the traditional language of statistical hypothesis testing, the sensitivity of a test is called the statistical power of the test, although the word power in that context has a more general usage that is not applicable in the present context. A sensitive test will have fewer Type II errors.