0:02

Okay, welcome back troops. This is Mathematical Biostatistics Boot

Camp Lecture five. And we're going to start talking about

Bayes' Rule. Bayes' rule is one of the most famous

results in Statistics. It comes from a, I believe Presbyterian

minister, named Thomas Bayes, who wrote down the rule, I believe it was published

posthumously, much later and it's a astoundingly simple rule that has

incredible power to it. And the idea is basically how can you

relate conditional probabilities of the form A given B to probabilities of the

form B given A? So, you reverse the arguments.

It's very important, right? It's saying how can I talk about A given

that B has occurred when I only know things about the distribution of B given

that A has occurred. It's a very important thing and, of

course, you can't do that without a little bit extra information.

And we'll talk about it specifically where that extra information comes from.

I, I wanted to give the, the, the mathematical, the probability density and

mass function version of it first, and then we'll talk about the kind of

classical treatment with, with events. But let's let f(x) given y be a

conditional density or mass function for X, given that Y has occurred and has taken

to value y. And f(y) being the marginal density for y.

Then if y is continuous then Bayes' rule basically says that f(y) given X is f(x)

given Y times f(y) divided by f(x) given t times f (t) dt.

And notice that what we needed to know to do this calculation of f(y) given X, is

f(x) given Y, and then this extra argument f(y) by itself.

And so the idea of Bayes' rule is sort of flipping the arguments.

And then if y is discreted, f(y) given X is f(x) given Y times f(y) divided by the

sum over t of f(x) given t times f(t). Bayes' rule again, relates f(y) given X to

f(x) given Y and then, the marginal density f(y).

And if we apply this to events, it takes a kind of familiar form that you may have

run into before. So, a special case of this relationship

basically works out to be, probability of B given A, is the probability of A given B

times the probability of B divided by probability of A given B times the

probability of B plus the probability of A given B compliment times the B compliment.

And you could do this exactly from our previous formula, let x be the discreet

random variable that's the indicator whether' A has occurred y be an indicator

that the event B has occurred then plug in to the discreet version of Bayes' rule,

that would be a simple proof if you are willing to stipulate the previous page,

you can also prove it very easily just by working with the rules of probability in

sets. So, this numerator is probability A

intersect B, this denominator is probability A intersect B plus from the

probability of A intersect B complement. So, the numerator works out to be

probability of A intersect B and the denominator works out to be probability of

A, so that's exactly the conditional probability B given A.

So, it's quite easy to prove, but I just want it by discussing this indicative that

there's no real distinction between the way we're discussing it in terms of

continuous densities or discrete joint mass functions and this kind of

traditional method of treatment using probabilities and events.

So, that's a very brief treatment of how you can use Bayes' rule with densities and

with mass functions. We'll go through several examples next

time, but one of the most common and biggest examples that we're going to talk

about is associated with diagnostic testing, and that's what we'll do next.

Okay, welcome back troops. This is Lecture Five., Mathematical

Biostatistics Boot Camp. And now, we're going to be talking about

diagnostic tests. So, particular application of Bayes' rule,

it's used in so-called diagnostic testing. And we'll talk a little bit about the kind

of traditional treatment of this, but we'll also delve a little bit into the,

the intricacies of these calculations. They're a little bit more complex than

people usually give them credit for. But the simple treatment is as follows.

So, let's let plus and minus be the events that the diagnostic test is either

positive or negative, respectively. So, plus being positive, of course, and

minus being negative. And then, let's let D and D complement be

the event that a subject of the test does or does not have the disease,

respectively. We can make a definition that sensitivity

of the test is the probability that the test is positive given that the subject

actually has the disease probability of plus given D, that's the sensitivity.

The specificity is the probability that the test is negative given as the subject

is not have a disease, that is the probability of a minus given D complement.

So, let's give a couple more definitions. So, the positive predictive values is

often what a subject would want to know. That is the probability that a person has

the disease given a positive test result. And the negative predictive value is

another thing that people would very much so like to know, in the result of a

negative test, is the probability that they do not have the disease given that

the test is actually negative. And then, we might declare the prevalence

of the disease to be just the marginal probability of disease.

Okay, last set of definitions. The diagnostic likelihood ratio of a

