5
$\begingroup$

My homework question:

An inspector suspects that the food in the factory she is inspecting has been contaminated with a harmful chemical c. Such chemical contamination occurs in 5% of factories producing this food. The inspector has a test A for the chemical which registers positive with 100% certainty when the chemical is present, but the test also registers positive in 10% of cases where the chemical is not present. She decides to use this test to help her decide whether there is contamination.

  1. Assume that the prior probability of contamination is equal to the base rate, and that the inspector’s test shows a positive result. Compute the posterior probability of contamination.
  2. The inspector has another test B for chemical c which only registers positive 50% of the time when c is present, but has the advantage of never giving a false positive (i.e., if c is not present, the test will never say it is). The results of the two tests, A and B, are independent given the presence or absence of c. It turns out that when the inspector uses test B, the results are negative. In addition, the inspector knows that the factory is poorly maintained. The rate of contamination in factories with poor maintenance is twice as high as the rate in factories overall. Compute the posterior probability of contamination.

I know these should be rather basic, but I'm getting stuck. For #1 I've reached an answer, but I'm not sure it's correct:

Using Bayes rule the probability should be

$P(c|positive) = \frac{P(positive|c)P(c)}{P(positive)}$

Now I think that $P(positive)$ should be:

$P(positive) = P(positive,c)+P(positive,\neg c) = P(positive|c)P(c) + P(positive|\neg c)P(\neg c)$

Thus:

$P(c|positive) = \frac{P(positive|c)P(c)}{P(positive|c) P(c) + P(positive|\neg c) P(\neg c)}$

$P(c|positive) = \frac{1 * 0.05}{1 * 0.05 + 0.1 * 0.95} = 0.34$

Is this correct?

In part #2 I thought since they are supposed to be independent this must hold:

$ P(A_{positive} \cap B_{negative}|c) = P(A_{positive}|c)*P(B_{negative}|c) $

First I adjusted the base rate and recalculated #1:

$P(c|A_{positive}) = \frac{1 * 0.1}{1 * 0.1 + 0.1 * 0.9} = 0.52$

The questions says: "the results are negative". So B should be:

$P(c|B_{negative}) = \frac{P(B_{negative}|c)P(c)}{P(B_{negative}|c) P(c) + P(B_{negative}|\neg c) P(\neg c)} = \frac{0.5 * 0.1}{0.5 * 0.1 + 1 * 0.9} = 0.05$

$ P(c|A_{positive} \cap B_{negative}) = \frac{P(A_{positive} \cap B_{negative}|c) * P(c)}{P(A_{positive} \cap B_{negative})} = \frac{P(A_{positive}|c) * P(B_{negative}|c) * P(c)}{P(A_{positive} \cap B_{negative})} $

What should I do next?

$\endgroup$
  • $\begingroup$ I think that the problem is that P(A_{+} B-{+} | c) should not be equal to P(A_{+} | c) x P(A_{+} | c); when they are equal they are called conditionally independent. Conditional independence is not the same as independence. $\endgroup$ – schenectady May 5 '11 at 16:08
  • $\begingroup$ Post this as an answer. $\endgroup$ – John Salvatier May 5 '11 at 16:20
  • $\begingroup$ $P(c|B_{\text{positive}}) = 1$ is certainly correct, since you say "B ... has the advantage of never giving a false positive". $\endgroup$ – Henry May 5 '11 at 16:37
  • $\begingroup$ @schenectady could you elaborate on that and maybe post it as an answer? $\endgroup$ – Jakub Hampl May 5 '11 at 17:00
  • $\begingroup$ @Henry yeah after starring at it for like 20 minutes I realize that you are right. Sigh, I feel really dumb now. $\endgroup$ – Jakub Hampl May 5 '11 at 17:02
3
$\begingroup$

It is simpler to start from scratch in your part 2, rather than proceed sequentially. I will show the answer this way, and then show where the step was "wrong" in your approach.

The independence means:

$$P(A_+B_-|c)=P(A_+|c)P(B_-|c)=P(B_-|c)=50\text{%}$$ $$P(A_+B_-|\neg c)=P(A_+|\neg c)P(B_-|\neg c)=P(A_+|\neg c)=10\text{%}$$

