Table of Contents
A chi-square test compares observed data against expected values to check whether a relationship between categorical variables is real or due to chance. Its two main types are goodness of fit and test of independence, both built on the formula χ² = Σ (O − E)² ÷ E.
The chi-square (χ²) test is a non-parametric statistical test used to analyse categorical data. It checks whether observed frequencies differ significantly from the frequencies you would expect if no pattern or relationship existed.
Researchers rely on it across dissertations, surveys and lab reports whenever variables are grouped into categories rather than measured on a continuous scale — for example gender, grade band, subject choice or yes/no survey answers.
Unlike a t-test or ANOVA, chi-square never compares group means. It works purely with counts, frequencies and proportions across defined categories, which sets it apart within the wider family of hypothesis tests.
Because it does not assume a normal distribution, chi-square suits nominal or ordinal data well. For a wider view of when to use it, see our guide to choosing the right statistical test for your project.
The core formula is χ² = Σ (O − E)² ÷ E, where O is the observed frequency in each category and E is the expected frequency under the null hypothesis. You sum this across every cell.
The Greek letter chi (χ) gives the test its name; squaring the difference removes negative values, so every gap between observed and expected counts adds positively to the final statistic.
A larger χ² value signals a bigger gap between what you observed and what you expected, suggesting the variables are related. A small value suggests the data fits the expected pattern closely.
Expected frequency for a contingency table cell equals (row total × column total) ÷ grand total. Get this step wrong and the whole result becomes unreliable, so check every cell twice.
There are two common chi-square tests. The goodness of fit test checks whether one categorical variable matches an expected distribution. The test of independence checks whether two categorical variables are associated.
Goodness of fit suits questions like “do dice rolls land evenly across six faces?” Test of independence suits questions like “is study method linked to pass or fail rate?” Both use the same core formula.
Dissertations tend to use the test of independence more often than goodness of fit, since most research questions ask whether two variables — such as treatment group and outcome — are connected.
Choosing between them depends entirely on how many categorical variables your research question involves, and whether you are checking one distribution or the relationship between two separate variables.
Chi-square tests rely on a few conditions. Data must be counts or frequencies, not percentages or measurements, and each observation must fall into exactly one category.
Categories must be mutually exclusive, and observations need to be independent of one another — one participant’s response should not influence another participant’s response.
Expected cell frequencies should generally reach five or higher. Where this is not possible, consider merging categories or applying an exact test such as Fisher’s exact test instead.
Every chi-square test follows the same broad process, whether you are testing one variable or two. Working through it methodically avoids the calculation errors that most often trip up students.
Step one states the null and alternative hypotheses clearly. Step two builds a table of observed frequencies, then calculates the expected frequency for each cell using the formula above.
Once you have χ², compare it against the critical value from a chi-square distribution table, or read the exact p-value from software such as SPSS — see our SPSS data analysis help guide if you are new to the package.
A chi-square test behaves like a one-tailed test in practice, since squaring the differences removes direction — only large discrepancies between observed and expected counts push the statistic toward significance.
The table below summarises the practical differences between the two tests, including the variables involved and how degrees of freedom are worked out for each.
| Feature | Goodness of Fit | Test of Independence |
|---|---|---|
| Variables tested | One categorical variable | Two categorical variables |
| Null hypothesis | Sample matches expected distribution | No association between the variables |
| Typical example | Are survey answers evenly split? | Is smoking status linked to gender? |
| Degrees of freedom | Categories − 1 | (Rows − 1) × (Columns − 1) |
| Data layout | Single row or column of categories | Contingency table (rows × columns) |
Degrees of freedom (df) tell you which row of the chi-square distribution to check. For goodness of fit, df equals the number of categories minus one. For independence, df equals (rows − 1) × (columns − 1).
Once you have df and a significance level, usually 0.05, look up the critical value in a chi-square table. If your calculated χ² exceeds it, reject the null hypothesis.
Most statistics software reports an exact p-value instead of a table lookup. If p falls below your significance level, the result is statistically significant, following the same logic covered in our guide to hypothesis testing.
With small samples, consider Yates’ continuity correction for 2×2 tables, or switch to Fisher’s exact test, since standard chi-square can overstate significance when expected counts are low.
Most UK social science departments expect APA-style reporting for chi-square: the symbol, degrees of freedom and sample size in brackets, then the statistic and exact p-value.
Write it as χ²(df, N = sample size) = value, p = .xxx — for example χ²(2, N = 150) = 9.12, p = .010, matching the worked example above.
Round χ² to two decimal places and the p-value to three, dropping the leading zero in APA style, and switch to “p < .001” once the exact value rounds to zero.
A handful of errors account for most marks lost on chi-square write-ups. Watch for these before you submit any results chapter or lab report.
Running and reporting a chi-square test correctly takes practice, especially when you are also writing up methodology and results chapters against a deadline.
Our statistical analysis service supports UK students with SPSS, R and Excel workings, correct formula application, and clearly written results sections for dissertations and reports.
If you need broader support with your research project, explore our dissertation writing service, or browse more statistical analysis guides for step-by-step help with other tests.
A chi-square test checks whether categorical data fits an expected pattern (goodness of fit) or whether two categorical variables are related (test of independence). It compares observed frequencies against expected frequencies to reveal genuine relationships rather than random variation in survey or experimental data.
The chi-square formula is χ² = Σ (O − E)² ÷ E, where O is the observed frequency and E is the expected frequency for each category or cell. You calculate this for every cell, then sum the results to get the final chi-square statistic.
Goodness of fit tests whether one categorical variable matches an expected distribution, such as checking if dice rolls are fair. The test of independence checks whether two categorical variables are associated, such as year group and coffee habit, using a contingency table layout.
For goodness of fit, degrees of freedom equal the number of categories minus one. For a test of independence, degrees of freedom equal (number of rows − 1) multiplied by (number of columns − 1). This value determines which row of the chi-square table to check.
There is no fixed minimum, but guidance generally recommends expected frequencies of at least five in every cell. If several cells fall below this, results become unreliable, and you may need to combine categories or use an alternative such as Fisher’s exact test.
Compare your calculated χ² value to the critical value from a chi-square table at your chosen significance level and degrees of freedom, or check the p-value in your software output. If χ² exceeds the critical value, or p is below 0.05, reject the null hypothesis.
You May Also Like