In this video, we will continue with the HIV testing example to introduce

the concept of Bayes factors.

Earlier, we introduced the concept of priors and posteriors.

The prior odds is defined as the ratio of the prior probabilities

assigned to the hypotheses or models we're considering.

So if there are two competing hypotheses being considered,

then the prior odds of hypothesis one to hypothesis two can be defined as

O of H1 to H2, which is equal to the probability of H1 over probability of H2.

Similarly, the posterior odds is the ratio of the two posterior probabilities of this

hypotheses.

That is PO of H1 to H2 is the probability of H1 given data

divided by the probability of H2 given data.

Using Bayes rule, we can rewrite the posterior probabilities as the probability

of the data given the hypothesis times the prior for

that hypothesis divided by the probability of data.

The probability of data in both the numerator and denominator cancels, and

we can reorganize this as the ratio of the data given H1 and

data given H2 times the ratio of the prior probabilities of these hypothesis.

The first quantity, the ratio of the probabilities of data given these two

hypotheses is defined as the Bayes factor.

And the second quantity is the prior odds that we saw earlier.

In other words, the posterior odds is the product of the bayes factor and

the prior odds for these two hypotheses.

The Bayes factor quantifies the evidence of data arising from hypothesis one

versus hypothesis two.

In a discrete case, this is simply the ratio of the likelihoods of the observed

data under the two hypotheses or models.

However, in a continuous case, it's the ratio of the marginal likelihoods.

In this way,

we are considering all possible values of the model parameters theta.

In this video, we will stick with the simpler discrete case.

And in upcoming videos,

we will revisit calculating Bayes factors for more complicated models.

Let's return to the HIV testing example from earlier,

where our patient had tested positive in the ELISA.

Remember that our hypotheses, our patient does not have HIV, and patient has HIV.

The prior probabilities we place on these hypothesis came from the prevalence of

HIV at the time in the general population.

We were told that the prevalence of HIV in the population was 1.48 out of 1000,

hence the prior probability assigned to hypothesis 2 is 0.00148.

And the prior assigned to hypothesis 1 is simply the complement of this.

Hence, the prior odds can be calculated as the ratio of these two values,

which comes out to approximately 674.68.

We also calculated posterior probabilities of these hypotheses given a positive

result.

These were approximately 0.88 and 0.12.

We'll hold on to more decimal places in our calculations to avoid rounding

errors later.

Hence, the posterior odds is approximately 7.25,

then we can calculate the Bayes factor as the ratio of the posterior

odds to prior odds which comes out to approximately 0.0108.

Note that in this simple discrete case the Bayes factor, it simplifies to

the ratio of the likelihoods of the observed data under the two hypotheses.

Remember that the true positive rate of the test was 0.93 and

the false positive rate was 0.01.

Using these two the base factor also comes out to approximately 0.0108.