Follow A Bayesian, Or People Die!#
๐๐ฉ๐ช๐ด ๐ช๐ด ๐ข ๐ธ๐ณ๐ช๐ต๐ฆ-๐ถ๐ฑ ๐ฐ๐ง ๐ด๐ฐ๐ฎ๐ฆ ๐ต๐ฉ๐ฐ๐ถ๐จ๐ฉ๐ต๐ด ๐ ๐ฉ๐ข๐ฅ ๐ข๐ต ๐ต๐ฉ๐ฆ ๐ฃ๐ฆ๐จ๐ช๐ฏ๐ฏ๐ช๐ฏ๐จ ๐ฐ๐ง ๐ต๐ฉ๐ฆ ๐ฑ๐ข๐ฏ๐ฅ๐ฆ๐ฎ๐ช๐ค, ๐ญ๐ฐ๐ฐ๐ฌ๐ช๐ฏ๐จ ๐ฃ๐ข๐ค๐ฌ ๐ต๐ฐ ๐ด๐ฐ๐ฎ๐ฆ ๐ข๐ด๐ฑ๐ฆ๐ค๐ต๐ด ๐ฐ๐ง ๐ต๐ฉ๐ฆ ๐๐ณ๐ฆ๐ฒ๐ถ๐ฆ๐ฏ๐ต๐ช๐ด๐ต ๐ท๐ด. ๐๐ข๐บ๐ฆ๐ด๐ช๐ข๐ฏ ๐ฅ๐ฆ๐ฃ๐ข๐ต๐ฆ. ๐โ๐ฎ ๐ฏ๐ฐ๐ต ๐ช๐ฏ ๐ต๐ฉ๐ฆ ๐ฑ๐ฐ๐ด๐ช๐ต๐ช๐ฐ๐ฏ ๐ต๐ฐ ๐ข๐ฅ๐ฅ ๐ข๐ฏ๐บ๐ต๐ฉ๐ช๐ฏ๐จ ๐ฏ๐ฆ๐ธ ๐ต๐ฐ ๐ต๐ฉ๐ฆ ๐ต๐ฐ๐ฑ๐ช๐ค, ๐ฃ๐ถ๐ต ๐ ๐ธ๐ช๐ญ๐ญ ๐ถ๐ด๐ฆ ๐ต๐ฉ๐ฆ ๐ฏ๐ฆ๐ธ๐ด ๐ฐ๐ง ๐ต๐ฉ๐ข๐ต ๐ต๐ช๐ฎ๐ฆ ๐ต๐ฐ ๐จ๐ช๐ท๐ฆ ๐ข๐ฏ ๐ฆ๐น๐ข๐ฎ๐ฑ๐ญ๐ฆ ๐ธ๐ฉ๐ฆ๐ณ๐ฆ ๐๐ณ๐ฆ๐ฒ๐ถ๐ฆ๐ฏ๐ต๐ช๐ด๐ต ๐ข๐ฏ๐ฅ ๐๐ข๐บ๐ฆ๐ด๐ช๐ข๐ฏ ๐จ๐ช๐ท๐ฆ ๐ฅ๐ช๐ง๐ง๐ฆ๐ณ๐ฆ๐ฏ๐ต ๐ข๐ฏ๐ด๐ธ๐ฆ๐ณ๐ด. ๐๐ต ๐ช๐ด ๐ข ๐ค๐ญ๐ข๐ด๐ด๐ช๐ค ๐ค๐ฐ๐ฏ๐ฅ๐ช๐ต๐ช๐ฐ๐ฏ๐ข๐ญ ๐ด๐ต๐ข๐ต๐ช๐ด๐ต๐ช๐ค๐ข๐ญ ๐ช๐ฏ๐ง๐ฆ๐ณ๐ฆ๐ฏ๐ค๐ฆ, ๐ฆ๐ข๐ด๐บ ๐ช๐ง ๐บ๐ฐ๐ถ ๐ฉ๐ข๐ท๐ฆ ๐ข ๐ฅ๐ฆ๐ฆ๐ฑ ๐ถ๐ฏ๐ฅ๐ฆ๐ณ๐ด๐ต๐ข๐ฏ๐ฅ๐ช๐ฏ๐จ ๐ฐ๐ง ๐ต๐ฉ๐ฆ ๐ฅ๐ช๐ง๐ง๐ฆ๐ณ๐ฆ๐ฏ๐ค๐ฆ๐ด ๐ฃ๐ฆ๐ต๐ธ๐ฆ๐ฆ๐ฏ ๐๐ณ๐ฆ๐ฒ๐ถ๐ฆ๐ฏ๐ต๐ช๐ด๐ต ๐ข๐ฏ๐ฅ ๐๐ข๐บ๐ฆ๐ด๐ช๐ข๐ฏ ๐ด๐ต๐ข๐ต๐ช๐ด๐ต๐ช๐ค๐ด, ๐ฃ๐ถ๐ต ๐ข๐ญ๐ด๐ฐ ๐ฆ๐ข๐ด๐บ ๐ต๐ฐ ๐จ๐ฐ ๐ธ๐ณ๐ฐ๐ฏ๐จ ๐ช๐ง ๐บ๐ฐ๐ถ ๐ฅ๐ฐ๐ฏโ๐ต.
The title is inspired by a quote from Col. Jessup (interpreted by Jack Nicholson) in A Few Good Man movie.
โWe follow orders, son.
We follow orders or people die.
Itโs that simple.โ
A truly legendary performance!
Disclaimer
Despite the provocative title, and how sometimes the Frequentist approach to these kind of problems is mis-represented in many accounts you find on the web (too many unfortunately of low quality, try to Google it!), I do not advocate the view that Frequentist is bad and you should always use Bayesian! .
The usual advice is to always choose wisely (obviously!).
My goal is to persuade you that in order to do so you must understand both well! (thatโs the real trick!).
Disclaimer 2
For a deep, practical and very well done discussion on this topic I strongly suggest to have a look at what Jake VanderPlas has written in his blog. Here I followed his approach in presenting these kind of problems.
Issues With Early Covid-19 Samples#
At the beginning of the pandemic (Feb-Mar 2020) we knew very little about this new disease and, above all, how extended was spread and how deadly it was. The only available information, repeated tirelessly by the media, were about the number and fraction of people tested positive, how many of them needed hospitalization and, unfortunately, the number of deaths.
What added even more rage for people like me that digest data for a living, was the mis-use and mis-interpretation of those numbers and figures. Both by traditional media and, exponentially magnified, by the totally uncontrolled arena of social media.
In fact, it was clear to anybody with minimal statistic background that all the extrapolations about the spread, seriousness, death rate, etcโฆ of the disease (statistic inference in our jargon) from the daily rate of infection announcements (as the number positives over the total tests done) was completely meaningless and totally biased.
What it was needed - as many pointed out - was a controlled testing on a randomly selected sample of people. Unfortunately at that time it was not possible to do it. The limited supply of testing kits that were prioritized to key workers and people with symptoms. That was totally understandable.
But the inability to produce unbiased data was not a justification to use biased data as an alternative!!
However there was an important exception to this lack of unbiased data: the Diamond Princess cruise ship (and others later).
Because of the isolated environment and relatively low number, all passengers were tested independently from the fact they reported symptoms or not.
For some time, the data from cruise ships have been the only unbiased ones available. Many scientists used these data for early studies of the Covid-19 (i.e. โWhat the cruise-ship outbreaks reveal about COVID-19โ published in Nature on 26 March 2020)
A Statistical Problem on Conditional Inference#
Those dramatic events at early stage of the pandemic reminded me examples of conditional inferences, an advanced statistical concept. They are fairly well known, with first examples dating back to the reverend Thomas Bayes in 1763, that discussed a โbilliard problemโ in his paper.
Almost any book on Statistics has a version of these kind of problems, and for a good reason! They really challenge your understanding of statistical inference, and make you appreciate the subtleties behind the Frequentist and Bayesian approach to probability.
It is only after a full understanding of these subtleties that you can really be in a position to โchoose wiselyโ!
A Covid-19 Infected Cruise Ship Problem
A cruise ship docked on the port you are responsible for. They have reported people with Covid-19 symptoms. All passengers have being tested, and you have to dispatch ambulances to take people tested positive in dedicated hubs for treatment.
You assess the situation as the following:
So far M=35 passengers got their Covid-19 test results, with Q=7 tested positive.
They have been already disembarked and taken care accordingly
There are still N=70 people on board, with the Covid-19 test results still pending.
You only have K=22 ambulances left.
One ambulance can carry only one positive passenger.
At this point you get a call from the crisis center headquarter asking you if you need more ambulances. They explain that ambulances are needed everywhere and this will be your only chance to have more ambulances. However you should only ask what is deemed necessary, many people lives are at stake.
Clearly to be 100% safe, you should have 70 ambulances; you will be covered no matter what.
But ambulances are scarce, so you decide to take a reasonable risk: you will ask for more ambulances only if the probability that 22 ambulances are not enough is higher than 10%
What you should answer then?
Will the number of positive tests on the remaining 70 passengers be greater than 22 with a probability higher than 10% ?
Some possible answers#
There are many ways to reason about this problem, I will discuss four of them:
- Frequentist Approach
This is how a Frequentist might answer
- Bayesian Approach
This is how a Bayesian will probbably answer
- Professional Approach
This is how a Professional statistician may answer
- Caveman Approach
This is how a person knowing nothing or enough about conditional probability, maximum likelihood, nuisance parameters, Beta-Binomial distribution, etcโฆ , but with very good coding skills, might answer. A DevOps or MLOps engineer for example.
In the following we assume the first 35 people were randomly selected, i.e. their rate of infection is the same as the remaining 70 passengers (never ever ever give priority to woman, children or elderly as a statistician,it will totally bias your sample!!).
A frequentistic approach could go like this:
The actual (true) infection rate is \(\rho\). We donโt know it, but we can infer our best guess by the measurements we have.
For any given passenger already tested, we can calculate the probability (binomial) distribution of the observation (positive or not), given \(\rho\).
As we have \(M=35\) observations, we can calculate the likelihood \(\mathcal{L}(\rho)\) of observing \(Q=7\) positives as join probability of \(M\) independent observations
Finally we calculate which value of \(\rho\) maximize the likelihood \(\mathcal{L}(\rho)\) of observing the measurements we observe. That result \(\hat{\rho}\) is our best guess for \(\rho\).
After all those steps and calculations we find that our best guess \(\hat{\rho}\) is (surprise!):
Since the infection rate is the same for all passengers, the probability of \(K\) positive cases out of the remaining \(N\) passengers is easy to calculate (binomial probability):
In particular we want to know the overall probability \(\mathcal{P}(K_{max})\) that the number of positive cases is above \(K_{max} = 22\):
If \(\mathcal{P}(K_{max})\) is above 10% the risk is too high, and we need more ambulances.
A bayesian will treat this problem as a simple case of conditional probability with a nuisance parameter to marginalize
Letโs define for clarity:
- A
there are \(K\) positive cases among the \(N=70\) passenger on board
- D
the data we have, i.e. there are \(Q=7\) positive cases among the \(M=35\) passengers already tested
- \(\rho\)
the unknown infection rate
What we want is \(P(A,\rho|D)\), and since \(\rho\) is unknown, it is marginalized:
The trick now is to manipulate this expression until we get something we know how to calculate. Using the law of conditional probability (\(P(A\cap B) = P(A|B) \cdot P(B)\)) and the Bayesโ theorem we have:
Using the binomial probability, we also have:
The last bit is what to put for \(P(\rho)\), the prior on the probability distribution of \(\rho\). What we can say is that it can be equally anything between 0 and 1 (flat distribution, \(P(\rho)=c\)). Put everything together:
After calculating these simple integrals, we get the conditional probability to observe \(K\) positives on the remaining passengers:
We can get the overall probability \(\mathcal{P}(K_{max})\) that the number of positive cases is above \(K_{max} = 22\) from :
A Professional would recognize that he probability of \(a\) positives in \(A\) passengers randomly selected from all the \(B\) passengers among which there are exactly \(b\) positives follows a Hypergeometric distribution, i.e.:
In this problem however we know \(a\) and with this information we want, on the still-to-be-tested passengers (\(B-A\)), the distribution of the number of positives still unknown (\(b-a\))
It is convenient to choose for \(b\) a Beta-Binomial distribution as prior, as it is a conjugate prior of a Hypergeometric distribution:
This implies that the unknown number of positives \(b-a\) is also a Beta-Binomial distribution (posterior):
where the hyperparameters \(\alpha,\beta\) of the prior are added to the observed numbers of positives and negatives passengers \(a, A-a\).
Using the notation of the problem (\(A=M, a=Q, B=N+M, b=K+Q\)) and choosing a uniform prior (\(\alpha = \beta = 1\)):
We can get the overall probability \(\mathcal{P}(K_{max})\) that the number of positive cases is above \(K_{max} = 22\) from :
A caveman would just write a simple toy Monte Carlo simulation, for example as follow:
Assume a random infection rate,
Create a random, fake scenario of infected passengers in agreement with the given observations,
Simply annotate (yes or no) if that scenario has an โunwantedโ outcome, i.e. the number of tested positives passengers are more than 22
Generate zillion of scenarios
In the end, the fraction of the generated scenarios with an โunwantedโ outcome will give the probability required. No statistic knowledge needed, just a ratio of two integers.
Results#
Running the Python code we can report the final answers
Will the number of positive tests on the remaining 70 passengers be higher than 22 with 10% (or more) probability?
- Frequentist
NO. The probability is only 0.8%
- Bayesian
YES. The probability is 10.92%
- Professional
YES. The probability is 10.92%
- Caveman
YES. The probability is (10.92 \(\pm\) 0.14) %
The Caveman result accounts for the statistical error on the number of toy Montecarlo generated while the other three approaches are analytical results.
But these are just details.
The main point is that the Frequentist approach gives the wrong answer, and as a consequence people die! (well, to be precise there is a 10.92% probability that nobody dies)
Discussion and Take Away Message#
OK, whatโs going on here?? Were not all those endless frequentistic vs. bayesian debates basically all but philosophical banters? Some pedantic interpretations of the concept of probability but basically giving identical answers in all practical cases? And this is why it is important not only to know them, but also to understand them well.
Important
Frequentistic and Bayesian never give the same answers (maybe the same results), for the simple fact that they donโt answer the same question!
Is the frequentistic statistical inference all wrong?#
Is this a counterexample that the frequentist approach is wrong? Obviously not!
Any person with a good statistic background already realized from the start that the frequentist approach I showed above is not what a frequentist would do.
To explain well why is beyond the scope of this post (this is also the reason for the immense literature on these topics!). But I will put here few points that are important to have crystal clear for a proper application of statistic inference, whatever approach one might use:
A Frequentist would already have argued about the question asked. The objection is on the meaning of โ90% probability that at most 22 passengers on board will test positiveโ. For a frequentist there is not such a probability. Either it will happen or it will not. Thatโs the truth. We donโt know what it will be, but there is not 11% or 0.8% or whatever probability. It is yes or it is no.
In any case, a Frequentist would probably have framed the problem in term of hypothesis testing, and/or confident interval. But this IS NOT the same as the Bayesian counterparts (often called credible region). They are NOT answering the same question!
The freqentist inference gives procedures on statistics problems. They account of observations in the calculation of the confidence interval, but the statistic interpretation is on the procedure. The procedure does come with a frequency guarantee that the truth number of positives is within the frequentist confidence interval 95% of the time (or whatever threshold is used), not the particular confidence interval.
If the frequentist procedure is applied to 100 cruise ships in the same situation, for 95 ships the calculated confident interval contains the true value of positive passengers. If you consider only 1 ship though , it may be one of those 95 or one of the remaining 5. In the latter case the calculated confidence interval DOES NOT contain the true value. As for the frequentist spirit, the truth is or is not in the calculated interval, there is no probability.
In this sense conditional inference is not Frequentist. Confidence Intervals are un-conditional.
As a final note, it seems in this particular case the Bayesian approach is a better (in the sense of โmore intuitiveโ) choice. But I still remember a warning I once found somewhere while reading about these topics:
To those who attach themselves to either camp: remember, there is plenty of ammunitions in term of counterexamples on BOTH sides!