Chi-Square calculator for contingency tables
Test category counts for an association between groups and inspect the expected frequencies. Your entries stay in this browser.
Association test
Association at 5%
Insufficient evidence
Assumes independent observations and mutually exclusive categories.
Test results
| Measure | Result |
|---|---|
| Pearson chi-square | 2.78 |
| Degrees of freedom | 2 |
| Approximate p-value | 0.25 |
| Cramér’s V | 0.17 |
| Total observations | 100 |
| Smallest expected count | 12 |
| Expected cells below five | 0 of 6 |
Every expected count is at least five. The approximation still depends on the sampling assumptions.
Observed and expected counts
| Group / category | Observed | Expected |
|---|---|---|
| Email / Clothing | 10 | 12 |
| Email / Footwear | 10 | 12 |
| Email / Homewares | 20 | 16 |
| Search / Clothing | 20 | 18 |
| Search / Footwear | 20 | 18 |
| Search / Homewares | 20 | 24 |
Insufficient evidence at the chosen threshold. Approximate p-value 0.25.
Enter counts rather than percentages
This chi-square calculator tests whether the category distribution differs between groups. Enter observed counts in a two-way contingency table with two to six groups and categories.
For a channel-by-category table, each row is a channel and each column is a product category. The cells contain counts of independent observations.
Count each observation in exactly one row and one column. A customer buying several categories cannot appear repeatedly in a customer-level analysis.
Choose a rule that assigns each customer to one category, such as their first purchase category. Repeated purchases from the same customer need an analysis that accounts for dependence.
A count of 10 means ten observations. Entering 10 because a report says 10% loses the sample size and produces a different test.
Zero is allowed in a cell. Negative or fractional counts are rejected, and every included row and column must have a positive total.
Calculate expected counts and chi-Square
Under independence, a cell’s expected count equals its row total multiplied by its column total, divided by the grand total.
For each cell, subtract the expected count from the observed count, square the difference and divide by the expected count. Add those contributions to get Pearson’s chi-square statistic.
The NIST contingency-table method gives these formulas and uses (rows - 1) × (columns - 1) degrees of freedom.
With the margins fixed, filling the first rows - 1 by columns - 1 cells determines the remaining cells. A two-row, three-column table therefore has two degrees of freedom.
The approximate p-value is the upper-tail probability from that chi-square distribution. This calculator uses uncorrected Pearson counts, including for two-by-two tables, without Yates’ continuity correction.
Cramér’s V equals the square root of chi-square divided by the grand total and the smaller of rows - 1 and columns - 1.
V runs from zero to one and describes the size of the association in the sample. This is the unadjusted measure, without a small-sample bias correction.
Follow a channel and category example
The hypothetical example counts 100 customers by acquisition channel and first purchase category. Email has 40 customers and Search has 60.
| Channel | Clothing | Footwear | Homewares | Total |
|---|---|---|---|---|
| 10 | 10 | 20 | 40 | |
| Search | 20 | 20 | 20 | 60 |
| Total | 30 | 30 | 40 | 100 |
Email and Clothing has an expected count of 40 × 30 / 100 = 12. Email’s expected counts are 12, 12 and 16. Search’s are 18, 18 and 24.
The first cell contributes (10 - 12)² / 12 = 0.33. Adding all six unrounded contributions gives chi-square 2.78, with two degrees of freedom.
The approximate p-value is 0.25 and Cramér’s V is 0.17. Every expected count exceeds five, so the sparse-count warning stays clear.
At the example’s 5% threshold, the p-value exceeds 0.05. The table gives insufficient evidence of an association between acquisition channel and first purchase category.
Interpret association and sparse-cell warnings
Choose the significance threshold before inspecting results. At 5%, the calculator reports evidence of association when the unrounded approximate p-value is below 0.05 and every expected count reaches five.
A p-value describes how unusual this statistic or a larger one would be under independence and the test assumptions. It is not the probability that independence is true.
A small p-value does not establish causation or show that a channel caused customers to choose a category. Traffic mix or other differences can explain the association.
A p-value above the threshold does not prove independence. Read the observed pattern and Cramér’s V alongside the sample size and your business question.
The NIST expected-frequency guidance warns that small expected counts can make the chi-square approximation poor.
This tool flags every expected count below five and withholds the association verdict if any occur. It also counts expected cells below one.
That is a conservative screen. NIST describes concern when an expected count is below one or 20% of expected counts fall below five, while noting that recommendations differ.
The approximate statistic and p-value remain visible for inspection, alongside the warning. Clearing the warning does not establish that your observations are independent.
With sparse counts, consider a suitable exact or simulation method. Combine categories only when the grouping makes substantive sense, without choosing groups to obtain a preferred result.
This tool does not run exact tests, one-way goodness-of-fit tests or paired-observation tests. For two conversion variants with visitor totals and conversions, use the A/b test calculator.