positive test and let's call it DLR plus, is the probability of the test being

positive given that the person has the disease, divided by the probability the

test is positive given that the person does not have the disease, which is

exactly sensitivity divided by one minus specificity.

The diagnostic likelihood ratio of a negative tests labelled DLR minus, you can

read the formula there, the probability of negative test given the disease divided by

the probability of negative test, given disease complement which is one minus the

sensitivity divided by the specificity. Okay, we will go through, in detail, why

all these things are useful through a specific example.

And then, we will come back and, and talk a little about, maybe why these

calculations are little bit more subtle than people often discuss.

Okay, so, study comparing the efficacy of HIV test reports, on experiment which

concluded that the, the antibody test have a sensitivity of about 99.7 and a

specificity of about 98.5. And I got these numbers from a website but

am fudging them a little bit because it's kind of more important to just perform the

calculations than to talk about specific tests and to evaluate them.

So, imagine these numbers are accurate with respect to a specific test.

And by the way, y base rule is kind of convenient in these sorts of settings.

It's in principle, a little bit easier to get these numbers, sensitivity and

specificity by virtue of the fact that you would just take blood samples for a set of

people that you know are HIV positive and see what's the proportion of them that was

the test comes up positive. And take a group of people that you know

to be HIV negative and see the proportion that have a negative test result.

And you could get these numbers or get estimates of these numbers and, of course,

that's a very simplistic treatment of how you actually would get a sensitivity and

specificity, is there's lot's of issues, like how do you actually know if you're

working in an area where the tests are difficult.

How do you actually know whether a person has the disease or not, is in question, or

if you wait so long to where they're, the disease is very clinically relevant, then

are you evaluating the test in a stage of the disease where it's not interesting for

when you would be applying the disease? There's a lot of issues in development of

test and evaluation of test and constructing the validity that we are

going to completely gloss over in this discussion.

So, for our discussion, let's just assume these numbers are right, that they work

well. And then also, let's assume that there's a

0.1 percent prevalence of HIV in the population.

And a subject receives a positive test result.

Well, what is the probability that this subject has HIV?

Well, mathematically, what we want is probability of disease given a positive

test result, given the sensitivity, the probability of a positive test result,

given disease, which 0.997. This specificity probability of a negative

test result, given disease compliment, 0.985 and the prevalence probability of D,

0.001. So, using Bayes' formula, we can just

plugin, we get 0.997 times 0.001 divided by 0.997 times 0.001 plus 0.015 times

0.999. This works out to be about six%.

So, it works out that a positive test result only suggest to six percent

probability that the subject has the disease.

Or in other words, the positive predictive value is six % for this test.

Now you might wonder that seems awfully low.

Why is this the case that, you know, if I take a collection of blood samples that

are known to be positive and then I apply the test, it's 99 percent that are

accurately labeled as positive, how is this so low?

And if I take a bunch of blood samples that I know to be negative, and I apply

the test, I get a very high percentage of negative test how is this so low?

Well, it's basically, the low positive predictive value is due to the low

prevalence of disease in the somewhat modest specificity.

It's not so bad. And in this case, this is what Bayes' rule

actually does for us. You start out with prior information,

basically, you know, a very low probability of thinking that this person

has the disease, then you update it with the information of the positive test

result. And that gets codified by updating it with

sensitivity and the specificity associated with the test.

And that informs the positive predictive value.

And you get something that's much higher than the prior probability of disease, the

prevalence. But still isn't terribly high because you

started with such a low prior. And that's how Bayes' rule works.

So, for example, you know, here, the prevalence we're talking about is some,

say, national prevalence in the U S. But imagine, if you knew that the subject

was an intravenous drug user and routinely had intercourse with an H I V infected

partner. Well, your prior that this person has HIV,

would be much, much higher than the low prevalence that we cited here.

I don't know what the prevalence is among a population like this, but suffice to say

that it's much higher. And then, your positive predictive value

would be similarly higher, which is kind of interesting discussion.

Imagine, if you were clinician of some sort and you were working with a patient

and you saw their positive test result and you'd say, yeah, you know, its a positive

test result, but maybe we should run another test or do some other things to

