2
$\begingroup$

To get the number of "positive cases" I'm in doubt between two strategies.

The first one is to draw samples from a Beta distribution: $p \sim Beta(\alpha + cases, \beta + non\ cases)$, using these draws to get the number of positive cases given a total: $n \sim Binomial(p, Total)$.

The second approach is to multiply the draws from the Beta distribution directly with the total: $n \sim Beta(\alpha + cases, \beta + non\ cases) \times Total$.

Theoretically, the first method seems more correct, since you first estimate the parameters from the data, update a prior, and then use the posterior parameters with the appropriate distribution to predict the outcome. The second though is quite computationally faster (I'm using Monte Carlo simulations) then the first and the results don't seem too different.

So I was wondering if the two forms are mathematically equivalent and if not, which are the drawbacks of the second method.

$\endgroup$
4
  • 2
    $\begingroup$ Note that the second one can generate a fraction, e.g., if $p = 0.1$ and $Total = 19$ then $n = 1.9$, but the first one can't. Therefore, they can't be mathematically equivalent. $\endgroup$
    – jbowman
    Feb 10, 2020 at 15:42
  • $\begingroup$ On small numbers you're right, but as the denominator of the Binomial goes bigger don't they get similar? $\endgroup$
    – Bakaburg
    Feb 10, 2020 at 18:25
  • 2
    $\begingroup$ Well the question was "mathematically equivalent", which they aren't. The second method doesn't give you the same amount of variability in the result that the first one does, either, since in effect it assumes your Binomial variate generated exactly $np$ successes, which it typically won't. $\endgroup$
    – jbowman
    Feb 10, 2020 at 18:57
  • $\begingroup$ Could you elaborate more on this in an answer? $\endgroup$
    – Bakaburg
    Feb 10, 2020 at 18:58

1 Answer 1

4
$\begingroup$

Your friends here is the law of total expectation and the law of total variance. I will change/simplify your notation a bit.

Let $P \sim \mathcal{Beta}(\alpha+C, \beta + NC)$ and then $$ N_1 \mid P=p \sim \mathcal{Binom}(T,p) $$ and alternatively $$ N_2 =T \cdot p \quad \text{Given that $P=p$}. $$ $N_1$ and $N_2$ have the same expectation (use the law of total expectation), but they do not have the same variance: $$ \DeclareMathOperator{\E}{\mathbb{E}} \DeclareMathOperator{\V}{\mathbb{V}} \V N_1 = \E \V N_1 \mid P + \V \E N_1 \mid P = \\ \E T P (1-P) + \V T P = T \E P(1-P) + T^2 \V P $$ while $$ \V N_2 = \E \V N_2 \mid P + \V \E N_2 \mid P = \\ \E T^2 \cdot\underbrace{ \V P\mid P }_0 + \V T \cdot \E P = 0 + T^2 \V P $$ and now you can finish the calculation by using the expectation and variance of the beta distributed $P$. It is immediate from the above formulas that $N_1$ has the larger variance, as is expected from the hierarchical sampling.

$\endgroup$
9
  • $\begingroup$ Perfect, I need to trust you on some passages, but it's exactly the answer I need. $\endgroup$
    – Bakaburg
    Mar 10, 2020 at 12:00
  • $\begingroup$ One question. Does this elaboration take into account that the model is hierarchical? that is the parameters of the Beta are fixed, but the p in the binomial is a random variable produced by the previous Beta. Wouldn't $N_1$ have variance components coming from the Beta and the Binomial, and therefore higher than just the Beta? (feel free to destroy me on this) $\endgroup$
    – Bakaburg
    Mar 10, 2020 at 12:10
  • 1
    $\begingroup$ My argument is hierarchical, with two levels corresponding to the two levels in the total variance formula, that is $ \DeclareMathOperator{\E}{\mathbb{E}} \DeclareMathOperator{\V}{\mathbb{V}} \E \V$ and $ \V \E $. But my algebra was wrong ... will correct now! $\endgroup$ Mar 11, 2020 at 23:45
  • 1
    $\begingroup$ Because, given $P$ it is a constant ... so zero variance. $\endgroup$ Mar 12, 2020 at 8:52
  • 1
    $\begingroup$ Search for properties of expectation/variance in any probability book $\endgroup$ Mar 12, 2020 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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