# G-test

﻿
G-test

In statistics, "G"-tests are likelihood-ratio or maximum likelihood statistical significance tests that are increasingly being used in situations where chi-square tests were previously recommended.

The commonly used chi-squared tests for goodness of fit to a distribution and for independence in contingency tables are in fact approximations of the log-likelihood ratio on which the G-tests are based. This approximation was developed by Karl Pearson because at the time it was unduly laborious to calculate log-likelihood ratios. With the advent of electronic calculators and personal computers, this is no longer a problem. "G"-tests are coming into increasing use, particularly since they were recommended in the 1994 edition of the popular statistics text book by Sokal and Rohlf [Sokal, R. R. and Rohlf, F. J. (1994). "Biometry: the principles and practice of statistics in biological research.", 3rd edition. New York: Freeman. ISBN 0-7167-2411-1.] . Dunning introduced the test to the computational linguistics community where it is now widely used.

The general formula for Pearson's chi-squared test statistic is
$chi^2 = sum_\left\{i\right\} \left\{\left(O_i - E_i\right)^2 over E_i\right\}$
where Oi is the frequency observed in a cell, E is the frequency expected on the null hypothesis, and the sum is taken across all cells. The corresponding general formula for "G" is
$G = 2sum_\left\{i\right\} \left\{O_i cdot ln\left(O_i/E_i\right) \right\}$
where ln denotes the natural logarithm (log to the base "e") and the sum is again taken over all non-empty cells.

The value of "G" can also be expressed in terms of mutual information of the contingency table or as the difference of the entropy of the contingency table and the entropy of the row and column sums
$G = 2 left \left[ sum_\left\{ij\right\} k_\left\{ij\right\} ight\right] cdot left \left[ H\left(pi_\left\{ij\right\}\right) - H\left(pi_\left\{i.\right\}\right) - H\left(pi_\left\{.j\right\}\right) ight\right]$

or $G = 2 left \left[ sum_\left\{ij\right\} k_\left\{ij\right\} ight\right] cdot MI\left(row,col\right)$
where the entropy of some observed distribution $q$ is defined as $H\left(q_i\right) = - \left\{sum_i q_i log q_i\right\}$ and $pi_\left\{ij\right\} = \left\{k_\left\{ij\right\} over sum_\left\{ij\right\} k_\left\{ij$, $pi_\left\{i.\right\} = \left\{sum_j k_\left\{ij\right\} over sum_\left\{ij\right\} k_\left\{ij$ and $pi_\left\{. j\right\} = \left\{sum_i k_\left\{ij\right\} over sum_\left\{ij\right\} k_\left\{ij$. $MI\left(row,col\right)= H\left(pi_\left\{ij\right\}\right) - H\left(pi_\left\{i.\right\}\right) - H\left(pi_\left\{.j\right\}\right)$ is the "Mutual Information between the row vector and the column vector" of the contingency table.

It can also be shown that the inverse document frequency weighting commonly used for text retrieval is an approximation of "G" where the row sum for the query is much smaller than the row sum for the remainder of the corpus. Similarly, the result of Bayesian inference applied to a choice of single multinomial distribution for all rows of the contingency table taken together versus the more general alternative of a separate multinomial per row produces results very similar to the "G" statistic.

Given the null hypothesis that the observed frequencies result from random sampling from a distribution with the given expected frequencies, the distribution of "G" is approximately that of chi-squared, with the same number of degrees of freedom as in the corresponding chi-squared test.

For samples of a reasonable size, the "G"-test and the chi-squared test will lead to the same conclusions. However, the approximation to the theoretical chi-square distribution for the "G"-test is better than for the Pearson chi-squared tests in cases where for any cell |"Oi" − "Ei" | > "Ei", and in any such case the "G"-test should always be used.

For very small samples the multinomial test for goodness of fit, and Fisher's exact test for contingency tables, or even Bayesian hypothesis selection are preferable to either the chi-squared test or the "G"-test.

tatistical Software

*Software for the R programming language [http://www.r-project.org] to perform the G-test is available [http://www.psych.ualberta.ca/~phurd/cruft/ on a Professor's software page] at the University of Alberta.
*Fisher's G-Test in the [http://cran.r-project.org/web/packages/GeneCycle/ GeneCycle Package] of the R programming language (fisher.g.test) does not implement the G-test as described in this article, but rather Fisher's exact test of Gaussian white-noise in a time series (see Fisher, R.A. 1929 "Tests of significance in harmonic analysis").

References

*Dunning, Ted (1993). "Accurate Methods for the Statistics of Surprise and Coincidence.", Computational Linguistics, Volume 19, issue 1 (March, 1993).

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Test-driven development — (TDD ) is a software development technique consisting of short iterations where new test cases covering the desired improvement or new functionality are written first, then the production code necessary to pass the tests is implemented, and… …   Wikipedia

• Test pilot — Test pilots are aviators who fly new and modified aircraft in specific maneuvers, allowing the results to be measured and the design to be evaluated. Test pilots may work for military organizations or private, (mostly aerospace) companies.… …   Wikipedia

• Test logiciel — Test (informatique) En informatique, un test (anglicisme) désigne une procédure de vérification partielle d un système informatique. Le but en est de trouver un nombre maximum de comportements problématiques du logiciel, car il est impossible de… …   Wikipédia en Français

• Test Card F — is a test card that was created by the BBC and used on television in the United Kingdom and in countries elsewhere in the world for more than four decades. Like other test cards, it was usually shown while no programmes were being broadcast, but… …   Wikipedia

• Test the Nation — is a television programme, first broadcast in 2001 by BNN in The Netherlands where the concept is owned by [http://www.eyeworks.tv/ Eyeworks Holding] who license it to TV production companies around the world. how FormatThe format is designed to… …   Wikipedia

• Test and tagging — is a generic name given to the process of visually inspecting and electrically testing in service electrical equipment for personal use and/or safety. Colloquially, it is also referred to as; tagging, test tag, test and tag, electrical tagging,… …   Wikipedia

• Test Rorschach — Test de Rorschach La première planche parmi les dix du test de Rorschach Le test de Rorschach ou psychodiagnostik est un outil d évaluation psychologique de type projectif élaboré par le psychiatre et psychanalyste Hermann Rorschach en 1921. Il… …   Wikipédia en Français

• Test de Charge — Test de performance Un test de performance ou benchmark est un test dont l objectif est de déterminer la performance d un système informatique. L acception la plus courante de ce terme est celle dans laquelle ces tests logiciels vont avoir pour… …   Wikipédia en Français

• Test de Khi-2 — Test du χ²  Pour la loi de probabilité, voir Loi du χ². Densité du χ² en fonction du nombre de degrés de liberté Le test du χ² (prononcer …   Wikipédia en Français

• Test de rorschach — La première planche parmi les dix du test de Rorschach Le test de Rorschach ou psychodiagnostik est un outil d évaluation psychologique de type projectif élaboré par le psychiatre et psychanalyste Hermann Rorschach en 1921. Il consiste en une… …   Wikipédia en Français

• Test des taches d'encre — Test de Rorschach La première planche parmi les dix du test de Rorschach Le test de Rorschach ou psychodiagnostik est un outil d évaluation psychologique de type projectif élaboré par le psychiatre et psychanalyste Hermann Rorschach en 1921. Il… …   Wikipédia en Français