Bayes' rule at work

The probability of Infected or Not Infected, given the result of the test, is easily calculated using a simple rule of probability theory known as Bayes' theorem (or Bayes' rule),10thus obtaining, for the two probabilities to which we are interested (the other two are obtained by complement),
$\displaystyle P($Inf$\displaystyle \,\vert\,$Pos$\displaystyle )$ $\displaystyle =$ $\displaystyle \frac{P(\mbox{Pos}\,\vert\,\mbox{Inf})\cdot P_0(\mbox{Inf})}
{P(\mbox{Pos}) }$ (6)
       
$\displaystyle P($NoInf$\displaystyle \,\vert\,$Neg$\displaystyle )$ $\displaystyle =$ $\displaystyle \frac{P(\mbox{Neg}\,\vert\,\mbox{NoInf})\cdot P_0(\mbox{NoInf})}
{P(\mbox{Neg})}\,,$ (7)

where $P_0()$ stands for the initial, or prior probability, i.e. `before'11the information of the test result is acquired, i.e. the degree of belief we attach to the hypothesis that a person could be e.g. infected, based on our best knowledge of the person (including symptoms and habits) and of the infection. As we have already said, if the person is chosen absolutely at random, or we are unable to form our mind even having the person in front of us, we can only use for $P_0($Inf$)$ the proportion $p$ of infected individuals in the population, or assume a value and provide probabilities conditioned by that value, as we shall do in a while. Therefore, hereafter the two `priors' will just be $P_0($Inf$)= p$ and $P_0($NoInf$)= 1-p$.

Applying another well known theorem, since the hypotheses Inf and NoInf are exhaustive and mutually exclusive, we can rewrite the above equations as

$\displaystyle P($Inf$\displaystyle \,\vert\,$Pos$\displaystyle )$ $\displaystyle =$ $\displaystyle \frac{P(\mbox{Pos}\,\vert\,\mbox{Inf})\cdot P_0(\mbox{Inf})}
{P(\...
...dot P_0(\mbox{Inf})+P(\mbox{Pos}\,\vert\,\mbox{NoInf})\cdot P_0(\mbox{NoInf}) }$ (8)
       
$\displaystyle P($NoInf$\displaystyle \,\vert\,$Neg$\displaystyle )$ $\displaystyle =$ $\displaystyle \frac{P(\mbox{Neg}\,\vert\,\mbox{NoInf})\cdot P_0(\mbox{NoInf})}
...
... P_0(\mbox{Inf})+P(\mbox{Neg}\,\vert\,\mbox{NoInf})\cdot P_0(\mbox{NoInf}) }\,.$ (9)

In our model $P($Pos$\,\vert\,$Inf$)$ and $P($Neg$\,\vert\,$NoInf$)$ depend on our assumptions on the parameters $\pi_1$ and $\pi_2$, that is, including the other two probabilities of interest,
$\displaystyle P($Pos$\displaystyle \,\vert\,$Inf$\displaystyle , \pi_1)$ $\displaystyle =$ $\displaystyle \pi_1$ (10)
$\displaystyle P($Pos$\displaystyle \,\vert\,$NoInf$\displaystyle , \pi_2)$ $\displaystyle =$ $\displaystyle \pi_2\,,$ (11)
$\displaystyle P($Neg$\displaystyle \,\vert\,$Inf$\displaystyle , \pi_1)$ $\displaystyle =$ $\displaystyle 1- \pi_1$ (12)
$\displaystyle P($Neg$\displaystyle \,\vert\,$NoInf$\displaystyle , \pi_2)$ $\displaystyle =$ $\displaystyle 1-\pi_2\,,$ (13)

