Chi-Square Tests: Goodness of Fit and Independence
T-tests and ANOVA compare means, which works only when the outcome is measured on a continuous scale. Much of the data researchers actually collect is categorical: yes or no, agree or disagree, treatment group A, B, or C. Comparing frequencies rather than means requires a different family of tests, and the chi-square test is the standard tool for the job.
Chi-square tests are among the most widely used inferential statistics in survey research, epidemiology, market research, and any field where categorical outcomes are common. This guide explains the two most common types (goodness of fit and independence), when to use each, how to calculate them by hand, and how to report them in academic papers.
What Is a Chi-Square Test?
A chi-square test compares observed frequencies (the counts actually collected in the data) to expected frequencies (the counts predicted under a null hypothesis). If the observed and expected frequencies are close, the chi-square statistic is small and the p-value is large. If they diverge substantially, the chi-square statistic is large and the p-value is small, suggesting the null hypothesis does not fit the data.
The general formula is the same for all chi-square tests:
χ² = Σ [(Observed − Expected)² / Expected]
The chi-square statistic is compared to a chi-square distribution with the appropriate degrees of freedom to obtain a p-value. Chi-square tests belong to the broader family of hypothesis testing procedures, and every chi-square test starts with a null hypothesis about the frequencies and an alternative hypothesis that they differ from expectation.
The Two Main Types of Chi-Square Tests
| Test Type | Question It Answers | Example Research Question |
|---|---|---|
| Chi-square goodness of fit | Do observed frequencies in one categorical variable match a hypothesized distribution? | Are dissertation students evenly distributed across four departments, or does one department produce more than expected? |
| Chi-square test of independence | Are two categorical variables related to each other? | Is preference for citation style (APA, MLA, Chicago) related to academic discipline? |
The two tests share the same underlying formula but answer different questions. Goodness of fit examines a single categorical variable and compares its distribution to a theoretical or expected pattern. The test of independence examines whether two categorical variables are associated. A third variant, the chi-square test of homogeneity, tests whether the distribution of a categorical variable is the same across multiple populations. Its calculations are identical to those of the test of independence, so most textbooks treat them together.
The Chi-Square Goodness of Fit Test
The goodness of fit test evaluates whether the frequencies observed in a single categorical variable match a hypothesized distribution. The hypothesized distribution might be equal proportions across categories, a known population distribution, or a theoretical distribution from a model.
Example. A graduate school administrator wants to know whether dissertation students are evenly distributed across four departments. If the null hypothesis of equal distribution is true, each department should have 25 percent of the 200 doctoral students, or 50 students each. The observed counts are:
- Department A: 62 students
- Department B: 41 students
- Department C: 55 students
- Department D: 42 students
Step 1. Calculate the expected count for each category: 200 × 0.25 = 50 for each department.
Step 2. Calculate (Observed − Expected)² / Expected for each category:
- A: (62 − 50)² / 50 = 144 / 50 = 2.88
- B: (41 − 50)² / 50 = 81 / 50 = 1.62
- C: (55 − 50)² / 50 = 25 / 50 = 0.50
- D: (42 − 50)² / 50 = 64 / 50 = 1.28
Step 3. Sum the values: χ² = 2.88 + 1.62 + 0.50 + 1.28 = 6.28
Step 4. Identify degrees of freedom: df = k − 1 = 4 − 1 = 3, where k is the number of categories.
Step 5. Compare to the critical value. For df = 3 at α = 0.05, the critical chi-square value is 7.815. Because 6.28 is less than 7.815, we fail to reject the null hypothesis. The p-value is approximately 0.099.
The distribution of students across departments does not differ significantly from equal at the conventional 0.05 level, though the p-value is close enough to suggest the pattern is worth examining with a larger sample.
The Chi-Square Test of Independence
The test of independence examines whether two categorical variables are related. Data are organized in a contingency table with rows representing one variable and columns representing the other. The test compares the observed cell frequencies to the frequencies expected if the two variables were unrelated.
Expected frequencies are calculated using:
Expected = (Row total × Column total) / Grand total
Example. A researcher surveys 300 graduate students to examine whether preference for citation style is related to academic discipline. The observed contingency table looks like this:
| Discipline | APA | MLA | Chicago | Row Total |
|---|---|---|---|---|
| Social Sciences | 85 | 10 | 15 | 110 |
| Humanities | 10 | 60 | 30 | 100 |
| Business | 50 | 15 | 25 | 90 |
| Column Total | 145 | 85 | 70 | 300 |
Step 1. Calculate expected frequencies for each cell. For Social Sciences × APA: (110 × 145) / 300 = 53.17. The full expected table:
| Discipline | Expected APA | Expected MLA | Expected Chicago |
|---|---|---|---|
| Social Sciences | 53.17 | 31.17 | 25.67 |
| Humanities | 48.33 | 28.33 | 23.33 |
| Business | 43.50 | 25.50 | 21.00 |
Step 2. Calculate (Observed − Expected)² / Expected for each cell and sum. The largest contributions come from the Social Sciences-APA cell (over-represented) and the Humanities-MLA cell (over-represented). The total chi-square value works out to approximately χ² = 108.4.
Step 3. Identify degrees of freedom: df = (rows − 1)(columns − 1) = 2 × 2 = 4.
Step 4. Compare to the critical value. For df = 4 at α = 0.05, the critical chi-square value is 9.488. Because 108.4 is far greater than 9.488, we reject the null hypothesis. The p-value is less than 0.001.
Citation style preference is strongly associated with academic discipline. The pattern of observed frequencies suggests that social sciences favor APA, humanities favor MLA, and business shows a mixed pattern with APA leading.
Assumptions of the Chi-Square Test
Chi-square tests are less demanding than parametric tests but still rest on several assumptions.
- Categorical data. Both variables must be categorical (nominal or ordinal). Continuous variables must be binned into categories before analysis, though this often loses information.
- Independence of observations. Each participant contributes to only one cell. Repeated measures on the same participants require a different test, such as McNemar's test for paired categorical data.
- Expected frequencies large enough. No expected frequency should be less than 1, and no more than 20 percent of expected frequencies should be less than 5. When these conditions fail, use Fisher's exact test instead, particularly for 2 × 2 tables.
- Random sampling. The data should come from a random sample of the population of interest.
Effect Sizes for Chi-Square Tests
A significant chi-square tells you a relationship exists but not how strong it is. Effect sizes for chi-square tests describe the strength of the association.
- Phi (φ) is used for 2 × 2 tables. Values range from 0 to 1, with 0.1, 0.3, and 0.5 corresponding to small, medium, and large effects.
- Cramér's V is used for larger tables. Values range from 0 to 1 and are interpreted using the same conventions as phi, adjusted for table size.
- Odds ratios and relative risks are common in medical and epidemiological research for 2 × 2 tables and are often more informative than phi because they directly quantify the strength of association.
Always report effect sizes alongside chi-square statistics. A significant chi-square with a very small Cramér's V may indicate a statistically detectable but practically trivial association, especially in large samples.
Reporting Chi-Square Results in APA Format
The APA format for chi-square results includes the statistic, degrees of freedom in parentheses, the sample size, the p-value, and an effect size. The general template is:
χ²(df, N = sample size) = value, p = p-value, φ or V = effect size
Complete examples for each test type:
Goodness of fit: "A chi-square goodness of fit test was conducted to examine whether doctoral students were evenly distributed across four departments. The distribution did not differ significantly from equal, χ²(3, N = 200) = 6.28, p = .099."
Test of independence: "A chi-square test of independence revealed a significant association between academic discipline and preferred citation style, χ²(4, N = 300) = 108.4, p < .001, Cramér's V = 0.42. Social science students strongly preferred APA, humanities students preferred MLA, and business students showed a mixed pattern with APA leading."
Common Mistakes to Avoid
Using chi-square on continuous data. Continuous variables should be analyzed with t-tests, ANOVA, correlation, or regression, not by binning into arbitrary categories.
Ignoring small expected frequencies. When expected frequencies fall below 5 in more than 20 percent of cells, the chi-square approximation becomes unreliable. Fisher's exact test is the appropriate alternative for small samples in 2 × 2 tables.
Using chi-square on paired categorical data. Studies where the same participants provide categorical responses at two time points (or under two conditions) require McNemar's test, not chi-square. Independence of observations is a strict requirement.
Reporting only the p-value. Chi-square reports require the statistic, degrees of freedom, sample size, and an effect size at minimum. Descriptive statistics (usually the observed counts or percentages) should also appear in the results.
Interpreting a significant chi-square as a cause. A significant test of independence indicates that two variables are associated, not that one causes the other. Causal claims require experimental designs or careful causal inference methods.
Before You Submit: A Self-Audit
Work through this checklist before submitting a paper reporting chi-square results:
- Are both variables genuinely categorical?
- Have you confirmed that expected frequencies meet the minimum size requirements?
- Is the observed contingency table (or frequency distribution) reported in the paper?
- Are the chi-square statistic, degrees of freedom, and sample size all reported?
- Is an effect size (phi or Cramér's V) reported alongside the p-value?
- Does the discussion avoid causal language that the design does not support?
- For 2 × 2 tables with small expected frequencies, has Fisher's exact test replaced chi-square?
Chi-square tests appear throughout survey research, epidemiology, and any study with categorical outcomes, and their reporting conventions are specific enough that small omissions are common findings in peer review. If you have finished your analysis and want a professional editor to review your methods, results, and statistical reporting before submission, Editor World offers journal article editing by editors with subject-matter backgrounds. Clients browse editor profiles and choose the editor whose expertise best matches their field. A free sample edit on the first 300 words is available for every project, and a certificate of editing is available as an optional add-on for publishers or committees that require one.
Frequently Asked Questions
What is the difference between the chi-square goodness of fit test and the test of independence?
The goodness of fit test examines whether a single categorical variable follows a hypothesized distribution, such as equal proportions across categories. The test of independence examines whether two categorical variables are related to each other. Both use the same formula but answer different questions.
When should I use Fisher's exact test instead of chi-square?
Use Fisher's exact test when expected frequencies are too small for chi-square to be reliable. The standard rule is that Fisher's exact test is preferred when any expected frequency is less than 5 in a 2 × 2 table, or when more than 20 percent of expected frequencies fall below 5 in larger tables.
Can I use chi-square with continuous data?
Chi-square requires categorical data. Continuous variables must be binned into categories before analysis, but doing so typically loses information and reduces statistical power. Continuous outcomes are better analyzed with t-tests, ANOVA, correlation, or regression, depending on the research question.
What effect size should I report for a chi-square test?
For 2 × 2 tables, report phi (φ). For larger tables, report Cramér's V. In medical and epidemiological research, odds ratios and relative risks are common alternatives for 2 × 2 tables and often communicate more directly than phi. Report an effect size even when the chi-square is significant, because significance alone does not indicate strength of association.
Does a significant chi-square test mean one variable causes the other?
No. A significant chi-square test of independence indicates that two variables are associated, not that one causes the other. Causal claims require experimental designs with random assignment or careful causal inference methods. Observational data can identify associations but cannot establish causation on their own.