The test

The counts

The result

For the write-up


    

How it works

Paste a table of counts, or two columns of categories. CHI-SQUARE works out the expected counts, chi-square, degrees of freedom, p and Cramér’s V, with adjusted residuals for each cell, and adds Fisher’s exact test and Yates’s correction on a two-by-two table. It warns when expected counts are too small, and runs in this tab.

In more detail

CHI-SQUARE also runs Fisher's exact test and Yates's correction on a two-by-two table, shows adjusted residuals so you can see which cells drive the result, and tests counts against expected shares for goodness of fit. Every figure is held to SciPy, and nothing typed here leaves this tab.

What it does, and what it does not

The test of independence asks whether the pattern in a table of counts, say smokers and non-smokers by region, is more uneven than chance would make it if the two had nothing to do with each other. It works out the count each cell would have if they were unrelated, adds up how far the real counts are from those, and reads p from the chi-square distribution. The adjusted residual in each cell is how many standard errors that cell is from its expected count; beyond about 2 either way is where the association lives.

The test needs counts of separate people or things, each counted once. It is not for percentages, means or measurements, and not for the same people counted twice (before and after needs McNemar's test, which this page does not run). Fisher's exact test is given only for two-by-two tables; a larger table with small expected counts needs categories combined, or an exact test this page does not offer. Nothing corrects for running many tests.

The likelihood-ratio chi-square (G) is shown as well, since some fields report it. Every figure, including Fisher's exact p, is held to SciPy in this site's own tests. For scores rather than counts, T-TEST compares two means.

The guide: An SPSS alternative that opens .sav files in your browser

Questions people ask about CHI-SQUARE

What does the warning about expected counts below 5 mean?

The chi-square test’s p-value comes from an approximation that is good when every cell’s expected count is reasonably large. The usual rule, from Cochran, is that no expected count should be below 1 and no more than a fifth below 5. When a table breaks it, the page says how many cells do; on a two-by-two table use Fisher’s exact test, which needs no approximation and is shown beside it.

Should I use Yates’s correction?

On a two-by-two table it makes the test more conservative, often more than it needs to. Many statisticians now prefer the uncorrected Pearson test with large counts and Fisher’s exact test with small ones. Both corrected and uncorrected figures are shown so you can report the one your field expects.

What is Cramér’s V?

A measure of how strong the association is, from 0 (none) to 1 (each row predicts the column exactly), that does not grow with the sample size the way chi-square does. On a two-by-two table it equals the absolute value of phi. A significant chi-square with a small V means a real but weak association, which is common with large samples.

Can I paste raw data instead of a table?

Yes. Choose ‘Two columns of categories’ and paste two columns, one row per person or case. The page counts them into a table and runs the test on that. A row with either value blank is left out, and the count says how many were.

What is the goodness-of-fit test for?

Whether counts in one set of categories match the shares you expected: a die that should be fair, survey responses against census proportions. Type the counts and, if the expected shares are not equal, a second column of proportions or counts. The shares are scaled to the total, so 25, 25, 50 and 0.25, 0.25, 0.5 mean the same.

Who can see your file
WhoCan they see it?
YouYes
OBSCURA OSNo. Your file never reaches us.
Someone who breaks into our serversNo. Your file is not there.
Advertisers or partnersNo.
Anyone using your unlocked computer, or a harmful browser extensionYes. Keep your device and browser clean.

Worked example

How 240 people of three age groups read the news: on paper, on a screen or listened to. Worked out when this page was built, by the same code the calculator runs in your browser:

CHI-SQUARE: test of independence

  Observed (expected)
                    18 to 34        35 to 54        55 and over     
  On paper          14 (26.95)      29 (31.50)      41 (25.55)      
  On a screen       52 (38.18)      44 (44.63)      23 (36.20)      
  Listened to       11 (11.87)      17 (13.88)      9 (11.25)       

  Pearson chi-square(4, N = 240) = 26.806, p = 2.18e-5
  Likelihood ratio G(4) = 26.885, p = 2.10e-5
  Cramer’s V = 0.236
  No expected count below 5; smallest 11.25.

A chi-square test of independence found a statistically significant
association between the row and column categories, χ²(4, N = 240) = 26.81, p
< .001, Cramér’s V = .24.

What it does not do

  • It does not give a reliable p-value when too many expected counts are small; it says so, and gives Fisher’s exact test on a two-by-two table.
  • It does not run tests on measurements; it works on counts.

Load this page, turn off Wi-Fi, and run the tool. It still works.