The Central Idea

Let

\[ D=\{\text{condition present}\} \]

and

\[ D^c=\{\text{condition absent}\}. \]

Let

\[ +=\{\text{positive test}\} \]

and

\[ -=\{\text{negative test}\}. \]

A diagnostic-testing problem compares the hidden state \(D\) or \(D^c\) with the observed result \(+\) or \(-\).

The Four Possible Outcomes

Every tested case falls into one of four categories:

These four outcomes form a complete classification of test results.

A Diagnostic Table

Positive Test Negative Test
Condition Present True Positive False Negative
Condition Absent False Positive True Negative

Many diagnostic quantities are conditional probabilities formed from rows or columns of this table.

Prevalence

The prevalence of the condition is

\[ \boxed{P(D)}. \]

It is the proportion of the relevant population that has the condition before the test result is considered.

In Bayesian language, prevalence often serves as the prior probability of the condition.

Sensitivity

Sensitivity is the probability that the test is positive when the condition is present:

\[ \boxed{ \text{Sensitivity}=P(+\mid D) }. \]

Sensitivity measures how effectively the test detects positive cases among those who truly have the condition.

True-Positive Rate

Sensitivity is also called the true-positive rate.

Thus,

\[ \boxed{ \text{TPR}=P(+\mid D) }. \]

The denominator is the group with the condition.

False-Negative Rate

Among cases with the condition, the test either returns positive or negative.

Therefore,

\[ P(+\mid D)+P(-\mid D)=1. \]

The false-negative rate is

\[ \boxed{ \text{FNR}=P(-\mid D)=1-\text{Sensitivity} }. \]

Specificity

Specificity is the probability that the test is negative when the condition is absent:

\[ \boxed{ \text{Specificity}=P(-\mid D^c) }. \]

Specificity measures how effectively the test correctly rejects negative cases among those who do not have the condition.

True-Negative Rate

Specificity is also called the true-negative rate:

\[ \boxed{ \text{TNR}=P(-\mid D^c) }. \]

False-Positive Rate

Among cases without the condition,

\[ P(+\mid D^c)+P(-\mid D^c)=1. \]

Therefore, the false-positive rate is

\[ \boxed{ \text{FPR}=P(+\mid D^c)=1-\text{Specificity} }. \]

Sensitivity and Specificity Condition on the True State

Sensitivity conditions on

\[ D, \]

while specificity conditions on

\[ D^c. \]

Both describe test behavior within known truth categories.

They do not directly answer how likely the condition is after a test result is observed.

Positive Predictive Value

The positive predictive value is the probability that the condition is present given a positive test:

\[ \boxed{ \text{PPV}=P(D\mid +) }. \]

This reverses the direction of sensitivity.

Negative Predictive Value

The negative predictive value is the probability that the condition is absent given a negative test:

\[ \boxed{ \text{NPV}=P(D^c\mid -) }. \]

Predictive Values Condition on the Test Result

PPV conditions on a positive result:

\[ P(D\mid +). \]

NPV conditions on a negative result:

\[ P(D^c\mid -). \]

These quantities depend on both test characteristics and the prevalence of the condition in the tested population.

Do Not Confuse Sensitivity with Positive Predictive Value

Sensitivity is

\[ P(+\mid D). \]

Positive predictive value is

\[ P(D\mid +). \]

These probabilities reverse the direction of conditioning and can be very different.

Do Not Confuse Specificity with Negative Predictive Value

Specificity is

\[ P(-\mid D^c). \]

Negative predictive value is

\[ P(D^c\mid -). \]

Again, the denominators are different.

A Complete Set of Conditional Quantities

Condition on the true state:

\[ P(+\mid D)=\text{sensitivity}, \] \[ P(-\mid D)=\text{false-negative rate}, \] \[ P(-\mid D^c)=\text{specificity}, \] \[ P(+\mid D^c)=\text{false-positive rate}. \]

Condition on the observed result:

\[ P(D\mid +)=\text{PPV}, \] \[ P(D^c\mid -)=\text{NPV}. \]

A First Diagnostic Example

Suppose a condition has prevalence

\[ P(D)=0.02. \]

A test has sensitivity

\[ P(+\mid D)=0.95 \]

and specificity

