# Uncertainty Wednesday: Sensitivity and Specificity

By [Continuations](https://continuations.com) · 2017-03-29

uncertainty wednesday, sensitivity, specificity, medical test

---

Today’s [Uncertainty Wednesday](http://continuations.com/tagged/uncertainty-wednesday) is a further [continuation](http://continuations.com/post/27658476/starting-continuations) of the [PSA Test example](http://continuations.com/post/157859654895/uncertainty-wednesday-psa-test-example), but I got tired of the boring title and wanted to give the post as more, well, specific one. Last Wednesday I wrote that sensitivity and specificity are “widely used to assess the quality of medical tests.”  

Here are their [definitions taken from Wikipedia](https://en.wikipedia.org/wiki/Sensitivity_and_specificity)

Sensitivity = probability of a positive test given that the patient has the disease  
Specificity = probability of a negative test given that the patient is well

Using our notation we can rewrite this as

Sensitivity = P(H | B), i.e. probability of a high PSA level signal (H) conditional on the patient having cancer (B)

Specificity = P(L | A), i.e. probability of a low PSA level signal (L) conditional on the patient being healthy (A)

We see that sensitivity is in a way the inverse of the question we were asking originally, which is P(B | H), i.e the probability of having cancer (B) conditional on a receiving a high PSA level signal (H).

So the question is what is the relationship between P(H | B) and P(B | H)?

To figure this out, let’s first see if we can derive P(H | B) from the elementary probabilities [given originally](http://continuations.com/post/157859654895/uncertainty-wednesday-psa-test-example), which I am repeating here

P({AL}) = P(healthy \*and\* low PSA) = 0.907179  
P({AH}) = P(healthy \*and\* high PSA) = 0.089721  
P({BL}) = P(cancer \*and\* low PSA) = 0.001519  
P({BH}) = P(cancer \*and\* high PSA) = 0.001581

So let’t start by recalling out how likely it is that someone has cancer (B) which we also derived previously

P(B) = P(cancer) = P({BH, BL}) = P({BH}) + P({BL}) = 0.001519 + 0.001581 = 0.0031

So based on this it becomes quite easy to answer our new conditional question:

P(H | B) = P({BH}) / P(B) = 0.001581 / 0.0031 = 0.51

So the sensitivity of the test is 0.51 or 51%, which means that the test correctly detects about half of the people who have cancer.

Now [let’s look back at P(B | H)](http://continuations.com/post/158149393260/uncertainty-wednesday-psa-test-example-contd) and what do we see there

P(B | H) = P({BH}) / P(H) = 0.001581 / 0.091302 = 0.017316

The numerators are the same, which let’s us come up with a simple formula by forming the ratio between the two conditionals:

P(B | H) / P(H | B) = P({BH}) / P(H) \* P(B) / P({BH}) = P(B) / P(H)

we can rewrite that as

P(B | H) = P(B)/P(H) \* P(H | B)

So we now see that the answer to the crucial question – how likely is it that the patient has cancer conditional on a positive test – doesn’t depend just on the sensitivity of the test P(H | B) but also on the the ratio between the unconditional probabilities of having cancer P(B) and of receiving a high PSA signal P(H).

Readers with a background in statistics will recognize the above as the formula for [Bayes’ Theorem](https://en.wikipedia.org/wiki/Bayes%27_theorem). Next Wednesday we will go into more detail about what it means, but between now and then you should ask yourself how much the sensitivity of a test really tells you by itself.

---

*Originally published on [Continuations](https://continuations.com/uncertainty-wednesday-sensitivity-and-specificity)*
