If you work with categorical data, the chi-square test is the classic way to find out whether patterns in your counts are real. It checks either the independence of two variables in a contingency table or how well observed counts fit an expected distribution. Survey analysts, quality engineers, genetics researchers, and marketing teams use it weekly to compare response patterns, defect types, and segment shares. Because it only needs counts, it works on data that averages cannot describe.
The formula and a worked example
The statistic is chi-square = sum of (O - E) squared over E, where O is each observed count and E is the matching expected count. For a table, degrees of freedom equal (rows - 1) x (cols - 1), and a goodness-of-fit test uses the number of categories minus 1. Take 600 die rolls where every face should show 100 times and the observed counts are 90, 105, 110, 95, 100, and 100.
Each face contributes a squared gap divided by 100: that gives 1, 0.25, 1, 0.25, 0, and 0, so the total chi-square statistic is 2.5 with 5 degrees of freedom. That value falls far below the 11.07 cutoff for significance, so the die looks fair.
How to run the test
Running the test starts with a choice. Pick the Chi-Square test type, either of Independence / Homogeneity for a contingency table or of Goodness-of-fit for a single categorical variable, then enter your counts into Table data and press Calculate. The output pairs the chi-square statistic with a P-value at your chosen degrees of freedom. Two quick tips keep results honest: no expected cell should fall below 5, and a significant P-value shows association, never cause.
Frequently Asked Questions
What does a high chi-square value indicate?
A high value means observed counts drift far from the counts expected if your null hypothesis were true. With 600 die rolls, a statistic of 2.5 looks fair, while 25 would strongly suggest a loaded die.
How do I find the degrees of freedom?
For a contingency table, degrees of freedom equal (rows - 1) x (cols - 1), so a 3x4 table gives 2 x 3 = 6. A goodness-of-fit test with 6 categories uses 5 degrees of freedom.
When should I use this test?
Use it when your data are category counts rather than measurements, such as survey answers, defect types, or blood groups. It is the standard tool for testing independence between two categorical variables in a contingency table.
What sample size does the test need?
Every expected count should be at least 5 for the approximation to hold, which pushes reliable tests toward totals of 50 or more. With tiny samples, Fisher's exact test is the safer alternative for a 2x2 table.
Is a significant result proof of causation?
No, a small P-value only shows that the pattern is unlikely under the no-association hypothesis. A chi-square of 10 on 1 degree of freedom linking brand and satisfaction still cannot tell you which variable drives the other.