# Chi^2 test for 2x2-contingency table using probabilities instead of count data

I would like to perform a $\chi^2$ hypotheses test for association based on a $2 \times 2$ contingency table. However, my contingency table

$$\begin{array}{|c|c|} \hline \\ a & b \\ \hline \\ c & d \\ \hline \end{array}$$

does not contain integer count data but probabilities

$$\begin{array}{|c|c|} \hline \\ 1 - f(a) & 1 - g(a) \\ \hline \\ f(a) & g(a) \\ \hline \end{array}$$

$f,g$ are Bernoulli distributions over event $a.$ How can I calculate the test statistic in this case?

You can't, unless you know the sample size. A $\chi^2$ test is a test of whether observed data are plausibly generated from an underlying population with no association between the two variables. Unless you know how many data were actually observed you can't make any conclusions about whether they are plausibly from that null-hypothesis distribution.

If you do know the total sample size, obviously you can just convert your probabilities to counts and perform the test the usual way.

While you can't directly compute the chi-square statistic if you don't have at least one of the counts in the cell, or one of the marginal totals or the overall total, it may not be a hopeless situation, because with a modest degree of luck* you might just be able to compute a useful lower bound on the sample size from the proportions themselves.

Consider this example table of proportions (where column totals are 1):

  0.59375 0.2142857
0.40625 0.7857143


What are the smallest column totals that could have given those numbers?

Looking at the first column, the smallest column total that will yield integers for the counts would be 32, implying counts of 19 and 13 in the first column.

Now look at the second column. The smallest column total that will yield integers for the counts (taking into account rounding) is 14, yielding counts of 3 and 11 in the second column.

The counts for the 'lower bound' table is then:

19  3
13 11


Both columns must be some positive integer multiple of these values. Without any additional information, we can calculate the chi-square statistic of that lower-bound table, and this will give a lower bound on the chi-square statistic.

Without continuity correction the chi-square value for that table is 5.62 (and with it, it is 4.20).

So these are lower bounds on the chi-square statistic (without or with continuity correction respectively).

So if you aren't using continuity correction, the chi-square value cannot be less than 5.62. That's at least something.

[As it happens, I have the original data that generated the proportions above:

19  6
13 22


which yields chi-square statistics of 8.85 (without CC) and 7.35 (with CC).]

In this particular example, all of the chi-square values (both for the actual and the lower bound table, with or without Yates' continuity correction) are significant at the 5% level.

* How much luck? Some, but not huge amounts ... unless the values are heavily rounded off.

If you're pretty lucky, the two counts in a column will be relatively prime (as was the case in the first column in our example). If you're moderately lucky they'll have only a small prime factor in common, hopefully as small as 2 (as was the case in the second column). If you're unlucky, you'll get counts with a large common factor (like 16 and 40, which you will only be able to get lower bounds of 2 and 5 on).

For large counts, the probability they're relatively prime is reasonably high (a result from number theory suggests roughly 60%), so the chances at least one of the columns has relatively prime counts (i.e. ones you can reconstruct exactly) is pretty good. The corresponding chance (for large counts) that they both do, and you actually get the original table back is (assuming independence) a little better than 1/3.

If the proportions are rounded to a few decimal places, the situation becomes substantially more difficult - you can still obtain lower bounds, but they're much less likely to be large numbers, because you have to take the worst-case (smallest marginal count) that's consistent with the rounded values.