ContingencyTableR, CPearsonChiSquaredTest Method |
Namespace: Meta.Numerics.Statistics
The Pearson Pearson χ2 test tests for correlation between the row and column values. If row and column values are uncorrelated, then the expected number of counts in a table entry is simply proportional to the totals for its row and column. If that number is large for all entries, then the central limit theorem suggests that the actual number of counts will be distributed normally with mean equal to the expected value and standard deviation equal to its square root. The χ2 statistic measures the departure of the actual table from this expectation in the uncorrelated case, and under this null hypothesis its distribution is known. Having calculated χ2, then, we can compute just how unlikely it was to obtain a value as large or larger than the one obtained.
In cases where either the actual or expected counts for some entries are small or zero, the assumptions of the Pearson χ2 test are violated and it should not be used. For 2 X 2 experiments, the FisherExactTest is a viable alternative in these cases.