\[ P(-\mid D^c)=0.96. \]

Find the Complementary Error Rates

The false-negative rate is

\[ P(-\mid D)=1-0.95=\boxed{0.05}. \]

The false-positive rate is

\[ P(+\mid D^c)=1-0.96=\boxed{0.04}. \]

Find the Overall Positive-Test Probability

Since

\[ P(D^c)=0.98, \]

total probability gives

\[ P(+) = P(D)P(+\mid D) + P(D^c)P(+\mid D^c). \]

Therefore,

\[ P(+) = 0.02(0.95)+0.98(0.04). \]

Thus,

\[ \boxed{ P(+)=0.0582 }. \]

Find the Positive Predictive Value

Bayes' theorem gives

\[ P(D\mid +) = \frac{P(D)P(+\mid D)}{P(+)}. \]

Therefore,

\[ P(D\mid +) = \frac{0.02(0.95)}{0.0582} \approx \boxed{0.3265}. \]

The positive predictive value is about \(32.65\%\).

Why High Sensitivity Does Not Guarantee High PPV

The test detects \(95\%\) of true cases, but the condition occurs in only \(2\%\) of the population.

Because the group without the condition is much larger, even a \(4\%\) false-positive rate can produce many false positives.

Predictive value therefore depends strongly on prevalence.

Natural Frequencies

The same example can be made concrete by imagining

\[ 10{,}000 \]

tested cases.

At \(2\%\) prevalence,

\[ 200 \]

have the condition and

\[ 9{,}800 \]

do not.

Count the True Positives

Sensitivity is \(95\%\), so among \(200\) cases with the condition,

\[ 0.95(200)=190 \]

test positive.

These are the true positives.

Count the False Negatives

The remaining

\[ 200-190=10 \]

cases with the condition test negative.

These are the false negatives.

Count the False Positives

The false-positive rate is \(4\%\).

Among \(9{,}800\) cases without the condition,

\[ 0.04(9{,}800)=392 \]

test positive.

These are the false positives.

Count the True Negatives

Specificity is \(96\%\), so

\[ 0.96(9{,}800)=9{,}408 \]

cases without the condition test negative.

These are the true negatives.

Build the Natural-Frequency Table

Positive Negative Total
Condition Present 190 10 200
Condition Absent 392 9408 9800
Total 582 9418 10000

Read PPV from the Table

Among all positive tests,

\[ 582 \]

in total, exactly

\[ 190 \]

are true positives.

Therefore,

\[ P(D\mid +) = \frac{190}{582} \approx \boxed{0.3265}. \]

Read NPV from the Table

Among all negative tests,

\[ 9418 \]

in total,

\[ 9408 \]

are true negatives.

Therefore,

\[ P(D^c\mid -) = \frac{9408}{9418} \approx \boxed{0.9989}. \]

The negative predictive value is about \(99.89\%\).

The Same Test Can Have Very Different PPV and NPV

In the example,

\[ \text{PPV}\approx32.65\% \]

while

\[ \text{NPV}\approx99.89\%. \]

The difference arises partly because the condition is rare in the tested population.

The Role of Prevalence

For fixed sensitivity and specificity, changing

\[ P(D) \]

changes the predictive values.

In general, increasing prevalence tends to increase positive predictive value and decrease negative predictive value.

Decreasing prevalence tends to have the opposite effect.

Positive Predictive Value Formula

Using sensitivity, specificity, and prevalence,

\[ \boxed{ P(D\mid +) = \frac{P(D)P(+\mid D)} {P(D)P(+\mid D)+P(D^c)P(+\mid D^c)} }. \]

Since

\[ P(+\mid D^c)=1-\text{specificity}, \]

the formula can be written directly from prevalence, sensitivity, and specificity.

Negative Predictive Value Formula

Similarly,

\[ \boxed{ P(D^c\mid -) = \frac{P(D^c)P(-\mid D^c)} {P(D)P(-\mid D)+P(D^c)P(-\mid D^c)} }. \]

Here

\[ P(-\mid D)=1-\text{sensitivity}. \]

Example: Higher Prevalence

Keep sensitivity at

\[ 0.95 \]

and specificity at

\[ 0.96, \]

but suppose prevalence is now

