# Bayes Theorem application for second testing based on first test result

I am currently trying to answer this question and am though a bit confused on how to apply Bayes Theorem when a second test is performed based on the result of the first.

A test to determine who is under the influence of a drug has a probability of 0.8 of being correct (i.e for both positive and negative results).

If the test is positive, a second different test is carried out. The second test always correctly detects if the patient is in fact not under under the influence of the drug, but has a 10% error rate with drug users/under the influence.

If 20% of the patients tested are actually users/under the influence we are asked to calculate:

a) Proportion of patients that have to be given the second test (i.e proportion of testing positive on the first test) b) probability patients testing positive on the first test are really under the influence/drug users c) probability that patients testing negative on the second test are actually under the influence/drug users;

For a) I am not sure I've arrived at the correct solution,as its 30% more than the population of 20% who are actually users.

d - drug user/under the influence c - not under the influence/not a drug user

$$P(d|+) = \frac{P(+|d)*P(d)}{P(+)*P(+|d) + P(+|c)*P(c)} = \frac{0.2*0.8}{(0.2*0.8 + 0.2*0.8)} = 0.50$$ i.e % 50% of patients will test positive on first test

b) I am immediately confused by this question and c). I have followed the rationale of this question Conditional probability and testing twice, and found the answer below:

P1 = first test P2 = second test

Then the desired probability is $$\Pr[P_2 \mid P_1] = \frac{\Pr[P_2 \cap P_1]}{\Pr[P_1]} = \frac{\Pr[P_2 \cap P_1 \mid d]\Pr[d] + \Pr[P_2 \cap P_1 \mid c]\Pr[c]}{\Pr[P_1 \mid d]\Pr[d] + \Pr[P_1 \mid c]\Pr[c]} = \frac{(0.8+0.9)*0.2 + (0.8+1)*0.8}{0.8*0.2 + 0.8*0.8} = 5.5625$$

This is obviously not correct, I am not sure where I went wrong here. Any hints/answers are welcomed I am new to Bayesian Theory.

## 1 Answer

A quick check if there are $$1000$$ individuals:

• We expect $$200$$ to be actual users and $$800$$ to be non-users
• Of the $$200$$ expected actual users we expect $$160$$ to test positive on the first test and $$40$$ to test negative
• Of the $$800$$ expected non-users we expect $$160$$ to test positive on the first test and $$640$$ to test negative
• Of the $$160$$ expected actual users who tested positive on the first test, we expect $$144$$ to test positive on the second test and $$16$$ to test negative
• Of the $$160$$ expected non-users who tested positive on the first test, we expect all $$160$$ to test negative on the second test

If you do not like starting with $$1000$$ people then start with $$1$$, divide all the numbers above by $$1000$$ and you have proportions of the population

This suggests your answers should have been

a) $$\frac{160+160}{1000}=0.32$$ proportion of total population who test positive on the first test and are given the second test

b) $$\frac{160}{160+160}=0.5$$ proportion of those testing positive on the first test who are actual users

c) $$\frac{16}{16+160}\approx 0.091$$ proportion of those testing negative on the second test who are actual users

Your final expression was indeed wrong. For example $$\Pr[P_2 \cap P_1 \mid d] \not = \Pr[P_2 \mid d]+\Pr[P_1 \mid d]$$

• Hi, thanks for providing an answer this makes perfect sense to me and at least now I have a way of checking my answers. Regardless, I am still struggling to apply the Bayes theorem, I can't get 0.32 for a) no matter how many variations I try :/ I am following en.wikipedia.org/wiki/Bayes%27_theorem#Drug_testing. A simple analogous application to my problem still gives me 50%. Mar 23, 2020 at 19:03
• @CandiCC99 In your notation $P(+) = P(+ \mid d)P(d)+P(+ \mid c)P(c) = 0.8\times 0.2+0.2 \times 0.8=0.32$ Mar 23, 2020 at 19:10
• Ah OK so for a) we are not actually meant to use Bayes Theorem. After having a look further on my notes and wikipedia, it makes sense to translate the question as a request for a Bayesian prediction, en.wikipedia.org/wiki/Bayesian_inference#Bayesian_prediction. Given we want to predict individuals going into the second test and assess whether they are drug users or not. Thanks for the prompt clarifications! Will now try b) and c). Mar 23, 2020 at 19:45