You have two categorical variables and you want to know whether they are related. Maybe you surveyed 200 hospital patients and recorded smoking status (yes or no) and disease diagnosis (yes or no). The numbers in your cross-tabulation look different across groups, but is the difference real or just sampling noise? The chi-square test of independence answers exactly that question. It is the standard test for association between categorical variables, and it appears in nearly every field from public health to marketing research.
What the Chi-Square Test Measures
The chi-square test compares what you actually observed in your data against what you would expect if the two variables were completely unrelated. Suppose 80 of your 200 patients smoke and 60 have the disease. If smoking and disease were independent, you would expect the smokers-with-disease cell to contain (80 × 60) / 200 = 24 people. The test calculates this expected frequency for every cell in the table, then measures how far the observed counts deviate from those expected counts.
The formula is straightforward. For each cell, take the difference between observed and expected frequency, square it, and divide by the expected frequency. Sum those values across all cells and you get the chi-square statistic, χ². A large χ² means the observed data deviate substantially from what independence would predict. A small χ² means the two variables behave roughly as if they were unrelated.
The test comes in two main varieties. The chi-square test of independence checks whether two categorical variables are associated in a single sample. The chi-square goodness-of-fit test checks whether a single categorical variable follows a specific distribution (for example, whether die rolls are evenly distributed across six faces). This article focuses on the test of independence, because that is what most thesis projects require. If you are not sure whether chi-square is the right test for your design, our statistical test selection guide walks through the decision step by step.
How to Read Chi-Square Output
SPSS, R, and most statistical software produce the same core output. You will see the χ² value, degrees of freedom, and a p-value. Degrees of freedom for a chi-square test of independence equal (rows − 1) × (columns − 1). In a 2 × 2 table like smoking × disease, that gives (2 − 1)(2 − 1) = 1. A 3 × 4 table would have (3 − 1)(4 − 1) = 6. The degrees of freedom matter because the shape of the chi-square distribution changes with each df value, which in turn affects where the p-value falls.
In APA-7 format, report the result like this: χ²(1, N = 200) = 12.34, p < .001. The number in parentheses is the degrees of freedom, N is the total sample size, and the p-value tells you whether the association is statistically significant. Always report exact p-values (for example, p = .003) unless the value is below .001. For more on how to read and report p-values correctly, see our guide to interpreting p-values.
Assumptions and When They Break
The chi-square test has fewer assumptions than most parametric tests, but the ones it has are strict. The most commonly violated assumption is about expected frequencies. Every cell in your cross-tabulation must have an expected frequency of at least 5. Not the observed frequency. The expected frequency, which you compute as (row total × column total) / grand total. If even one cell falls below 5, the chi-square approximation becomes unreliable and your p-value cannot be trusted.
When expected frequencies drop below 5 in a 2 × 2 table, switch to Fisher's exact test. Fisher's test does not rely on the chi-square approximation at all. It computes the exact probability of obtaining the observed distribution (or one more extreme) under the null hypothesis. SPSS produces Fisher's exact p-value automatically alongside the chi-square result whenever you run a 2 × 2 table, so you do not need to request it separately. For tables larger than 2 × 2 with low expected frequencies, consider collapsing categories to bring the counts up, or use a Monte Carlo simulation for the p-value.
A second assumption is independence of observations. Each participant or case should appear in only one cell. If a single patient can be counted in both the "smoker with disease" cell and the "smoker without disease" cell across different time points, the observations are not independent and the test is invalid. This happens more often than you might think, especially in longitudinal studies or repeated-measures designs where the same individuals are measured multiple times.
Third, chi-square requires categorical data. Both variables must be nominal or ordinal with a limited number of categories. If you have a continuous variable like age in years, you cannot plug it directly into a chi-square test. You would need to group it into categories first (e.g., 18–30, 31–45, 46+), and that grouping decision is rarely neutral. The number of categories and the cut points you choose will affect your results.
Effect Sizes: Cramér's V and Phi
A significant chi-square result tells you the association exists. It does not tell you how strong it is. With N = 2,000, even a trivially small association will produce a significant p-value. You need an effect size, and for chi-square tests that means Cramér's V.
Cramér's V ranges from 0 (no association) to 1 (perfect association). For 2 × 2 tables, V equals the absolute value of the phi coefficient (φ), so the two are interchangeable in that specific case. For larger tables, only V applies. Cohen's benchmarks for V in a 2 × 2 table are .10 (small), .30 (medium), and .50 (large). These benchmarks shift for larger tables: in a 3 × 3 table, .07 is small, .21 is medium, and .35 is large. Always check the minimum dimension of your table (the smaller of rows or columns, minus 1) when interpreting V, because the benchmarks depend on it.
In our smoking-and-disease example, V = .25 with a 2 × 2 table. That falls between the small (.10) and medium (.30) benchmarks, so you would describe the association as small-to-medium in strength. Report it as: χ²(1, N = 200) = 12.34, p < .001, V = .25. Many students skip the effect size entirely, and supervisors consistently flag that omission. For a full explanation of why effect sizes matter and how to choose the right one for your test, read our effect size guide.
Chi-Square vs Other Tests for Categorical Data
| Feature | Chi-Square Test | Fisher's Exact Test | McNemar's Test |
|---|---|---|---|
| Purpose | Association between two categorical variables | Same as chi-square, but exact calculation | Change in a dichotomous variable (paired data) |
| Table size | Any size (2×2, 3×4, etc.) | Typically 2×2 (extensions exist for larger) | 2×2 only |
| Minimum expected frequency | ≥ 5 in every cell | No minimum required | Sum of discordant cells ≥ 10 (rule of thumb) |
| Sample independence | Independent observations | Independent observations | Paired or matched observations |
| Effect size | Cramér's V, phi (φ) | Odds ratio | Odds ratio |
| When to use | Large samples, all expected frequencies ≥ 5 | Small samples or cells with expected frequency < 5 | Before-and-after or matched-pair designs |
A Worked Example
A nursing student collects data from 200 patients at a regional hospital. She records whether each patient is a current smoker (yes or no) and whether they have been diagnosed with a specific respiratory disease (yes or no). The cross-tabulation looks like this: 80 smokers, 120 non-smokers, 60 patients with the disease, 140 without it.
She calculates expected frequencies. For the smoker-with-disease cell: (80 × 60) / 200 = 24. For smoker-without-disease: (80 × 140) / 200 = 56. Non-smoker-with-disease: (120 × 60) / 200 = 36. Non-smoker-without-disease: (120 × 140) / 200 = 84. All four expected frequencies exceed 5, so the chi-square assumption is met.
Running the test in SPSS (Analyze > Descriptive Statistics > Crosstabs, with chi-square and Cramér's V checked), she gets χ²(1, N = 200) = 12.34, p < .001, V = .25. She writes in her results section: "A chi-square test of independence showed a significant association between smoking status and disease diagnosis, χ²(1, N = 200) = 12.34, p < .001, Cramér's V = .25, indicating a small-to-medium effect." That is a clean, APA-compliant report. If you want Academic Stats Agent to generate this kind of formatted output automatically from your dataset, the app produces publication-ready chi-square tables with effect sizes included.
Common Mistakes to Avoid
The first and most common mistake is running a chi-square test on continuous data. We see this regularly: a student takes age (measured in years), income (measured in dollars), or test scores (measured on a 0–100 scale) and tries to run a chi-square. The test requires counts of cases falling into discrete categories. Continuous variables need a t-test, ANOVA, or correlation, depending on the research question. If you are comparing means, you want a t-test or ANOVA. If you are looking at relationships between continuous variables, you want a correlation or regression.
The second mistake is ignoring the expected frequency assumption. A student runs a chi-square on a 2 × 2 table where one cell has an expected frequency of 2.8. SPSS even prints a warning at the bottom of the output ("1 cell (25.0%) has expected count less than 5"). Many students either do not read that warning or do not know what to do about it. The fix is simple: report Fisher's exact test instead, which SPSS provides right next to the chi-square result in any 2 × 2 cross-tabulation.
Third, not reporting an effect size. A significant chi-square tells your reader that the variables are associated, but with no indication of how strongly. A χ² of 6.2 with N = 50 means something very different from a χ² of 6.2 with N = 5,000. Cramér's V standardizes the result so readers can judge the practical significance. We have reviewed over 300 student projects, and omitting effect sizes is among the top five feedback items supervisors raise.
Fourth, confusing chi-square with tests for ordinal or interval data. If your categorical variable has a natural order (e.g., education level: high school, bachelor's, master's, doctorate), a standard chi-square ignores that ordering entirely. It treats the categories as unordered labels. For ordinal associations, the linear-by-linear association test or Somers' d may be more appropriate and more powerful, because they can detect trends that chi-square misses.
Key takeaway: The chi-square test of independence checks whether two categorical variables are associated by comparing observed frequencies against what you would expect under independence. Report it as χ²(df, N) = value, p = value, and always include Cramér's V (or phi for 2 × 2 tables) as the effect size. Check that all expected frequencies are at least 5; if not, use Fisher's exact test for 2 × 2 tables. Never use chi-square on continuous variables.
Frequently Asked Questions
Can the chi-square test be used with small samples?
Only if the expected frequencies are adequate: the standard rule is that no more than 20% of cells should have an expected count below 5, and no cell should be below 1. If that rule is violated, use Fisher's exact test instead, especially for 2x2 tables.
What are expected frequencies in a chi-square test?
Expected frequencies are the counts you would see in each cell if the two variables were completely independent. Each one is calculated as (row total × column total) / grand total, and the chi-square statistic measures how far the observed counts deviate from these values.
What effect size should I report with a chi-square test?
Report the phi coefficient for 2x2 tables and Cramer's V for larger tables. Both range from 0 to 1, with values around .10 considered small, .30 medium, and .50 large for tables with one degree of freedom.