In-depth learning guide

Chi-Square Test Guide

Pearson’s chi-square statistic compares observed categorical counts with counts expected under a stated model. Expected counts and degrees of freedom determine how the statistic maps to an upper-tail p-value.

3 min readStep-by-step methodReviewed 27 Oct 2026Published by LynaraOpen Chi-Square Test Calculator →

Method

  1. Use independence mode for a rectangular contingency table where rows and columns represent categorical variables.
  2. Use goodness-of-fit mode when observed category counts are compared with fully specified expected counts that sum to the same total.
  3. Inspect the expected counts before interpreting the p-value; Lynara flags any expected count below 5.
  4. Report χ², degrees of freedom and p-value together and use an exact or alternative method when your course or sparse-data conditions require one.

Worked example

For [[86,14],[80,20]], independence-mode expected counts are 83, 17, 83 and 17 and χ² is about 1.276.

A goodness-of-fit example with observed 20,30,50 and expected 25,25,50 gives χ² = 2 with df = 2.

Notes

Open Chi-Square Test Calculator

Choose independence or goodness-of-fit from the data structure

A chi-square test of independence uses a contingency table to ask whether two categorical variables are associated. A goodness-of-fit test compares observed counts across categories with a specified expected distribution. The calculations are related, but the hypotheses and expected counts come from different setups.

Use counts rather than percentages as the direct input to the usual chi-square statistic. Expected counts are derived under the null model.

Inspect expected counts before trusting the approximation

The chi-square reference distribution can be unreliable when expected cells are too small, especially in sparse tables. Combining categories must be substantively defensible, not merely a way to force the test to work.

A significant result shows evidence that observed counts differ from the null expectation, but it does not by itself identify which cells drive the pattern or measure the practical size of the association. Examine residuals or an effect-size measure when appropriate.

Worked 2-by-2 table: reconstruct each expected count

Imagine a fictional survey table with two response categories across two groups: Group A has 30 Yes and 20 No responses; Group B has 20 Yes and 30 No responses. Each row total is 50, each column total is 50 and N = 100. If group and response were independent, every expected cell would be (50 × 50)/100 = 25. The uncorrected Pearson statistic is four contributions of (30 − 25)²/25 or (20 − 25)²/25, each equal to 1, so χ² = 4. With two rows and two columns, df = (2 − 1)(2 − 1) = 1.

For χ² = 4 and df = 1, the upper-tail p-value is approximately 0.0455. All four expected cells are 25, so this illustrative table does not have the small-expected-count problem. In the linked calculator, choose independence, enter rows [30, 20] and [20, 30], and check the expected-count display and statistic. Do not use goodness-of-fit mode for this two-variable question.

The p-value does not reveal cause or practical importance

At a preselected 5% significance threshold the example gives evidence against independence under the chosen sampling and test assumptions, but the p-value is not the probability that the null hypothesis is true. In a 2-by-2 table, Cramér's V = √(χ²/N) = √(4/100) = 0.20 for this example; reporting it alongside the cell counts gives a separate descriptive view of association magnitude.

The test does not establish which variable caused another to change, nor does it repair selection bias, overlapping responses or non-independent observations. Before communicating a result, report the original counts, all expected counts, df, the uncorrected test choice and the practical context. If expected counts are small or the data are paired, the simple independence approximation may be unsuitable.

Authoritative references

Primary or authoritative references for the external standard, scoring rule or identifier convention used on this page.

Editorial review and limitations

Review status: reviewed under Lynara's editorial policy on 27 Oct 2026. Institution-specific grading rules, assignment instructions and publisher requirements can override a general example.
Verification: see the methodology and sources & verification pages. To report a reproducible error, use the contact page with the page URL, inputs and expected result.

Continue with the related tools

Use the linked tools for your own inputs and scenarios.

Browse all statistics calculators →

Keep learning

Related guides