\[ P(D)=0.20. \]

Find the New Positive Predictive Value

Since

\[ P(D^c)=0.80, \]

the positive probability is

\[ P(+) = 0.20(0.95)+0.80(0.04). \]

Thus,

\[ P(+)=0.190+0.032=0.222. \]

Therefore,

\[ P(D\mid +) = \frac{0.190}{0.222} \approx \boxed{0.8559}. \]

The PPV rises dramatically because the condition is much more common.

Same Test, Different Population

The sensitivity and specificity did not change.

Only the prevalence changed.

Yet the PPV increased from about

\[ 32.65\% \]

to about

\[ 85.59\%. \]

Predictive values are therefore population-dependent.

Example: Quality-Control Screening

The same mathematics applies outside medicine.

Suppose \(5\%\) of manufactured units are defective:

\[ P(D)=0.05. \]

An inspection system flags \(90\%\) of defective units:

\[ P(+\mid D)=0.90. \]

It correctly clears \(95\%\) of nondefective units:

\[ P(-\mid D^c)=0.95. \]

Find the Flagged-Unit Probability

The false-positive rate is

\[ 1-0.95=0.05. \]

Therefore,

\[ P(+) = 0.05(0.90)+0.95(0.05). \]

Thus,

\[ P(+)=0.045+0.0475=\boxed{0.0925}. \]

Given a Flag, Find the Probability of a Defect

Apply Bayes' theorem:

\[ P(D\mid +) = \frac{0.05(0.90)}{0.0925}. \]

Therefore,

\[ \boxed{ P(D\mid +)\approx0.4865 }. \]

Under this model, about \(48.65\%\) of flagged units are actually defective.

Accuracy

One overall measure of correct classification is

\[ \boxed{ P(\text{correct}) = P(D\cap+)+P(D^c\cap-) }. \]

Using conditional probabilities,

\[ P(\text{correct}) = P(D)P(+\mid D) + P(D^c)P(-\mid D^c). \]

Example: Overall Accuracy

Return to the example with

\[ P(D)=0.02, \] \[ P(+\mid D)=0.95, \]

and

\[ P(-\mid D^c)=0.96. \]

Then

\[ P(\text{correct}) = 0.02(0.95)+0.98(0.96). \]

Therefore,

\[ P(\text{correct}) = 0.019+0.9408 = \boxed{0.9598}. \]

The overall accuracy is \(95.98\%\).

High Accuracy Can Be Misleading in Imbalanced Populations

If the condition is very rare, a system that almost always predicts “negative” may achieve high overall accuracy while performing poorly at identifying the positive cases.

Therefore, accuracy should not automatically replace sensitivity, specificity, or predictive values.

A Simple Accuracy Warning

Suppose only \(1\%\) of cases are positive.

A classifier that always predicts negative would be correct

\[ 99\% \]

of the time.

Yet its sensitivity would be

\[ \boxed{0}. \]

A single summary measure can hide important behavior.

False Discovery Rate

The probability that a positive result is false is

\[ \boxed{ P(D^c\mid +) }. \]

This is the complement of positive predictive value:

\[ P(D^c\mid +)=1-P(D\mid +). \]

It is sometimes called the false discovery rate in classification contexts.

False Omission Probability

The probability that a negative result hides a positive case is

\[ \boxed{ P(D\mid -) }. \]

This is the complement of negative predictive value:

\[ P(D\mid -)=1-P(D^c\mid -). \]

Positive Likelihood Ratio

A positive result can also be summarized by its likelihood ratio:

\[ \boxed{ LR_+ = \frac{P(+\mid D)} {P(+\mid D^c)} }. \]

In terms of sensitivity and specificity,

\[ \boxed{ LR_+ = \frac{\text{sensitivity}} {1-\text{specificity}} }. \]

Negative Likelihood Ratio

A negative result has likelihood ratio

\[ \boxed{ LR_- = \frac{P(-\mid D)} {P(-\mid D^c)} }. \]

Therefore,

\[ \boxed{ LR_- = \frac{1-\text{sensitivity}} {\text{specificity}} }. \]

Interpret the Positive Likelihood Ratio

If

\[ LR_+=10, \]

then a positive result is ten times as likely when the condition is present as when it is absent.

