Chi-Square Test Calculator

Test whether two categorical variables are associated using a contingency table, chi-square statistic, degrees of freedom, and p-value.

Chi-square test of independence
Separate columns with commas and rows with semicolons.

About the chi-square test of independence

The chi-square test of independence evaluates whether two categorical variables are statistically associated. Data are arranged in a contingency table: each row represents a category of one variable, each column represents a category of the other, and each cell contains an observed frequency. The null hypothesis says the variables are independent, meaning the proportion across columns is the same for every row. The alternative says an association exists. For every cell, the calculator derives an expected frequency from its row total, column total, and the grand total. The expected count equals row total multiplied by column total and divided by the grand total. It then computes the contribution (observed − expected)² / expected for each cell and adds those contributions to produce the chi-square statistic. Larger discrepancies between observed and expected counts create a larger statistic. Degrees of freedom equal (number of rows − 1) × (number of columns − 1). The p-value is the upper-tail probability from the chi-square distribution at the calculated statistic and degrees of freedom. A small p-value indicates that a discrepancy this large would be unusual if the variables were truly independent. Researchers commonly compare the p-value with a preselected significance level such as 0.05. A p-value below that threshold supports rejecting the null hypothesis, but it does not measure the strength or practical importance of the association. The approximation works best when observations are independent and expected cell counts are sufficiently large. A common guideline is that no expected count should be below one and no more than 20% should be below five. Sparse two-by-two tables may require Fisher's exact test instead. Counts must be raw frequencies rather than percentages, rates, averages, or duplicated observations. Categories should be mutually exclusive so each observation contributes to exactly one cell. Use the result alongside an effect-size measure such as Cramér's V when practical importance matters. Statistical significance can emerge from a weak relationship in a very large sample, while a meaningful relationship may miss a conventional cutoff in a small sample. This calculator supplies the statistic, degrees of freedom, and p-value needed for inference; sound conclusions still depend on study design, representative sampling, and a clear definition of both categorical variables.

Chi-square independence examples

Contingency tables can represent survey answers, outcomes, or category preferences.

Observed tableTest resultInterpretation
10, 20; 20, 40χ² = 0, df = 1, p = 1Both rows have identical proportions, so observed and expected counts match.
10, 10; 10, 30χ² = 3.75, df = 1, p ≈ 0.0528The evidence is close to, but above, a 0.05 significance threshold.
30, 10; 10, 30χ² = 20, df = 1, p < 0.001The opposite row patterns provide strong evidence of association.

How to run a chi-square test

  1. Arrange raw counts with one variable in rows and the other in columns.
  2. Enter commas between cells and semicolons between table rows.
  3. Select Calculate Chi-Square to compute the statistic and p-value.
  4. Compare the p-value with a significance level selected before analyzing the data.

Chi-square test FAQ

What does a small p-value mean?

It means the observed table would be unusual under the assumption of independence. It supports an association, but does not prove causation or quantify effect size.

Can I enter percentages instead of counts?

No. The test requires observed frequency counts because expected frequencies and sampling variability depend on the total sample size. Convert the source data back to counts first.

What are the degrees of freedom?

They determine which chi-square distribution is used for the p-value. For an r-by-c table, degrees of freedom equal (r − 1)(c − 1).

When are expected counts too small?

A common guideline requires every expected count to be at least one and at least 80% to be five or greater. When a small table violates that guidance, consider an exact test.

Does significance show a strong relationship?

Not necessarily. Significance is affected by sample size, so report an effect size such as Cramér's V as well. Context determines whether the association matters.