1988 Volume 1 Issue 1 Pages 23-35
In order to test the hypothesis that the row and column effects are independent in a two way contingency table, usually chi-square tests are used. However, it is well known that the approximation by the chi-square test statistics is deteriorated in the cases of small samples or sparse contingency tables. Thus, it is desirable to apply the exact test in such cases. In this paper, we introduce two algorithms for the exact test. One is a network algorithm which efficiently enumerates all contingency tables with the fixed marginal frequencies, the other is a method to count all the tables with the fixed margins one by one. The performance of network algorithm is compared with another on the basis of CPU time used to calculate the exact probaility. As a result, it was found that the network algorithm was superior to another one from aspects of the calculation efficiency. Further, we confirmed that the number of zero cells affected on the difference of performances between the exact and the chi-square tests. Consequently, we recommend to use the exact test for large or moderate contingency tables with many zero cells.