This quantity multiplies prior odds into posterior odds after a positive result.

Interpret the Negative Likelihood Ratio

If

\[ LR_-=0.10, \]

then a negative result is only one-tenth as likely when the condition is present as when it is absent.

Such evidence reduces the odds in favor of the condition.

Example: Likelihood Ratios from Sensitivity and Specificity

Suppose

\[ \text{sensitivity}=0.90 \]

and

\[ \text{specificity}=0.95. \]

Then

\[ LR_+ = \frac{0.90}{0.05} = \boxed{18}. \]

Also,

\[ LR_- = \frac{0.10}{0.95} \approx \boxed{0.1053}. \]

Testing as an Odds Update

If the prior odds of the condition are

\[ O_{\text{prior}}, \]

then after a positive test,

\[ \boxed{ O_{\text{post},+} = O_{\text{prior}}LR_+ }. \]

After a negative test,

\[ \boxed{ O_{\text{post},-} = O_{\text{prior}}LR_- }. \]

Example: Positive Result in Odds Form

Suppose prevalence is

\[ P(D)=0.10. \]

Prior odds are

\[ \frac{0.10}{0.90} = \frac{1}{9}. \]

Suppose

\[ LR_+=9. \]

Then posterior odds are

\[ \frac{1}{9}\cdot9=1. \]

Therefore,

\[ \boxed{P(D\mid +)=0.50}. \]

Example: Negative Result in Odds Form

Keep prior odds

\[ 1:9 \]

and suppose

\[ LR_-=0.10. \]

Posterior odds are

\[ \frac{1}{9}(0.10) = \frac{1}{90}. \]

Therefore,

\[ P(D\mid -) = \frac{1}{1+90} = \boxed{\frac{1}{91}} \approx \boxed{0.0110}. \]

Thresholds Create Tradeoffs

Many diagnostic systems classify a continuous score using a threshold.

Moving the threshold can change:

Increasing one performance measure may reduce another.

A Lower Positive Threshold

If a test labels more borderline cases as positive, sensitivity may increase because fewer positive cases are missed.

However, specificity may decrease because more negative cases are also labeled positive.

A Higher Positive Threshold

If a stricter threshold is required for a positive result, specificity may increase because fewer negative cases are falsely labeled positive.

However, sensitivity may decrease because more positive cases are missed.

There Is No Universal Best Threshold

The preferred threshold depends on the consequences of the two error types.

In one application, false negatives may be especially costly.

In another, false positives may create substantial follow-up costs.

Probability quantifies the tradeoff; choosing among tradeoffs requires the surrounding decision context.

Screening and Confirmation

Some systems use a first test designed to identify a broad set of possible positive cases and then apply a more selective second-stage procedure.

Mathematically, this creates a sequential conditional-probability problem.

Each additional result can update the probability again.

Repeated Tests Are Not Automatically Independent

If the same test is repeated, the results may share sources of error.

Therefore, one should not automatically multiply likelihood ratios as though the test results were conditionally independent.

The dependence structure of repeated evidence matters.

Example: A Confusion Matrix

Suppose a classifier is evaluated on \(1{,}000\) cases:

Predicted Positive Predicted Negative Total
Actually Positive 180 20 200
Actually Negative 80 720 800
Total 260 740 1000

Calculate Sensitivity from the Confusion Matrix

Among the \(200\) actually positive cases,

\[ 180 \]

are predicted positive.

Therefore,

\[ \boxed{ \text{Sensitivity} = \frac{180}{200} = 0.90 }. \]

Calculate Specificity from the Confusion Matrix

Among the \(800\) actually negative cases,

\[ 720 \]

are predicted negative.

Therefore,

\[ \boxed{ \text{Specificity} = \frac{720}{800} = 0.90 }. \]

Calculate Positive Predictive Value

Among the

\[ 260 \]

predicted-positive cases,

\[ 180 \]

are actually positive.

Therefore,

\[ \boxed{ \text{PPV} = \frac{180}{260} \approx 0.6923 }. \]

Calculate Negative Predictive Value

Among the

\[ 740 \]

predicted-negative cases,

\[ 720 \]

are actually negative.

Therefore,