In the same way we can rewrite Eqs. ([*]) and ([*]), adding, for completeness, also the other two probabilities of interest, as
$\displaystyle P($Inf$\displaystyle \,\vert\,$Pos$\displaystyle ,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{\pi_1\cdot p}
{\pi_1\cdot p + \pi_2\cdot (1-p)}$ (14)
$\displaystyle P($NoInf$\displaystyle \,\vert$Neg$\displaystyle ,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{(1-\pi_2)\cdot (1-p)}
{(1-\pi_1)\cdot p + (1-\pi_2)\cdot (1-p)}\,.$ (15)
$\displaystyle P($NoInf$\displaystyle \,\vert\,$Pos$\displaystyle ,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{\pi_2\cdot (1-p)}{\pi_1\cdot p + \pi_2\cdot (1-p)}$ (16)
$\displaystyle P($Inf$\displaystyle \,\vert\,$Neg$\displaystyle ,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{(1-\pi_1)\cdot p}
{(1-\pi_1)\cdot p + (1-\pi_2)\cdot (1-p)}\,.$ (17)

We also remind that the denominators have the meaning of `a priori probabilities of the test results', being
$\displaystyle P($Pos$\displaystyle \,\vert\,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \pi_1\cdot p + \pi_2\cdot (1-p)$  
$\displaystyle P($Neg$\displaystyle \,\vert\,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle (1-\pi_1)\cdot p + (1-\pi_2)\cdot (1-p)\,.$  

For example, taking the parameters of our numerical example ($p=0.1$, $\pi_1=0.98$ and $\pi_2=0.12$), an individual chosen at random is expected to be tagged as positive or negative with probabilities 20.6% and 79.4%, respectively.
Figure: Probability that an individual chosen at random will result Positive (red lines with positive slope) or Negative (green lines, negative slope) as a function of the assumed proportion of infectees in the population. Solid lines for $\pi_1=0.98$ and $\pi_2=0.12$; dashed for $\pi_1=0.98$ and $\pi_2=0.02$; dotted for $\pi_1=0.99$ and $\pi_2=0.01$; dashed-dotted for $\pi_1=0.999$ and $\pi_2=0.001$.
\begin{figure}\begin{center}
\epsfig{file=Prob_Pos-Neg.eps,clip=,width=\linewidth}
\\ \mbox{} \vspace{-1.0cm} \mbox{}
\end{center}
\end{figure}
Figure [*] shows these two probabilities as a function of $p$ for some values of $\pi_1$ and $\pi_2$.

Figure: Probability of `Infected if tagged as Positive' $[\,P($Inf$\,\vert\,$Pos$)$, red line, null at $p=0\,]$ and probability of `Not Infected if tagged as Negative' $[\,P($NoInf$\,\vert\,$Neg$)$, green line, null at $p=1\,]$ as a function of $p$, calculated from Eqs. ([*]) and ([*]) for $\pi_1=0.98$ and $\pi_2=0.12$ (solid lines). For comparison, we have also included (dashed lines) the case of $\pi_2$ reduced to 0.02, thus increasing the `specificity' to 0.98. Then there are the cases of a higher quality test $[\pi_1=(1-\pi_2)=0.99]$, shown by dotted lines and of an extremely good test $[\pi_1=(1-\pi_2)=0.999)]$ shown by dotted-dashed lines. (The probabilities to tag an individual, chosen at random, as positive or negative, for the same sets of parameters, were shown in Fig. [*].)
\begin{figure}\begin{center}
\epsfig{file=TruePosTrueNegBayes.eps,clip=,width=\linewidth}
\\ \mbox{} \vspace{-1.0cm} \mbox{}
\end{center}
\end{figure}
Figure [*] shows, by solid lines, $P($Inf$\,\vert\,$Pos$,\pi_1,\pi_2,p)$ and $P($NoInf$\,\vert$Neg$,,\pi_1,\pi_2,p)$ as a function of $p$, having fixed $\pi_1$ and $\pi_2$ at our nominal values 0.98 and 0.12. They are identical to those of Fig. [*], the only difference being the label of the $y$ axis, now expressed in terms of conditional probabilities. In the same figure we have also added the results obtained with other sets of parameters $\pi_1$ and $\pi_2$, as indicated directly in the figure caption.12

Analyzing the above four formulae, besides the trivial ideal condition obtained by $\pi_1=1$ and $\pi_2=0$, one can make a risk analysis in order to optimize the parameters, depending on the purpose of the test. For example, we can rewrite Eq. ([*]) as

$\displaystyle P($Inf$\displaystyle \,\vert\,$Pos$\displaystyle ,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{1}{1+ \frac{\pi_2}{\pi_1}\cdot\frac{(1-p)}{p}}\,:$ (18)

if we want to be rather sure that a Positive is really infected, then we need $\pi_2/\pi_1\ll 1$, unless $p\approx 1$. Similarly, we can rewrite Eq. ([*]) as
$\displaystyle P($NoInf$\displaystyle \,\vert$Neg$\displaystyle ,,\pi_1,\pi_2,p)$ $\displaystyle =$ $\displaystyle \frac{1}{1 + \frac{1-\pi_1}{1-\pi_2}\cdot \frac{p}{1-p}}\,:$  

in this case, as we have learned, in order to be quite confident that the negative test implies no infection, we need $(1-\pi_1)\ll 1$, that is, for realistic values of $\pi_2$, a value of $\pi_1$ practically equal to 1, unless $p$ is rather small, as we can see from Fig. [*]. (In order to show the importance to reduce $\pi_2$, rather than to increase $\pi_1$, in the case of low proportion of infectees in the population, we show in Fig. [*] the results based on some other sets of parameters.)
Figure: Same as Fig. [*], but with different parameters. Solid lines: $\pi_1=0.99$ and $\pi_2=0.10$. Dashed lines (the red one, describing $P($Inf$\,\vert\,$Pos$)$ overlaps perfectly with the continuous one): $\pi_1=0.999$ and $\pi_2=0.10$. Dotted lines (the green one, describing $P($NoInf$\,\vert\,$Neg$)$, almost overlaps the solid one): $\pi_1=0.99$ and $\pi_2=0.01$.
\begin{figure}\begin{center}
\epsfig{file=TruePosTrueNegBayes_1.eps,clip=,width=\linewidth}
\\ \mbox{} \vspace{-1.0cm} \mbox{}
\end{center}
\end{figure}