Compute chi-square test for goodness-of-fit (observed vs expected) or test of independence (contingency table). Outputs χ², df, p-value, and Cramér's V effect size.

RT-CNV-091 · Mathematics
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

Chi-Square Test Calculator

Each row = a different category of variable A; each column = a category of variable B. Minimum 2×2.
χ² statistic
—
Degrees of freedom
—
p-value
—
Cramér's V
—
—
Enter data + pick test mode to compute chi-square
Advertisement
After results · AD-W1Responsive · Post-tool — peak engagement

How to use the Chi-Square Test Calculator

Pick test type

Independence (contingency table): tests whether two categorical variables are related. Example: gender × product preference, customer segment × purchase decision. Default. Goodness-of-fit: tests whether observed counts in categories match expected proportions. Example: do dice rolls match the expected uniform distribution?

Enter data

Contingency table: one row per line; columns separated by commas. 2×2 = "A/B test conversion" pattern. Goodness-of-fit: observed counts in one row; expected counts (or proportions) in another. The tool computes degrees of freedom automatically: (rows-1) × (cols-1) for independence, (categories-1) for goodness-of-fit.

Read χ² + p-value + Cramér's V

χ² statistic measures the discrepancy between observed and expected. p-value is the probability of seeing this much (or more) discrepancy if H₀ (independence/good-fit) were true. Cramér's V is the effect size — 0.10 small, 0.30 medium, 0.50 large when the smaller side of the table has two categories, lower for bigger tables.

Watch for expected-count warnings

Chi-square requires expected counts ≥ 5 per cell for reliable results. The tool warns when cells fall below this. If many cells have low expected counts: (a) combine adjacent categories, (b) increase sample size, or (c) use Fisher's exact test (for 2×2 tables with small n).

Advertisement
After how-to · AD-W2Responsive

Chi-square — the categorical-data equivalent of the t-test

While t-tests handle continuous data (means + standard deviations), chi-square tests handle categorical data (counts of things falling into categories). Karl Pearson developed the test in 1900, and it became one of the foundational tools of statistical inference. The math is intuitive: compute the difference between observed counts and what you'd expect under your hypothesis, square those differences (so they don't cancel out), divide by expected to standardise, and sum across all cells. Look up the result in a chi-square distribution to get a p-value. This tool handles both common variants: goodness-of-fit (one categorical variable vs hypothesised proportions) and independence (testing whether two categorical variables are related).

Goodness-of-fit vs independence — when to use which

Goodness-of-fit: ONE categorical variable, compared to hypothesised proportions. Examples: "Do M&M color frequencies in this bag match the manufacturer's stated distribution?"; "Do dice roll outcomes (1-6) match the expected uniform 1/6 each?"; "Does observed product-rating distribution match the long-term baseline?" Always reducible to a single row of observed counts + corresponding expected counts. Independence: TWO categorical variables, testing whether they're related. Examples: "Is product preference (Type A/B/C) independent of customer segment (Premium/Standard/Basic)?"; "Does conversion rate (converted/not) differ between A/B test variants?"; "Are vote preference + age bucket related?" Always reducible to a 2D contingency table where rows = categories of one variable + columns = categories of the other.

Karl Pearson developed chi-square in 1900 — predating Student's t-test (1908) by 8 years. Both remain the dominant statistical-test choices today: t-test for continuous, chi-square for categorical.

Expected counts + the n ≥ 5 rule

Chi-square approximation relies on each cell having sufficient expected count. The standard rule: all expected counts should be ≥ 5; some sources allow ≥ 80% of cells with at least 5 + no cell below 1. Why this matters: chi-square uses the chi-square continuous distribution to approximate a discrete reality (counts). With low expected counts, the approximation breaks down + p-values become unreliable. What to do: (1) combine adjacent categories to boost cell counts ("under 30, 30-44, 45-59, 60+" → "under 45, 45+"); (2) use Fisher's exact test for 2×2 tables (gives exact p-values, no approximation); (3) use simulation-based methods (Monte Carlo chi-square) for larger sparse tables. This tool warns when cells have expected < 5 so you know whether to trust the result.

