Skip to content
CALX
Appearance

Appearance

Light or dark

Colour
Accessibility

Chi-square test calculator, goodness of fit and independence

χ² statistic, degrees of freedom, p-value and critical value, with cell-by-cell detail and Cochran’s rule checked.

Parameters

One count per category, separated by spaces (no percentages).

Counts, frequencies or proportions, rescaled to the observed total. Empty: uniform distribution.

0 for a theoretical distribution, 1 for an estimated mean (Poisson), 2 for a mean and a standard deviation (normal). Each parameter removes one degree of freedom.
0.05 by convention; 0.01 for a stricter requirement.

Result

Awaiting the quantities required for the calculation.

Calculation, assumptions and sources

OverviewChi-square (χ²) test of goodness of fit, which compares observed counts with a stated distribution, and of independence, on a contingency table.

Chi-square (χ²) test of goodness of fit, which compares observed counts with a stated distribution, and of independence, on a contingency table. The calculation gives the statistic, its degrees of freedom, the p-value, the critical value at the chosen level, the contribution and standardised residual of every cell, Cramér’s V and the check of Cochran’s rule.

Method & formulasχ² = Σ (O − E)² / E
χ² = Σ (O − E)² / EE(independence) = (row total × column total) / totaldf(goodness of fit) = k − 1 − mdf(independence) = (r − 1)(c − 1)V = √(χ² / (N × min(r − 1, c − 1)))

Dividing by E makes departures comparable across cells. Under the null hypothesis the statistic approximately follows a chi-square distribution with the degrees of freedom given above.

O
observed count in a cell.
E
expected count under the null hypothesis: given for goodness of fit, derived from the margins for independence.
k
number of categories in the goodness-of-fit test.
m
number of parameters estimated from the data to build the expected distribution.
r, c
number of rows and columns of the contingency table.
N
total count across all cells.
Standardised residual
(O − E) / √E. Its sign gives the direction of the local departure, strong beyond 2 in absolute value.
Cramér’s V
strength of the relationship between two variables, from 0 to 1, independent of total sample size.
p-value
probability of a departure at least this large if the null hypothesis were true.
Validity domainThe chi-square distribution approximates the distribution of the statistic when expected counts are large enough.

The chi-square distribution approximates the distribution of the statistic when expected counts are large enough. Cochran’s rule asks that all be at least 1 and that at most a fifth be below 5. Otherwise the p-value is optimistic; on a 2×2, Fisher’s exact test is preferable. Observations must be independent and entered as counts: percentages amount to declaring a sample of 100 individuals and distort the p-value. The Yates correction is defined for a 2×2 table only; elsewhere it is ignored and flagged.

Reading the resultIf p < α, the null hypothesis is rejected.

If p < α, the null hypothesis is rejected. A p-value above the level does not prove the null hypothesis: the data, sometimes too few, are not enough to contradict it. An association between two variables may come from a third factor and does not identify a cause.