Chi Square Calculator

Run a chi-square test of independence on any r×c contingency table, or a goodness-of-fit test against expected proportions. You get expected counts, χ², df, the p value, Cramér's V and an APA 7 sentence, all computed in your browser.

Results
StatisticValue
χ²3.56
df2.00
p-value0.169
Cramér's V.17
N120

APA report

χ²(2, N = 120) = 3.56, p = .169, V = .17

Have full study data?

Upload your dataset and generate a complete paper draft with statistics, figures, and references—free preview.

Generate paper

How to use the chi square calculator

**Test of independence (contingency table)**

1. Choose **Independence** and set the number of rows and columns, or paste a table of counts (from Excel, Google Sheets or a CSV). 2. Enter the **observed frequencies** in each cell. These must be counts, not percentages or means. 3. For a 2×2 table, decide whether to apply **Yates' continuity correction**. 4. Read the expected counts, χ², degrees of freedom, p value and Cramér's V. The calculator warns you if any expected count is below 5. 5. Copy the APA 7 report sentence.

**Goodness of fit**

1. Choose **Goodness of fit**. 2. Enter the observed count for each category. 3. Enter the expected proportions (or expected counts). Leave them equal to test a uniform distribution. 4. Read χ², df and p.

Your data are processed only in the browser and are never uploaded.

What the chi-square test does and when to use it

The chi-square (χ²) test compares the frequencies you **observed** with the frequencies you would **expect** if a null hypothesis were true.

  • **Test of independence:** are two categorical variables related? Example: is treatment group (drug vs placebo) associated with outcome (improved vs not improved)? Is gender associated with preferred study mode?
  • **Goodness of fit:** does one categorical variable follow a specified distribution? Example: do survey respondents' answers match the population's known 50/30/20 split?

Use it when both variables are categorical (nominal or ordinal treated as categories) and your data are counts of independent cases. If you want to compare means of a continuous outcome, use the [t test calculator](/tools/t-test-calculator) instead. For very small 2×2 tables, consider the [Fisher exact test calculator](/tools/fisher-exact-test-calculator).

Assumptions

  • **Independent observations.** Each person or item appears in exactly one cell. Repeated measures on the same people (before/after) violate this; McNemar's test is designed for paired 2×2 data.
  • **Counts, not percentages.** Converting to percentages changes the result.
  • **Large enough expected counts.** A common rule of thumb is that all expected counts should be at least 5 (some texts allow up to 20% of cells below 5 as long as none is below 1). When the rule fails, merge sparse categories or use Fisher's exact test.
  • **Categories are mutually exclusive and exhaustive.**

Formula

For each cell, the expected count under independence is

`E = (row total × column total) / N`

The test statistic sums the squared differences between observed (O) and expected (E) counts:

`χ² = Σ (O − E)² / E`

Degrees of freedom: `df = (r − 1) × (c − 1)` for an r×c table, and `df = k − 1` for a goodness-of-fit test with k categories.

Yates' correction for 2×2 tables: `χ² = Σ (|O − E| − 0.5)² / E`. It makes the test more conservative.

Effect size, Cramér's V: `V = √( χ² / (N × (min(r, c) − 1)) )`. For a 2×2 table this equals the phi coefficient (in absolute value).

Worked example

100 patients were randomised to a new treatment or control, and the outcome was recorded as improved or not improved:

| | Improved | Not improved | Total | |---|---|---|---| | Treatment | 30 | 20 | 50 | | Control | 18 | 32 | 50 | | Total | 48 | 52 | 100 |

**Expected counts:** improved = 50 × 48 / 100 = 24; not improved = 50 × 52 / 100 = 26 (the same for both rows). All are above 5, so the assumption holds.

**χ²** = (30 − 24)²/24 + (20 − 26)²/26 + (18 − 24)²/24 + (32 − 26)²/26 = 1.500 + 1.385 + 1.500 + 1.385 = **5.77**

df = (2 − 1)(2 − 1) = 1, giving **p = .016**. Cramér's V = √(5.77 / 100) = **0.24**.

With Yates' correction, χ²(1) = 4.85, p = .028; still significant at α = .05.

**Goodness-of-fit example:** 100 respondents chose options A/B/C as 48/35/17. Against the expected 50%/30%/20%, χ²(2) = 1.36, p = .506, so the sample does not differ significantly from that distribution.

How to interpret and report the result in APA 7

A p value below .05 means the observed counts differ from the expected counts more than chance alone would usually produce, so the variables are associated. Look at the cells where O differs most from E to describe the pattern (here, more treated patients improved than expected). Cramér's V tells you how strong the association is; Cohen's conventional benchmarks for df = 1 are about .10 (small), .30 (medium) and .50 (large).

APA 7 format includes df and the sample size:

> A chi-square test of independence showed a significant association between group and outcome, χ²(1, *N* = 100) = 5.77, *p* = .016, *V* = .24. Patients in the treatment group improved more often (60%) than those in the control group (36%).

If you have the full dataset rather than just a table, Data2Paper's [Generate Paper](/generate-paper) can run the analysis and draft a complete paper with tables, figures and discussion; the first part is free to preview.

Common mistakes

  • Entering **percentages or means** instead of raw counts.
  • Counting the **same participant more than once** (for example multiple-response survey items).
  • Ignoring the **expected count < 5** warning.
  • Reporting χ² without **df and N**, or without an effect size.
  • Treating a significant χ² as evidence of **causation**; in observational data it only shows association.
  • Running many χ² tests on the same data without adjusting for multiple comparisons.

Need a p value for a χ² statistic someone else reported? Use the [p value calculator](/tools/p-value-calculator).

FAQ

Related calculators