The G or likelihood ratio chi-square test for contingency tables. Roughly the same as Pearson's chi-square test (chiSquareContingency), but may be more accurate in certain situations and less accurate in others.

Like Pearson's Chi-square, the G-test is based on asymptotic distributions, and is not exact. Usage is is identical to chiSquareContingency.

Note: This test can be thought of as a test for nonzero mutual information between the random variables represented by the rows and the columns, since the test statistic and P-value are strictly increasing and strictly decreasing, respectively, in mutual information. Therefore, this function returns a GTestRes, which is a subtype of TestRes and also gives the mutual information for use in information theoretic settings.

References:, last retrieved 1/22/2011