What Is Bayes' Theorem?
What Is Bayes' Theorem?
What Is Bayes' Theorem?
“Events” Are different from “tests.” For example, there is a test for liver
disease, but that’s separate from the event of actually having liver
disease.
Tests are flawed: just because you have a positive test does not mean
you actually have the disease. Many tests have a high false positive
rate. Rare events tend to have higher false positive rates than more
common events. We’re not just talking about medical tests here. For
example, spam filtering can have high false positive rates. Bayes’
theorem takes the test results and calculates your real probability that the
test has identified the event.
The Formula
A could mean the event “Patient has liver disease.” Past data tells you
that 10% of patients entering your clinic have liver disease. P(A) = 0.10.
B could mean the litmus test that “Patient is an alcoholic.” Five percent
of the clinic’s patients are alcoholics. P(B) = 0.05.
You might also know that among those patients diagnosed with liver
disease, 7% are alcoholics. This is your B|A: the probability that a
patient is alcoholic, given that they have liver disease, is 7%.
Another way to look at the theorem is to say that one event follows
another. Above I said “tests” and “events”, but it’s also legitimate to
think of it as the “first event” that leads to the “second event.” There’s
no one right way to do this: use the terminology that makes most sense
to you.
Step 1: Figure out what your event “A” is from the question. That
information is in the italicized part of this particular question. The event
that happens first (A) is being prescribed pain pills. That’s given as 10%.
Step 2: Figure out what your event “B” is from the question. That
information is also in the italicized part of this particular question. Event
B is being an addict. That’s given as 5%.
Step 3: Figure out what the probability of event B (Step 2) given event A
(Step 1). In other words, find what (B|A) is. We want to know “Given
that people are prescribed pain pills, what’s the probability they are an
addict?” That is given in the question as 8%, or .8.
Step 4: Insert your answers from Steps 1, 2 and 3 into the formula and
solve.
P(A|B) = P(B|A) * P(A) / P(B) = (0.08 * 0.1)/0.05 = 0.16
There are several forms of Bayes’ Theorem out there, and they are all
equivalent (they are just written in slightly different ways). In this next
equation, “X” is used in place of “B.” In addition, you’ll see some
changes in the denominator. The proof of why we can rearrange the
equation like this is beyond the scope of this article (otherwise it would
be 5,000 words instead of 2,000!). However, if you come across a
question involving medical tests, you’ll likely be using this alternative
formula to find the answer:
Watch the video for a quick solution or read two solved Bayes’ Theorem
examples below:
The first step into solving Bayes’ theorem problems is to assign letters to
events:
A = chance of having the faulty gene. That was given in the question as
1%. That also means the probability of not having the gene (~A) is 99%.
So:
P(X|A) = Chance of a positive test result given that the person actually
has the gene. That was given in the question as 90%.
p(X|~A) = Chance of a positive test if the person doesn’t have the gene.
That was given in the question as 9.6%
Now we have all of the information we need to put into the equation:
P(A|X) = (.9 * .01) / (.9 * .01 + .096 * .99) = 0.0865 (8.65%).
The probability of having the faulty gene on the test is 8.65%.
Remember when (up there ^^) I said that there are many equivalent
ways to write Bayes Theorem? Here is another equation, that you can
use to figure out the above problem. You’ll get exactly the same result:
The main difference with this form of the equation is that it uses the
probability terms intersection(∩) and compliment (c). Think of it as
shorthand: it’s the same equation, written in a different way.
The two sides of the equation are equivalent, and P(B) * P(A|B) is what
we were using when we solved the numerator in the problem above.
P(B) * P(A|B) = 0.01 * 0.9 = 0.009
Bayes’ theorem problems can be figured out without using the equation
(although using the equation is probably simpler). But if you can’t wrap
your head around why the equation works (or what it’s doing), here’s the
non-equation solution for the same problem in #1 (the genetic test
problem) above.
Step 1: Find the probability of a true positive on the test. That equals
people who actually have the defect (1%) * true positive results (90%) =
.009.
Step 2: Find the probability of a false positive on the test. That equals
people who don’t have the defect (99%) * false positive results (9.6%) =
.09504.
Step 3: Figure out the probability of getting a positive result on the test.
That equals the chance of a true positive (Step 1) plus a false positive
(Step 2) = .009 + .09504 = .0.10404.
Step 4: Find the probability of actually having the gene, given a positive
result. Divide the chance of having a real, positive result (Step 1) by the
chance of getting any kind of positive result (Step 3) = .009/.10404 =
0.0865 (8.65%).
Bayes’ Theorem has several forms. You probably won’t encounter any
of these other forms in an elementary stats class. The different forms can
be used for different purposes. For example, one version uses what
Rudolf Carnap called the “probability ratio“. The probability ratio rule
states that any event (like a patient having liver disease) must be
multiplied by this factor PR(H,E)=PE(H)/P(H). That gives the event’s
probability conditional on E. The Odds Ratio Rule is very similar to the
probability ratio, but the likelihood ratio divides a test’s true positive
rate divided by its false positive rate. The formal definition of the Odds
Ratio rule is OR(H,E)=PH,(E)/P~H(E).