evaluate your condition. You know, that the positive predictive

value associated with this test is only six%.

Well then, in the same interview, well, it came out that the person was an

intravenous drug user and routinely had intercourse with an HIV infected partner.

Well, then the clinician would say, oh, well the test is very conclusive, we need

to start you on anti-retrovirals or something like that.

So, from the patients perspective, that might seem a little odd, that this

external information is what kind of changed the conclusion, the test value

didn't change, just in the discussion with the clinician, only the, their prevalence

changed. And only the prevalence in the calculation

changed. So, from the patient's perspective, this

might seem a little weird. But again the mathematics are exactly

accurate. So, there's a question as to what is the

component of the calculation that does not change regardless of the prevalence?

And that's ultimately what the diagnostic likelihood ratios are giving you.

12:53

So, take for example, here, the probability of having disease given a

positive test result, we use Bayes' rule and you see the Bayes' formula on the

right. And the probability of not having disease

given the positive test result. And then, we see Bayes' rule on the right

for that setting. If you take these two equations and divide

them, you get the following very, very nifty formula.

The probability of diseases given a positive test result, divided by the

probability of not having disease, given a positive test result is equal to the

diagnostic likelihood ratio times the probability of disease divided by the

probability of disease compliment. So, just to simplify this formula a little

bit, we need to talk about odds. So, odds has a formal mathematical

definition. If you say the odds of something is two to

one, that's ratio of two, right, two divided by one, that has an implied

probability of two-thirds that the event occurs and then one-third that the event

does not occur. So, the way you go from probabilities to

odds, is you take the probability and divide it by one minus the probability.

So, in this case, take two-thirds and divide it by one-third, you get two, you

get the odds. To go from odds back to a probability, you

take the odds and then divide by one plus the odds.

In this case, we had two, take two divide it by two plus one or three, you get the

probability, two-thirds and, and then one minus the probability is one-third.

So, if someone were to say, the odds were three to one, then that means the

probability is one-fourth, and the probability of the event not occurring is

one-fourth If the odds are four to one, that means the probability that the event

occurs is four-fifths, and the event that it doesn't occur is one-fifth, okay?

So, hopefully you get the picture. Work out some examples on pen and paper.

Just to let you know if you., if you go to horse racing in the US, it's always the

case that they give you the odds against something happening instead of the odds

for it. So, they're defining odds in terms of the

odds against rather then the odds for. So, at any rate that's just a small thing

if you happen to go gambling this weekend. Okay, so, and this formula has a very

specific form then. The post-test odds of disease, probability

of D given positive test result divided by the probability of D complement given a

positive test results, the post-test odds of D is equal to the diagnostic likelihood

ratio times P(D) divided by P(D) compliment which is the pretest odds of

disease. So, we have some incline of whether or not

a person has the disease just based on prior knowledge before we administer the

test. We obtain the test, and that yields data.

Well, the DLR plus, because it's a positive test, is the factor by which we

multiply our pretest odds to obtain our post-test odds.

So, in the discussion I was talking about earlier, whether the person is an

intravenous drug user and has sex with an HIV positive partner is irrelevant to the

DLR, right? The DLR says, for example, that your odds

of disease has increased by x amount by virtue of having a positive test,

regardless of your prevalence, right? Whereas, the positive and negative

predictive value inherently factor in the prevalence, okay?

So, that's the reason why you get drastically different numbers for these

things. Because they are interpreted in different

ways. So, I also want to talk a little bit about

this idea of Bayesian philosophy and, and regardless of whether you are Bayesian

statistician, Bayesian philosophy is quite appealing.

And this formula that the post-test odd is equal to the likelihood ratio which is

the. Probability model and the data combined

times the pretest odds, it's a very appealing sort of mirror to how we think

the scientific process should work. You start out with an, a priority kind of

waiting of a set of hypotheses. In this case, it's sort of a hypothesis

and its compliment, and you collect data. And that data informs your belief.

And then now, you have a post-test odds of disease.

And then, suppose you were to actually run another test, well, the likely starting

point for your new prior would be the post test odds, or the posterior after your

first test. And it turns out it all works out just

fine that if you take two tests, and they're both positive, your diagnostic

