Yesterday, an interesting conundrum came to me. Sometimes, people take two COVID tests on the same day. Imagine that one came back negative and the other came back positive… which can and does happen. Here is the tricky question… which one do you trust? The positive or the negative? You might think there is no way to compare them… but you’d be wrong. Mathematicians have an entire theory for dealing with problems exactly like this one. It is called Bayesian probability theory.
What is Bayesian Probability?
There isn’t any need to go into the incredible depth of what Bayesian probability is capable of, and so we won’t. Actually, all we need is a brief account of what Bayesian probability is meant to do and a brief explanation of how to do it. I can then walk you through how I, with my mathematical training, could go about evaluating which of the test results is probably right and which is probably wrong.
In short, Bayesian statistics or Bayesian probability is a theory of how evidence works. More specifically, Bayesian probability theory explains how evidence and probability interact and much influence new evidence should have on your current beliefs. This theory allows us to analyze which pieces of evidence are more important than others and how to correctly add new information into the overall picture.
I will first use a simplified example to show how the theory works. Suppose I ask you whether or not it will rain tomorrow in your hometown. Since (presumably) you’ve lived in your hometown for a large portion of your life, you have a pretty good idea of the likelihood that it will rain on a randomly chosen day. If you have to answer my question without looking up the weather report, you will probably give me that random probability. This random probability is called the prior probability (it is called this because it is prior to looking at any evidence). Your knowledge about your hometown’s average weather patterns is called the background information – it isn’t really evidence, it is rather the overall backdrop that you use to consider your evidence. Now, suppose you open up a weather app. You are now gathering evidence. In Bayesian probability, evidence just means “anything not already in your background information.” Evidence can point either direction – in fact you can have two pieces of evidence that point in opposite directions. For instance, imagine you open your weather app and you see a picture of a raincloud. Well, that evidence would serve to increase the likelihood that it will rain tomorrow. To be more specific, it doesn’t really impact whether or not it will rain tomorrow… obviously. But it should cause you to shift your opinion towards answering yes rather than no. The new probability that you have after this evidence is called the posterior probability (so called because it is post-evidence, that is, after looking at evidence). But evidence isn’t final in this theory. We can always find new evidence and factor that in. Perhaps, for instance, you look closer and your weather app says there is a 30% chance of rain tomorrow, and you know from living in your hometown for years that these low numbers do usually mean it won’t rain. Now, you received a new piece of evidence that should again shift the way you think about the question I asked you.
This is the natural way we process evidence. We all understand that seeing the raincloud on the weather app does give us some reason to think it will rain tomorrow, and we all understand that the 30% is an even better piece of evidence that, although it might rain tomorrow, it probably will not. Notice how after every new piece of evidence, the way we think about the situation changes. If you were to look at a different weather service and saw a 70% chance of rain, then your opinion should shift to account for that new information. When a mathematician, scientist, or philosopher talks about Bayesian probability or Bayesian statistics, all we mean is that we are using a mathematical theory that helps us keep all of our information up to date with the broad scope of evidence available to us.
Why Use This Stuff Anyways?
You’d be very surprised how many people us Bayesian thinking. I don’t think many of us would be surprised to see a scientist or mathematician using this method of thinking… but how about historians, philosophers, and detectives? Well, they do! Whenever you hear somebody speaking about the best way to explain something or the most likely explanation of something, very often they are using a process something like Bayesian probability. The strength of this way of doing mathematics is that we can directly compare pros and cons. In the weather example, we can figure out whether there being rain or no rain tomorrow is a better explanation of why we see the forecasts that we do. In history, if you have sources that give you slightly different information about a historical event, you want to know which historical events would be the most reasonable way to explain how those differences emerged. As a philosopher, you want to understand which ideas fit better with the observations we can all agree on about the world. As a detective, you want to know which suspect better fits with the evidence.
Notice in all of this that I have never once required that the match be perfect. Bayesian probability cares nothing for perfection. This method is designed specifically to deal with imperfect, messy situations. And that is what we are always dealing with, day in and day out.
How Does the Math Work?
The cornerstone of Bayesian probability theory is called Bayes’ Theorem. Before I can state what this is, I need to introduce the notation we use to write it down. When I use the capital letter , this is always referring to the probability of something or other. Capital letters other than are used as shorthand for some event we care about – like whether or not it will rain. For example, I might use as shorthand for “it will rain tomorrow,” and then would be the likelihood/probability that it will rain tomorrow. If I want to talk about the opposite of something, we can just put the word ‘not’ on the front – so is the likelihood that it will not rain tomorrow. (It is sometimes convenient to use a minus sign or some other symbol instead of the word not, but I won’t do that here.)
The last bit we need is called conditional probability. The notation I will use is , which you should read as “the probability of given .” The key word there is given. When we ask about , we aren’t just asking about the likelihood of – we are asking about the likelihood of given that we already know . This is the aspect of Bayesian probability theory that makes it possible to take new evidence into account. In the weather example, would be the weather reports we are looking at.
With all of this written down, I can now express Bayes’ Theorem. Before I write it in symbols, I’ll describe it in words. The goal is to calculate . The idea is that we can use the fact that we already know to get a head start. Since we already know happened, we can eliminate from consideration all possible situations where doesn’t happen. What we do now is we flip the order of the letters for a bit. We want to ask if would have made likely to happen – in other words, we want to know . If we also know , the likelihood of happening at all, then basically tells us the proportion of situations where both and happen. Likewise, tells us the proportion of situations where happens but doesn’t. Since either happens or doesn’t, those are the only two possibilities. Then to compute an overall probability, we pick the case we want to know about – the case where actually happens – and divide that by all the possible situations – that is just since we already know happened. What we’ve done is leveraged the fact that we know has happened already to figure out . In terms of formula, the preceding discussion tells us what we wanted to know.
Bayes’ Theorem: For any two events and ,
To see how this works, let’s go back to our weather example. In that example, represents “it will rain tomorrow” and we will say represents “the weather forecast says it will rain tomorrow.” The values of and are found using background information – so would be the likelihood it will rain on a random day, and would be the percent of days that weather services predict rain in your town. You could count up a few months of old weather predictions to find , and you could count up a year’s worth of actual rainy days to find . Now, would be the likelihood that the weather service would predict rain if in fact it will rain tomorrow. That should be a reasonably high number. Let’s say, just to put numbers to it, that is 90% – so on rainy days, weather services had predicted that rain the day beforehand in their forecasts 9 out of 10 times. Let’s say that in your town it rains on 15% of days overall and that your weather service predicts rain on about 18% of days overall.
Then , the probability that it actually will rain tomorrow given the forecast, is
This means that, three times out of four, it actually will rain tomorrow. Notice the cool thing about this – I never actually used the weather service’s posted probability to do any of this. I came up with the likelihood entirely on my own. This is the power of Bayesian probability.
What About COVID Testing?
Back to the original situation now. You’ve taken two back-to-back tests. One is positive, one is negative. What to do? Bayesian probability, that’s what!
Remember that the first step to any Bayesian problem is to set up your background information. The first piece of background information would be where you live. You’d want to estimate the probability that a random person near you currently has COVID-19. You could use your city, the area of your city you live in, or perhaps just your college campus if you live on a campus and never leave. I will call the probability of a random nearby person being sick . The second piece of background information is the quality of the test you use. The relevant term is the specificity of the test – which tells you how likely the test is to give you a negative result if you are truly no sick with COVID. I will call this factor . Notice that the specificity is phrased in Bayesian terms already – it is the likelihood that your test will come back negative given that you are not sick. We will use this later. Lastly, we need to know the rate of positive tests in the area you live in – I’ll just call this . To make everything easier to write down, I will use as shorthand for testing positive and as testing negative.
We now carry forward. What we want to know is the likelihood of obtaining a certain test result given your actual health condition. There are four probabilities that need to be calculated: , and . Now, we call on , the specificity of the test. This is the probability that you will test negative given that you are well. We’ve been using the notation for this. This means that . Now, three to go.
We can now use a principle of probability that we mentioned earlier. Either an event happens, or it doesn’t. Pretty simple. In probability language, this means opposite events add up to 1. Since is opposite of , is opposite to . This means that . We now know that . Now we know two out of the four.
This is as far as we can go without using Bayes’ theorem. I’ll now use Bayes’ theorem to calculate . The theorem tells us that
Now, we need to fill in the blanks. We already know that . Our background information gave us the value of , which is . The background information similarly tells us that . Therefore,
We now use the same “adding up to one” trick we used before to see that . This trick has brought the “sick” category back into the formula, which is what we needed. We now need Bayes’ theorem again to calculate . Using the background information much the same way as before,
Notice that if we use the original meanings of , then this means that
This other way of forming the expression is easier to read. To find , we count all the negative tests, subtract away those people who are actually well, and divide by the number of sick people. This is actually pretty intuitive when you slow down and think about it – we can describe the whole process in terms of counting people – and yet look at how far it has gotten us! As before, the fourth number, , can be found using the “adding up to 1” trick.
We now have all the numbers we need:
Now what? Well, the likelihood of your test results if you are actually well is the product of all the probabilities given that you are well. In Bayesian terms, this is
Likewise, the likelihood of your test outcomes if you are sick is
We are essentially done now. All that remains is to compare the two values. Whichever one is larger is the more likely of the two.
This is about as far as we can go with these simple probability methods. But, there is more to be said. First, we might notice that if we treat as a single unit, perhaps call it , then the likelihood of your outcome if you are actually sick is . We can view this whole problem now in terms of values of a function, . Using a different part of mathematics called calculus, we can discover that the biggest possible value of this expression is precisely , which happens when . We also learn from calculus that the closer is to , the bigger is. This means that all you really need to do is to find and figure out whether it is closer to than is.
And of course, in real life there is a speculative nature to all of this. You can only be sure of your final answer to the degree that you know your background information is reliable – and that is something that, although we do have it for many diagnostic tests, we do not yet have for COVID tests. So, while we can use the power of mathematics in these situations and many, many more, we must always use caution and humility in doing so.