Significance test

G-Test Calculator — Likelihood-Ratio Chi-Square

The G-test (likelihood-ratio chi-square) tests whether two categorical variables are independent, like the Pearson chi-square, but is built from the log-likelihood ratio of observed to expected counts; it uses the same degrees of freedom and usually gives a very similar result.

Reviewed by the crosstabs.com methods team · Last updated

Calculate online — no file needed

Type or paste your observed counts. Results update live, and the link in your address bar always reproduces this exact table.

Table sizeTip: paste a block of counts straight from a spreadsheet.
Total
50
50
Total5050100

G statistic (likelihood-ratio test)

4.03

df = 1 · p = .045

χ²(1, N = 100) = 4.00, p = .046, V = .20

All statistics
Pearson chi-squareχ² = 4.000, df = 1, p = .046
G-test (likelihood ratio)G = 4.027, df = 1, p = .045
Chi-square with Yates' correctionχ² = 3.240, p = .072
Fisher's exact test (two-sided)p = .071
Odds ratio0.444 (95% CI 0.200 – 0.989)
Cramér's V0.200 (small)
Phi coefficient (φ)-0.200
Contingency coefficient (C)0.196
Lambda (symmetric / row|col / col|row)0.200 / 0.200 / 0.200
Goodman–Kruskal gamma (γ)-0.385
Kendall's tau-b / tau-c-0.200 / -0.200
Somers' d (symmetric / row|col / col|row)-0.200 / -0.200 / -0.200
Theil's U (symmetric / row|col / col|row)0.029 / 0.029 / 0.029

What is the G-test?

The G-test is a likelihood-ratio test of independence for a contingency table. Like the Pearson chi-square, it asks whether the row and column variables are associated, but instead of summing (O − E)²/E it sums the log-likelihood ratio of each observed count against its expected count.

Both statistics are compared to the same chi-square distribution with the same degrees of freedom, and in practice they almost always lead to the same conclusion. The G-test is favoured by some analysts for sparse tables and because it is additive for nested log-linear models.

Formula

Definition

G = 2 × Σ O × ln(O / E)

O
= each observed cell count
E
= its expected count, (row total × column total) / grand total
ln
= the natural logarithm
df
= (rows − 1) × (columns − 1), the same as the Pearson chi-square; G is compared to the chi-square distribution

Worked example

Worked example

Suppose 110 people are cross-tabulated by whether they saw an ad (rows) and whether they bought (columns):

[[30, 10], [10, 60]] (n = 110)

Summing 2 × O × ln(O / E) over the four cells, using each cell's expected count E = (row total × column total) / grand total, gives:

G = 41.80 with df = (2 − 1) × (2 − 1) = 1, which is highly significant (p < 0.001).

For comparison, the Pearson chi-square on the same table is 40.55 — the two statistics are close, as they usually are.

When to use it

Use it when

  • You want an alternative to the Pearson chi-square test of independence.
  • You have a sparse contingency table — some analysts prefer the G-test here.
  • You are fitting nested or log-linear models, where the G statistic is additive.

Not the right tool when

  • You have a very small 2×2 sample — use Fisher's exact test instead, since the G-test relies on the same large-sample chi-square approximation.
  • You need an exact p-value rather than a large-sample approximation.

How to interpret it

Rule of thumb

Compare G to the chi-square distribution with (r − 1)(c − 1) degrees of freedom; p < 0.05 indicates the variables are associated. G and the Pearson chi-square almost always agree.

Frequently asked questions

G-test vs chi-square test?
Both test whether two categorical variables are independent and use the same degrees of freedom, (r − 1)(c − 1). The chi-square sums (O − E)²/E, while the G-test sums 2 × O × ln(O/E) from the log-likelihood ratio. The two statistics are usually very close and almost always agree.
When should I use the G-test?
Use it as an alternative to the chi-square test of independence. Some prefer it for sparse tables, and it is additive for nested or log-linear models. Avoid it for very small 2×2 samples, where Fisher's exact test is better.
Does the G-test use the same degrees of freedom as chi-square?
Yes. The G-test uses (rows − 1) × (columns − 1) degrees of freedom, exactly the same as the Pearson chi-square, and G is compared to the same chi-square distribution.

References & further reading

Try it on your own data — free, no signup

Upload a CSV or XLSX. Everything runs in your browser; your file never leaves your device.

Open the workspace →

Related calculators

← All calculators & guides