richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
131 stars 48 forks source link

Question: Bayes factor computation on a contingency table with structural zeros #148

Closed ivan-marroquin closed 3 years ago

ivan-marroquin commented 3 years ago

Hi there,

Thanks for such great package!

Let's suppose that I have a contingency table of size rx2, where r >> 2. There few cells with observed frequency of 0, and they are the minority in the table. Such cells may exist along one column or in both columns. And these observed frequencies are considered to be structural zeros. Because the way the data is collected, a poisson sampling is used to run the Bayes factor computation.

In such situation, how the Bayes factor is computed? Does it skip the cells with 0 value? Should I apply a correction, for instance 0.5, to all cells? Will the correction impact the measured factor compared to the one obtained from the original table?

Looking forward for your comments and clarifications.

Many thanks,

Ivan

richarddmorey commented 3 years ago

Hi Ivan, no the empty cells are not skipped in the computation. You can see the code here: https://github.com/richarddmorey/BayesFactor/blob/2639b0f879d53e6b697e592fc3c592a8f4f8579d/pkg/BayesFactor/R/contingency-utility.R#L33 and that it takes uses the full matrix. No correction is needed.