What a 2×2 A/B test can and cannot show

Conversion testing is the canonical use of a 2×2 table: variant × converted or not. The trap is reading a lift as a result before the test has spoken. Take 250 conversions from 5,000 visitors on A (5.0%) against 280 from 5,000 on B (5.6%) — a 12% relative lift that looks decisive on a dashboard. The chi-square test gives χ² = 1.79, p ≈ 0.18, and Cramér's V is 0.013: at that sample size the difference is well inside what chance produces. Three habits keep product experiments honest. (a) Size the test before running it, because small lifts need large samples — the sample size calculator does the arithmetic. (b) Separate statistical from practical significance: with a large enough sample almost any lift clears p < 0.05, so the question becomes whether it is worth shipping. (c) With more than two arms (A/B/C/D), run the chi-square independence test as the omnibus "do the variants differ?" question, then follow up with pairwise proportion tests under a Bonferroni or false-discovery-rate correction.

Pearson 1900: the expected-count-of-five rule, Cramér's V, and Fisher's exact

01

Karl Pearson 1900 — chi-square predates Student's t-test (1908). Foundational categorical-data statistical test.

02

Two main types: goodness-of-fit (one variable vs expected) + independence (two variables, contingency table).

03

Cell expected counts ≥ 5 required for reliable chi-square. Otherwise use Fisher's exact test or combine categories.

04

Cramér's V = effect size for independence. 0.10 / 0.30 / 0.50 is small / medium / large for a 2×k table; the cutoffs shrink for bigger tables.

05

χ² is always non-negative; larger values indicate larger discrepancy from expected.

06

Degrees of freedom: (rows-1) × (cols-1) for independence; (categories-1) for goodness-of-fit.

07

For 2×2 tables with small n, Fisher's exact test is preferred (gives exact p-values without approximation).

08

A/B testing conversion rates: 2×2 contingency table is the canonical use case. Variant × converted/not.

09

Survey research, genetic ratios, quality control, marketing segmentation — all rely on chi-square for hypothesis testing.

10

A 5.0% vs 5.6% conversion at 5,000 per arm gives χ² = 1.79, p ≈ 0.18 — a 12% lift that is not significant.

