How to Calculate Sensitivity and Specificity: With Examples

Sensitivity and specificity each require four numbers from a 2×2 table: true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). Once you have those counts, the formulas are straightforward. Sensitivity = TP ÷ (TP + FN). Specificity = TN ÷ (TN + FP). Both results are expressed as percentages or decimals between 0 and 1.

What Each Term Means

Before plugging numbers into formulas, you need to understand the four possible outcomes when a test is compared against a confirmed diagnosis (the “gold standard”).

  • True positive (TP): The test says positive, and the person truly has the condition.
  • False positive (FP): The test says positive, but the person is actually healthy.
  • True negative (TN): The test says negative, and the person is truly healthy.
  • False negative (FN): The test says negative, but the person actually has the condition.

Sensitivity measures how well a test catches people who are sick. It answers: “Of everyone who actually has the condition, what percentage did the test correctly identify?” Specificity measures how well a test identifies people who are healthy. It answers: “Of everyone who is actually free of the condition, what percentage did the test correctly call negative?”

Setting Up the 2×2 Table

The standard way to organize your data is a 2×2 contingency table. Rows represent the test result (positive or negative), and columns represent the true condition status (has the disease or doesn’t). Here’s the layout:

  • Top-left cell (A): True positives
  • Top-right cell (B): False positives
  • Bottom-left cell (C): False negatives
  • Bottom-right cell (D): True negatives

Adding margin totals helps you check your work. The left column total (A + C) equals everyone who truly has the condition. The right column total (B + D) equals everyone who is truly healthy. The grand total (A + B + C + D) is your entire sample.

The Formulas

Sensitivity looks only at the left column of the table, the people who truly have the condition:

Sensitivity = TP ÷ (TP + FN), or using table letters, A ÷ (A + C)

Specificity looks only at the right column, the people who are truly healthy:

Specificity = TN ÷ (TN + FP), or D ÷ (B + D)

Notice that each formula uses only one column. Sensitivity ignores the healthy people entirely, and specificity ignores the sick people entirely. This is why the two metrics are considered characteristics of the test itself rather than reflections of how common the disease is in the population.

Worked Example

Suppose you’re evaluating a rapid strep test. You test 200 patients and compare each result to a throat culture (the gold standard). The results:

  • True positives (TP): 72 patients tested positive and truly had strep.
  • False positives (FP): 8 patients tested positive but didn’t have strep.
  • False negatives (FN): 18 patients tested negative but actually had strep.
  • True negatives (TN): 102 patients tested negative and were truly strep-free.

Sensitivity = 72 ÷ (72 + 18) = 72 ÷ 90 = 0.80, or 80%. The test correctly identified 80% of the people who actually had strep. That means 20% of true strep cases were missed.

Specificity = 102 ÷ (102 + 8) = 102 ÷ 110 = 0.927, or about 93%. The test correctly identified 93% of the people who were strep-free. About 7% of healthy people received a false alarm.

The Trade-Off Between the Two

For many tests, especially those that use a numeric cutoff (blood sugar level, tumor marker concentration, blood pressure reading), sensitivity and specificity move in opposite directions when you shift the threshold. Lower the cutoff to catch more true cases and you’ll also flag more healthy people by mistake. Raise the cutoff to reduce false alarms and you’ll inevitably miss some true cases.

Imagine a blood test where people with a disease tend to score around 75, and healthy people tend to score around 45. If you set the cutoff at 60, you’ll catch most of the sick but misclassify some healthy people. If you drop the cutoff to 55, your sensitivity rises because you’re now catching sick people whose scores fall in the 55 to 60 range, but more healthy people with scores above 55 are now incorrectly flagged as positive. This inverse relationship is why no test is perfect at both metrics simultaneously.

Which One Matters More

The answer depends entirely on the consequences of getting it wrong. When missing a condition is dangerous, such as screening for cancer or ruling out a heart attack in the emergency room, high sensitivity takes priority. You’d rather deal with some false positives (and the extra follow-up testing they require) than send a truly sick patient home. Tests used this way are often called “rule-out” tests: a negative result on a highly sensitive test is very reassuring.

When a false positive carries serious consequences, such as an unnecessary surgery, a harmful drug regimen, or significant psychological harm, high specificity becomes more important. You want to be confident that a positive result is real before acting on it. In practice, many diagnostic pathways use a sensitive screening test first, followed by a specific confirmatory test.

One simple summary metric is the Youden Index, calculated as sensitivity + specificity − 1. A value of 1.0 means the test is perfect on both fronts; a value of 0 means it performs no better than flipping a coin. But weighting sensitivity and specificity equally is rarely appropriate in clinical decisions, so this index is more of a starting point than a final answer.

How Predictive Values Differ

Sensitivity and specificity describe how the test performs relative to the disease. Predictive values flip the perspective and describe what a result means for the patient. Positive predictive value (PPV) answers: “I tested positive. What’s the probability I actually have the condition?” Negative predictive value (NPV) answers: “I tested negative. What’s the probability I’m truly disease-free?”

The key difference is that predictive values shift dramatically with disease prevalence. If a condition is rare, even a very specific test will produce a low PPV because most positive results will be false positives relative to the small number of true cases. Sensitivity and specificity, by contrast, are generally treated as stable properties of the test itself. That said, a large analysis of nearly 7,000 diagnostic accuracy studies found that in practice, higher disease prevalence was associated with somewhat higher sensitivity and somewhat lower specificity. The shifts are modest but real, likely driven by differences in disease severity and patient populations across settings.

The formulas for predictive values use the rows of the 2×2 table instead of the columns. PPV = TP ÷ (TP + FP). NPV = TN ÷ (TN + FN). In the strep example above, PPV = 72 ÷ (72 + 8) = 90%, and NPV = 102 ÷ (102 + 18) = 85%.

Common Mistakes to Avoid

The most frequent error is mixing up the denominators. Sensitivity divides by everyone who truly has the condition (TP + FN), not by everyone who tested positive. Specificity divides by everyone who is truly healthy (TN + FP), not by everyone who tested negative. If you remember that sensitivity and specificity each use a column of the 2×2 table while predictive values each use a row, you’ll keep the formulas straight.

Another common mistake is interpreting a test’s sensitivity and specificity as the probability that any individual result is correct. A test with 95% sensitivity does not mean a positive result has a 95% chance of being right. That probability is the PPV, and it depends heavily on how common the condition is in the group being tested. In a low-prevalence population, even a 95%-sensitive, 95%-specific test can have a PPV below 50%.