Run a chi-square test on a table of counts CHI-SQUARE
Paste a contingency table, or two columns of categories, and see whether the rows and columns are related: expected counts, chi-square, degrees of freedom, p and Cramér's V, with a warning when the counts are too small for the test.
The test
The counts
The result
For the write-up
How it works
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.
Doing this often? OBSCURA Gnosis crosstabulates any two variables of a .sav, CSV or Excel file and runs chi-square on them, with the output saved to Word or PDF. On its own, US$2 a month; with everything else, US$5 a month or US$48 a year.