\magnification=\magstep1
\centerline{MONT 107N -- Understanding Randomness}
\centerline{Lecture Notes on Bayes' Rule}
\centerline{January 27, 2010}
\bigskip
\noindent
{\it What Bayes' Rule says, and why it is true}
\bigskip
Bayes' Rule is a probability statement about the relation between
the two conditional probabilities $P(A|B)$ and $P(B|A)$.  As 
an equation (the clearest form, I think!), it says:  For any
two events (with $P(A),P(B) \ne 0$),
$$
P(B|A) = P(A|B)\cdot {P(B)\over P(A)}.  \leqno(1)
$$
The reason it works this way is because of the definition
of the conditional probability:
$$
P(A|B) = {P(A\ {\rm and}\ B)\over P(B)}.  \leqno(2)
$$
Applying this to $P(B|A)$, we can manipulate and rearrange 
algebraically as follows:
$$\eqalign{
P(B|A) &= {P(B\ {\rm and}\ A) \over P(A)}\cr
       &= {P(A\ {\rm and}\ B) \over P(B)}\cdot {P(B)\over P(A)}\cr
       &= P(A|B) \cdot {P(B)\over P(A)},\cr
}$$
which shows what we wanted to establish from (1).
\bigskip
\noindent
{\it An context where ``Bayesian'' reasoning is important}
\bigskip
One important example of the sometimes unexpected consequences
of Bayes' Rule is the interpretation of medical diagnostic
tests (for example the kind of routine screening tests that
are now commonly given as part of annual physical exams).  

Let $A = $ the event that a test gives a ``positive'' result. 
(That is, the test says that you actually have the condition
the test is designed to detect -- usually some illness or 
disease).  Let $B = $ be the event that you actually have
that illness or disease. 

In designing medical diagnostic tests, doctors are often
most concerned with understanding the following two
probabilities:
\medskip
\item{$\bullet$} $P(A|B) = $ the {\it sensitivity} of the 
test.  This measures how likely the test is to give a positive
result, {\it given that the person to whom the test is administered
actually has that condition}.  
\item{$\bullet$} $P({\rm not}\ A |{\rm not}\ B) = $ the {\it specificity}
of the test.  This measures how likely the test is to 
give a negative result {\it when the person to whom the test
is administered does not have that condition}.
\medskip
\noindent
Values as close to $1$ as possible in both cases are usually 
the goal.  

So far we have been looking at the diagnostic test essentially
from the point of view of a doctor or medical researcher 
analyzing how well the test operates.  But of course, {\it most
of us} are more likely to be in another situation -- that 
of a patient (or a loved one of a patient) when the patient
gets one of these tests and then must deal with the consequences
of a ``positive'' result.  Now, how sensitive or specific
the test is are much less important than trying to assess
{\it a different probability}:  Given that the test gave
a positive result, what is the probability that the condition
or disease is actually present?  In symbols, this asks for
the ``reverse'' probability:  $P(B|A)$.  Note that this 
is exactly the situation dealt with by Bayes' Rule from (1)(!)
Knowing $P(A|B)$, we want to determine $P(B|A)$. 

\bigskip
\noindent
{\it An Example}
\bigskip
Suppose the test was relatively sensitive {\it and} relatively
specific:  $P(A|B) = .9$ and $P({\rm not}\ A|{\rm not}\ B) = .9$.  
But now, let us also assume that the condition or disease is 
{\it relatively rare}.  For instance, suppose that only about
1 in 1000 people actually have it, so that if we look at the 
results of giving the test to the whole population of patients,
$P(B) = .001$.  The question is:  What is $P(B|A)$ in this case? 

\bigskip
\noindent
(Note: It is important to realize that
the way we are analyzing this question only makes sense
if we are considering the whole population of patients.  The 
statement $P(B) = .001$ means that if we {\it randomly selected 
patients} a large number of times, then the selected
patient would have the disease about 1 out of 1000 times.
We are not claiming anything about any particular patient.)

\bigskip
If we look at (1) again, we can see that we know all of the 
information on the right side at this point, {\it except} $P(A)$,
the probability of getting a positive test result (whether or
not the patient has the condition or disease).  We can figure 
this out, though, as follows.  The positive test results
are entirely made up of either ``true positives'' or ``false positives''
(``false positives'' are cases where the result of the test is wrong --
the patient does not have the condition, but the test says that they 
do).  So, in symbols
$$ P(A) = P(A\ {\rm and}\ B) + P(A\ {\rm and\ not}\ B).$$
By (2), this can be rewritten as
$$ P(A) = P(A|B)P(B) + P(A|{\rm not}\ B)P({\rm not}\ B).\leqno(3)$$
Here, we know from the information we have that 
$P(A|B) = .9$, $P(B) = .001$, and 
$P({\rm not}\ B) = 1 - .001 = .999$.  The only unknown
is $P(A|{\rm not}\ B)$.  However, if we assume the condition 
${\rm not} B$, then either $A$ happens or not.  This shows
that 
$$P(A|{\rm not}\ B) = 1 - P({\rm not}\ A|{\rm not}\ B) = 1 - .9 = .1$$
(from the given specificity value).  Hence, from (3), we now have
$$P(A) = (.9)(.001) + (.1)(.999) = .1008. \leqno(4)$$
Then from (1) 
$$P(B|A) = P(A|B)\cdot {P(B)\over P(A)} = (.9)\cdot {.001\over .1008} \doteq .0089.$$
In other words, there is a bit less than a $1\%$ chance that you 
have the condition, given that the test results were positive.
\bigskip
\noindent
{\it Discussion of the example}
\bigskip
\item{$\bullet$}
The value of $P(B|A)$ should be shockingly, even {\it distressingly} small
(from the point of view of the doctors who designed the test, anyway!)
\item{$\bullet$}  On the other hand, it is also not hard to 
see that with the given numbers, the probability of 
not having the disease, given that the test results are 
{\it negative}, or $P({\rm not} B|{\rm not} A)$, is {\it very close
to} $1$.  So if your test result is negative, you can breathe
a lot easier(!)
\item{$\bullet$}  The underlying {\it reason} for the way the
example comes out is that 
when the condition is rare, {\it a large majority of the positive
test results are actually ``false positives''} -- the ``false positive'' 
term $(.1)(.999)$ in (4) is much larger than the ``true positive'' term
$(.9)(.001)$.  
\item{$\bullet$}  A question you might ask is:  What happens
if the disease or condition is {\it more common}?  For instance, 
say $P(B) = .05$  (about 1 in 20 people have the condition),
instead of $P(B) = .001$.  But still assume the 
sensitivity and specificity are $.9$.  If you do the computations in that 
case, then you will see:
$$P(A) = (.9)(.05) + (.1)(.95) = .14$$
and then from (1),
$$P(B|A) = (.9)\cdot {(.05)\over (.14)} \doteq .32$$
(about a $32\%$ chance).  This is not as small as in the other case,
but still probably a lot smaller than we would expect intuitively.
In fact, if you play around with some other cases, you can see that
with the sensitivity and specificity both $.9$, $P(B|A) < .9$
for all values of $P(B) < .1$.
\item{$\bullet$}  Another question you might ask is: Well couldn't the
problem be that the test is not sensitive or specific enough?
Suppose those probabilities were $.99$, but $P(B) = .001$?  It is 
not difficult to see that in those cases, $P(B|A)$ is still
significantly smaller than we might expect intuitively.  And if
the condition were less common -- $P(B) < .001$, we could 
get similar results as in the main example no matter how close
the sensitivity and specificity were to $1$(!)

\bye