Where we have inserted the information given in the question (A never has false negative but 10% false positive, B never has false positive, but 50% false negative). You can use this to calculate the marginal probabilities

$$P(A_+B_-)=P(A_+B_-|c)P(c)+P(A_+B_-|\neg c)P(\neg c)=50\text{%}P(c)+10\text{%}P(\neg c)=14\text{%}$$

Where we have used $P(c)=10\text{%}$, we then have:

$$P(c|A_+B_-)=P(c)\frac{P(A_+B_-|c)}{P(A_+B_-)}=10\text{%}\frac{50\text{%}}{14\text{%}}=36\text{%}$$

Note that this is not derivable from $P(c|A_+)$ and $P(c|B_-)$ alone. The reason is that while $A_+$ and $B_-$ are conditionally independent, they are not unconditionally independent.

Now if we start from $P(c|A_+)=52\text{%}$, we need to multiply by the ratio $$\frac{P(B_-|A_+c)}{P(B_-|A_+)}=\frac{P(B_-|c)}{P(B_-|A_+)}$$

The likelihood when $c$ is true is unchanged because we have the logical relation $c\implies A_+$ which is the same thing as $c\land A_+=c$.

However, to calculate $P(B_-|A_+)$ we have:

$$P(B_-|A_+)=P(B_-|A_+c)P(c|A_+)+P(B_-|A_+\neg c)P(\neg c|A_+)$$ $$=P(B_-|c)P(c|A_+)+\frac{P(B_-A_+|\neg c)}{P(A_+|\neg c)}P(\neg c|A_+)$$ $$=50\text{%}\times 0.52+\frac{10\text{%}}{10\text{%}}\times 0.48=74\text{%}$$

And this is not the same as $P(B_-)=95\text{%}$. Plugging this in we get:

$$p(c|A_+B_-)=52\text{%}\times\frac{50\text{%}}{74\text{%}}=36\text{%}$$

Which is the same the earlier calculation I gave before.

UPDATE

@dmk has asked for some additional explanation about why this answer is intuitively the correct one not the answer given by the more straight-forward:

$$\frac{P(c|A_+B_-)}{P(\neg c|A_+B_-)}=\frac{P(c)}{P(\neg c)}\frac{P(A_+|c)}{P(A_+|\neg c)}\frac{P(B_-|c)}{P(B_-|\neg c)}$$

The answer is: they give the same answer!

$$\frac{P(c|A_+B_-)}{P(\neg c|A_+B_-)}=\frac{0.1}{0.9}\frac{1}{0.1}\frac{0.5}{1}=0.555\dots$$

Converting this to probabilities and we get $\frac{0.555}{1+0.555}=36\text{%}$

So I must retract my comments to @dmk's answer, noting that his procedure was correct, but his calculation was not. $B_-$ is twice as likely to occur if $c$ is not present compared to if it is present. So in his calculation, we modify from $10:9$ odds (after observing $A_+$) to $5:9$ odds (after observing $B_-$)

$\endgroup$
  • $\begingroup$ explain in English? see below $\endgroup$ – dmk38 Jul 6 '11 at 14:35
  • $\begingroup$ got it. Since test b would be negative w/ probability 1 if c was not present & negative w/ probability 0.5 if c was present, the LR for hypothesis "c is present" when there is negative result on b is 0.5. The business about "independent, but only given c or not c" was what didn't compute-- unless there is some quantum mechanics lurking here, "c or not c" exhaust all the possibilities. $\endgroup$ – dmk38 Jul 6 '11 at 19:34
  • $\begingroup$ @dmk38 - it is still true that $A_+$ and $B_-$ are not totally independent - you have to condition on $c$ for this to occur. You can see this because $P(B_-|A_+)=0.74$ whereas $P(B_-)=0.95$. If they were completely independent, these two would be the same. But because the likelihood ratios are conditional on $c$ or $\neg c$, they are independent. I think what is happening is that $A_+$ tells you something about $B_-$, but only through its intermediate influence on $c$ ($A_+\to c \to B_-$). But once you know $c$, $A_+$ becomes irrelevant for $B_-$ (and vice versa) $\endgroup$ – probabilityislogic Jul 7 '11 at 1:25
1
$\begingroup$

part 1:

1:19 (prior odds = 5%) x 10 (likelihood ratio for positive test results = for every 100 true positives there are 10 false positives, so true positive is 10x more likely) = 10:19 (posterior odds) = 34% chance that contaminating agent is present.

part 2:

test a: 1:9 (prior odds = 10%, baserate for presence of agent in poorly maintained plants) x 10 (likelihood ratio for positive test results) = 10:9 (posterior odds) = 53% chance that contaminating agent is present.

test b: 10:9 (prior odds based on test a result & baserate for poorly maintained plants) x 1 (likelihood ratio for negative result-- just as likely to be false negative as true negative) = 10:9 = 53% chance that agent is present.

$\endgroup$
  • $\begingroup$ This part 2 of this answer is actually incorrect, because the two pieces of evidence $A_+$ and $B_-$ are not independent - observing $A_+$ tells you something about the evidence $B_-$. So you cannot proceed by calculating the product of likelihood ratios $\endgroup$ – probabilityislogic Jul 6 '11 at 0:56
  • $\begingroup$ I can accept that my answer is wrong, but how about explain why, & why yours is correct, in plain english. The problem stipulates the test results are independent. And in my analysis, the "information" one gets from test A result is combined with the information one gets from B via Bayes's theorem. This is not an unusual problem--combining results of independent tests w/ known error rates. If I performed 2 drug tests, results of which were independent, results would be combined in the way I have indicated. What is there about the indicated problem that suggests a different approach here? $\endgroup$ – dmk38 Jul 6 '11 at 14:31
  • $\begingroup$ The question states that the test results are independent, but only given $c$ or $\neg c$. So this means that $P(AB|c)=P(A|c)P(B|c)$ and also that $P(AB|\neg c)=P(A|\neg c)P(B|\neg c)$. But this does not mean that $P(AB)=P(A)P(B)$. My answer shows this for we have $P(AB)=0.14$ and $P(A)P(B)=0.17$. You can also show qualitatively that the probability for $c$ must decrease because we have $\neg c \implies B$. Using the "strong syllogism" we have premise: "not c implies B", observation: "B is true", conclusion: "therefore, not c becomes more plausible". $\endgroup$ – probabilityislogic Jul 6 '11 at 16:12
  • $\begingroup$ see my response. Your answer is essentially correct, but you should have multiplied by $0.5$ at stage 2 (because the LR is $0.5$, and not $1$). Then we are in agreement. $\endgroup$ – probabilityislogic Jul 6 '11 at 16:47
0
$\begingroup$

From your independence statement,

\begin{equation} P( A_{+} \bigcap B_{+} ) = P(A_{+} ) P(B_{+}) \nonumber \end{equation} and the definitions

\begin{equation} P(A_{+} \bigcap B_{+} | c) \equiv \frac{P(A_{+} \bigcap B_{+} \bigcap c)}{P(c)} \nonumber \end{equation}

\begin{equation} P(A_{+} | c) \equiv \frac{P(A_{+} \bigcap c)}{P(c)} \nonumber \end{equation} and

\begin{equation} P(B_{+} | c) \equiv \frac{P(B_{+} \bigcap c)}{P(c)} \nonumber \end{equation} can you algebraically show that \begin{equation} P(A_{+} \bigcap B_{+} | c) \equiv \frac{P(A_{+} \bigcap B_{+} \bigcap c)}{P(c)} = \frac{P(A_{+} \bigcap c)}{P(c)} \frac{P(B_{+} \bigcap c)}{P(c)} \equiv P(A_{+} | c) P(B_{+} | c) \nonumber \end{equation}

$\endgroup$
  • $\begingroup$ your premise $P(AB)=P(A)P(B)$ is not what @honitom assumed, or what the question wording says. Its actually your conclusion that is put as the assumption "...The results of the two tests, A and B, are independent given the presence or absence of c..." Which means $P(AB|c)=P(A|c)P(B|c)$ and $P(AB|\neg c)=P(A|\neg c)P(B|\neg c)$. And further, the relation $P(ABC)=P(AC)P(BC)$ is not a general one. e.g. take A="is female human" B="is male human" C="is human", Then we have $P(AC)=P(A)$ $P(BC)=P(B)$ but $P(ABC)=0$ (more abstract take $A=\neg B$ and $C=A\lor B$) $\endgroup$ – probabilityislogic Jul 5 '11 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.