likelihood ratios just multiply. But in terms of Bayesian think, it's the

idea that you have a prior. You update it with data, you get a

posterior. Now, that posterior is your prior.

It also codifies a lot of, of scientific discussion if your prior is absolutely

fixed at a specific point, then the date is irrelevant.

Nothing is going to move you off of it. There's lot of politics is that way of

course. So I think you think about political

discussions in terms of Bayes' rule it's really not very surprising at all.

So, at any rate, let's just go through our HIV example in more detail.

So, suppose someone has a positive HIV test, the DLR plus is 0.997 divided by one

minus 0.985 which works out to be about 66.

So, that means that regardless of your prior behavior in the population you are

coming from, the virtue of this test is that now you have 66 times the pretest

odds of having the disease. Or, you could say, or equivalently, the

hypothesis of disease is 66 times more likely supported by the data, than the

hypothesis of no disease. And then, let's just go through another

example. Suppose that the subject has a negative

testresult. Then, the DLR minus is one minus

0.997divided by 0.985, which works out to be about 0.003.

So, the DLR minus is telling you about your odds of disease, and the result of a

negative test result. So, your factor that you're multiplying by

is 0.003. So now, your post-test odds is 0.3 percent

of your pretest odds, given the negative test.

I wanted to conclude with a discussion on kind of a, a very deep point associated

with these calculations. These calculations are done and there

tends to be very little discussion of how much sense they actually make.

So, if you are, in fact, a Bayesian, then none of this has any problem whatsoever.

Assigning a probability to the Event that an individual has a disease offers no

complications in Bayesian thinking. A probability to a Bayesian is not as much

of an objective thing. It's a quantification of belief.

So, you have your prior belief, you have the component that is independent of your

prior, in, in the diagnostic likelihood ratio, and then you have your posterior

belief. In that, if you're consistent with respect

to Bayes' rule, then your posterior belief has been multiplied appropriately by the

diagnostic likelihood ratio, vis-a-vis the data.

And then you wind up with a very consistent picture.

If you're frequent is, then it's, it's a little bit harder to think about these

things because the standard frequent is sort of boiler play line is that the

person either has the disease or they don't.

There is no probability associated with it and if you are not being a Bayesian in

that probability, its not a mathematical qualification of a belief, then it takes

on a different character. You can still interpret the calculations

though, I would contend may be some hardcore Bayesian would still find issue

with how I am proposing to interpret it as a frequentest, but still, I would say you

are not talking about the probability that this specific subject has the disease in

the frequentest sense because they either have the disease or they don't.

There's no probability left. But what you're talking about, is this

idea of potential fictitious repetitions of this experiment.

And using the probability as a contextual entity to evaluate this person's

probability of disease as contextual entity to evaluate this person's

probability of disease as context, it's probability of lots of people exactly like

this person took this test, what would be the long run percentage of positive test

results that we got? That sort of thinking is what I'm

proposing was the way you could shoe horn these calculations into frequentest

thought. And I think it's probably fine.

Either way, turn through the mathematics in the same exact manner but the

interpretation is quite dicey, and I think it's probably fair to say that most

statistics texts kind of gloss over some of these finer details because, you know,

admittedly they're quite difficult to think about.

The other thing I wanted to briefly touch on is the nature of actually collecting

data to inform these calculations and I touched on this a little bit before but

it's very difficult to know. Conclusively, whether or not someone has a

disease when you are developing a test usually.

And it's very difficult to develop things like actual real prevalence estimates that

are relevant to the person that you are talking about with respect to the disease.

It's also very difficult to have whatever samples you're using to develop

sensitivity and specificity be indicative of the population of samples that the test

will be applied to in actual clinical practice.

So, in the process of saying this, even, even though these calculations are very

simple and they actually highlight Bayes' rule quite nicely, actually, that, that's

the primary point of the lecture, is that they highlight Bayes' rule, and we've

turned through some Bayes' rules calculations.

But I don't want to give you the sense that, that this is all there is to the

world of diagnostic testing and validation, which is a very, very deep

subject, and, and quite a fun subject, I might add, but involves quite a bit more

than Bayes' rule. So, thanks for attending the lecture.

We'll see you next time.