\[ \boxed{ \text{NPV} = \frac{720}{740} \approx 0.9730 }. \]

Calculate Accuracy from the Confusion Matrix

Correct classifications are

\[ 180+720=900. \]

Therefore,

\[ \boxed{ \text{Accuracy} = \frac{900}{1000} = 0.90 }. \]

Different Metrics Use Different Denominators

Sensitivity uses the actually positive group.

Specificity uses the actually negative group.

PPV uses the predicted-positive group.

NPV uses the predicted-negative group.

Accuracy uses the entire evaluated population.

Common Error: Assuming a Positive Test Means the Condition Is Present

A positive test does not automatically imply

\[ P(D\mid +)=1. \]

False positives may occur.

The correct posterior probability depends on prevalence and test behavior.

Common Error: Equating Sensitivity with PPV

Sensitivity is

\[ P(+\mid D). \]

PPV is

\[ P(D\mid +). \]

Reversing the condition changes the denominator and usually changes the probability.

Common Error: Equating Specificity with NPV

Specificity is

\[ P(-\mid D^c). \]

NPV is

\[ P(D^c\mid -). \]

These are not interchangeable.

Common Error: Using Specificity as the False-Positive Rate

Specificity is

\[ P(-\mid D^c). \]

The false-positive rate is its complement:

\[ \boxed{ P(+\mid D^c)=1-\text{specificity} }. \]

Common Error: Ignoring Prevalence

Sensitivity and specificity alone do not determine PPV or NPV.

Predictive values also depend on

\[ P(D). \]

The same test can have different predictive values in populations with different prevalence.

Common Error: Treating Accuracy as the Only Performance Measure

Accuracy can conceal important asymmetries between false positives and false negatives.

This is especially important when one class is rare.

Common Error: Multiplying Repeated-Test Evidence Without a Dependence Model

Repeated test outcomes may not be conditionally independent.

If their errors are correlated, multiplying separate likelihood ratios can overstate the amount of new information.

Common Error: Confusing Mathematical Probability with a Decision

A posterior probability quantifies uncertainty under a model.

It does not by itself determine what action should be taken.

Decisions may also depend on costs, benefits, risks, policies, thresholds, and domain-specific judgment.

A Reliable Procedure from Sensitivity and Specificity

  1. Define \(D\), \(D^c\), \(+\), and \(-\).
  2. Write the prevalence \(P(D)\).
  3. Compute \(P(D^c)=1-P(D)\).
  4. Write sensitivity \(P(+\mid D)\).
  5. Write specificity \(P(-\mid D^c)\).
  6. Compute the false-positive and false-negative rates by complements.
  7. Use total probability to find \(P(+)\) or \(P(-)\).
  8. Use Bayes' theorem to calculate the desired predictive value.
  9. Check the result against a natural-frequency table when useful.

A Reliable Procedure from Counts

  1. Build a \(2\times2\) table of actual state versus test result.
  2. Check that row and column totals agree with the population total.
  3. Use row totals for sensitivity and specificity.
  4. Use column totals for predictive values.
  5. Use all cases for overall accuracy.
  6. Translate every ratio back into a conditional probability statement.

Example: Full Workflow

Suppose

\[ P(D)=0.10, \]

sensitivity is

\[ 0.85, \]

and specificity is

\[ 0.90. \]

Then

\[ P(D^c)=0.90, \] \[ P(+\mid D^c)=0.10. \]

The overall positive probability is

\[ P(+) = 0.10(0.85)+0.90(0.10). \]

Therefore,

\[ P(+)=0.085+0.090=0.175. \]

The positive predictive value is

\[ P(D\mid +) = \frac{0.085}{0.175} = \boxed{\frac{17}{35}} \approx \boxed{0.4857}. \]

Practice 1: Complementary Error Rates

A test has sensitivity \(0.92\) and specificity \(0.95\).

Find the false-negative rate and false-positive rate.

Practice 2: Positive Predictive Value

Suppose

\[ P(D)=0.10, \] \[ P(+\mid D)=0.90, \]

and specificity is

\[ 0.95. \]

Find \(P(D\mid +)\).

Practice 3: Negative Predictive Value

Using the same information as Practice 2, find

\[ P(D^c\mid -). \]

Practice 4: Natural Frequencies