Frequently Asked Questions

  • Data type drives the choice. Chi-square: categorical data (counts in categories). Examples: conversion rate, color preference, segment counts. T-test: continuous data (numeric values). Examples: revenue per user, time on page, weight, age. Common mistake: t-test on rates (e.g., "5.2% vs 4.8% conversion rate") — should be chi-square or z-test for proportions. The underlying data is binary (converted yes/no), making chi-square more appropriate.

  • Three options. (1) Combine sparse categories: merge low-count cells with adjacent ones ("under 25, 25-34, 35-44, 45+" → "under 35, 35+"). (2) Use Fisher's exact test (for 2×2 tables): gives exact p-values without the chi-square approximation. Most stats software (R, SPSS, Python scipy) implements it. (3) Increase sample size: collect more data so cells fill up. For exploratory work, chi-square with cell expected ≥ 1 is sometimes still informative; for publication-quality work, ≥ 5 is the standard threshold.

  • The effect size measure for chi-square independence tests. Formula: V = √(χ² / (n × min(rows-1, cols-1))). Ranges 0 to 1. Interpretation: 0 = no association, 1 = perfect association. Conventional cutoffs, from Cohen: 0.10 small, 0.30 medium, 0.50 large — but only when min(rows, cols) = 2. The cutoffs divide by √(min(rows, cols) − 1), so a 3×3 table reads 0.07 / 0.21 / 0.35. Why effect size matters: p-value tells you if association is "real" (not chance); Cramér's V tells you "how strong" the association is. With large samples, weak associations become statistically significant; effect size lets you spot when significance is "real but tiny."

  • Chi-square: works well for large samples + 2×2 or larger tables; uses chi-square distribution approximation. Fisher's exact test: works for small samples + 2×2 tables (originally; extends to larger tables computationally); gives EXACT p-values via hypergeometric distribution. Decision rule: for 2×2 tables, when any expected cell < 5, prefer Fisher's exact. For larger tables, chi-square is computationally easier + still reasonable when expected counts are moderate. Fisher's exact for larger tables requires more CPU but most modern stats software handles it.

  • Build a 2×2 contingency table: rows = A vs B variant, columns = converted vs not converted. Example: Variant A: 250 converted / 4,750 not = 5,000 total. Variant B: 280 converted / 4,720 not = 5,000 total. Run chi-square independence test: this example gives χ² = 1.79, p ≈ 0.18, so the 5.0% vs 5.6% difference is not significant at 5,000 per arm. When p < 0.05, the conversion rate differs significantly between variants. Cramér's V quantifies the effect size. For more than 2 variants: A/B/C/D table; chi-square gives omnibus "are any different?" test; follow-up with pairwise tests + Bonferroni correction.

  • For very large chi-square statistics, p-values can become so small that floating-point precision loses meaningful digits. Reporting "< 0.0001" is the standard convention when the actual value rounds to zero in scientific notation. For very small p-values, the exact magnitude rarely matters — both p = 0.00001 and p = 0.0000001 are "extremely significant"; reporting one or the other doesn't change the interpretation.

  • An adjustment for 2×2 chi-square tests when expected counts are small (5-10). Subtracts 0.5 from |observed - expected| before squaring. Effect: produces more conservative p-values. Modern practice: Yates' correction is somewhat controversial — it's overly conservative in many cases, and Fisher's exact test is generally preferred for small-sample 2×2 problems. This tool doesn't apply Yates' correction by default. If your stats course or institution requires it, use Fisher's exact instead for cleaner interpretation.

  • Yes. A significant chi-square tells you "the categories aren't independent" but doesn't tell you WHICH cells drive the difference. Post-hoc options: (1) Examine standardised residuals: (observed - expected) / √expected. Cells with |residual| > 2 contributed substantially to significance. (2) Pairwise chi-square tests on subsets of the table, with Bonferroni correction for multiple comparisons. (3) Marascuilo procedure: post-hoc method for proportions with multiple comparison adjustment built in. Most stats software automates these.

  • No. All calculations run in your browser via JavaScript. Open DevTools → Network and confirm zero outbound requests. Data stays on your device. Safe for confidential research + business data.

  • Pair with: T-Test for continuous data; ANOVA for comparing 3+ group means; Sample Size Calculator for pre-test sizing; Linear Regression for relationship modelling; Standard Deviation for descriptive stats. External: R + Python (scipy.stats), SPSS, JASP (free academic), GraphPad Prism, JMP — all support full categorical-data analysis suites.

Method & sources

How it computes

χ² = Σ (O − E)² / E. Independence: E = row total × column total ÷ N, df = (r − 1)(c − 1). Goodness of fit: df = k − 1. Cramér's V = √(χ² / (N × (min(r, c) − 1))). Cells with expected counts under 5 are flagged.

What this tool implements

  • NIST/SEMATECH e-Handbook §1.3.5.15: the goodness-of-fit test applies to binned data, and the statistic depends on how the data are binned.
  • Worked on the page: 250/5,000 vs 280/5,000 conversions gives χ² = 1.79, p = 0.18 — not significant.
  • Cohen's 0.10 / 0.30 / 0.50 cutoffs for Cramér's V apply when min(r, c) = 2 and shrink by √(min(r, c) − 1) for larger tables.

Sources

Advertisement
Pre-footer · AD-W3 728 × 90