A condition affects \(5\%\) of a population. A test has sensitivity \(80\%\) and specificity \(90\%\).

In a hypothetical population of \(1{,}000\), find the expected numbers of:

Practice 5: Confusion Matrix

A classifier produces:

Find sensitivity and specificity.

Practice 6: Predictive Values from Counts

Using the counts from Practice 5, find PPV and NPV.

Practice 7: Accuracy

Using the counts from Practice 5, find the overall accuracy.

Practice 8: Positive Likelihood Ratio

A test has sensitivity

\[ 0.90 \]

and specificity

\[ 0.80. \]

Find \(LR_+\).

Practice 9: Negative Likelihood Ratio

Using the same test as Practice 8, find \(LR_-\).

Practice 10: Identify the Error

A test has sensitivity \(99\%\). A student concludes that anyone with a positive result has a \(99\%\) probability of having the condition.

Explain the error.

Practice Answers

Practice 1

The false-negative rate is

\[ 1-0.92=\boxed{0.08}. \]

The false-positive rate is

\[ 1-0.95=\boxed{0.05}. \]

Practice 2

The false-positive rate is

\[ 0.05. \]

Therefore,

\[ P(+) = 0.10(0.90)+0.90(0.05) = 0.09+0.045 = 0.135. \]

Thus,

\[ P(D\mid +) = \frac{0.09}{0.135} = \boxed{\frac{2}{3}} \approx \boxed{0.6667}. \]

Practice 3

The false-negative rate is

\[ 0.10. \]

Therefore,

\[ P(-) = 0.10(0.10)+0.90(0.95) = 0.01+0.855 = 0.865. \]

Thus,

\[ P(D^c\mid -) = \frac{0.90(0.95)}{0.865} = \frac{0.855}{0.865} \approx \boxed{0.9884}. \]

Practice 4

Out of \(1{,}000\), the expected number with the condition is

\[ 50, \]

and without it is

\[ 950. \]

True positives:

\[ 0.80(50)=\boxed{40}. \]

False negatives:

\[ 50-40=\boxed{10}. \]

True negatives:

\[ 0.90(950)=\boxed{855}. \]

False positives:

\[ 950-855=\boxed{95}. \]

Practice 5

Sensitivity:

\[ \frac{90}{90+10} = \boxed{0.90}. \]

Specificity:

\[ \frac{360}{360+40} = \boxed{0.90}. \]

Practice 6

PPV:

\[ \frac{90}{90+40} = \frac{90}{130} \approx \boxed{0.6923}. \]

NPV:

\[ \frac{360}{360+10} = \frac{360}{370} \approx \boxed{0.9730}. \]

Practice 7

Correct classifications:

\[ 90+360=450. \]

Total classifications:

\[ 90+10+40+360=500. \]

Therefore,

\[ \boxed{ \text{Accuracy}=\frac{450}{500}=0.90 }. \]

Practice 8

\[ LR_+ = \frac{0.90}{1-0.80} = \frac{0.90}{0.20} = \boxed{4.5}. \]

Practice 9

\[ LR_- = \frac{1-0.90}{0.80} = \frac{0.10}{0.80} = \boxed{0.125}. \]

Practice 10

Sensitivity is

\[ P(+\mid D), \]

while the probability that the condition is present after a positive result is

\[ P(D\mid +). \]

These are different conditional probabilities. To find the second, we also need the prevalence and the false-positive behavior of the test.

What to Remember

Diagnostic testing uses four basic outcomes:

The central conditional probabilities are

\[ \boxed{ \text{Sensitivity}=P(+\mid D) } \] \[ \boxed{ \text{Specificity}=P(-\mid D^c) } \] \[ \boxed{ \text{PPV}=P(D\mid +) } \] \[ \boxed{ \text{NPV}=P(D^c\mid -) }. \]

The central habit is: identify the denominator first—true state for sensitivity and specificity, observed result for predictive values.

Where We Go Next

Diagnostic testing applies Bayesian reasoning to one of its most familiar two-state settings. The same ideas extend beyond tests to expectations of numerical outcomes when information is known.

The next lesson, Conditional Expectation, develops the expected value of a random variable within a conditioned event or information set and connects probability updating with averages under restricted information.