A chi-square test is a statistical test that checks whether two categorical variables are related, by comparing the counts you actually observed against the counts you'd expect if there were no relationship at all. If you've got survey data full of categories — "yes/no", "Group A/B/C", "male/female" — and you're staring at a spreadsheet wondering whether the pattern is real or just noise, this is almost certainly the test you need.
Key Takeaways
- A chi-square test works on counts (frequencies) of categories, not on averages or measurements — use it when both variables are categorical.
- The chi-square test of independence asks whether two variables are associated (e.g., does treatment group relate to recovery?); the goodness-of-fit test asks whether one variable matches an expected distribution.
- A result is statistically significant when p < .05, meaning the observed pattern is unlikely to be due to chance alone.
- APA 7 reports chi-square as χ²(df, N = sample size) = value, p = value, plus an effect size like Cramér's V.
- Chi-square only tells you that variables are related, not how strongly or in which direction — that's why you also report an effect size.
What Does a Chi-Square Test Actually Do?
A chi-square test compares what you observed to what you'd expect by chance. Imagine you surveyed 100 people about whether they prefer tea or coffee, split by whether they work mornings or nights. If shift and drink preference are unrelated, you'd expect roughly the same proportion of tea-drinkers in both shifts. The chi-square test measures how far your real numbers stray from that "no relationship" scenario. A big gap produces a large chi-square statistic — evidence that the variables really are connected.
The key thing to remember: chi-square works on frequencies (how many people fall into each box), not on scores or measurements. If you're comparing average test scores between groups, you want a t-test or ANOVA instead. If you're counting how many people fall into categories, chi-square is your tool.
When Should I Use a Chi-Square Test?
Use a chi-square test when both of your variables are categorical and you want to know if they're related. Common examples:
- Does gender relate to voting preference?
- Does treatment group (drug vs. placebo) relate to outcome (improved vs. not improved)?
- Does education level relate to product choice?
There are two main flavours you'll actually run into:
Chi-Square Test of Independence
This checks whether two categorical variables are associated. Example: "Is there a relationship between smoking status and lung disease diagnosis?" This is the version most theses and surveys use.
Chi-Square Goodness-of-Fit Test
This checks whether one categorical variable matches an expected distribution. Example: "Do customers pick our four flavours equally, or is one clearly favoured?" You compare observed counts against a hypothesised split (e.g., 25% each).
If you're unsure which test your data needs, StatRyx can detect that your variables are categorical and pick the correct chi-square variant for you automatically — no flowchart required.
What Are the Assumptions?
Before trusting a chi-square result, check these:
- Independence of observations — each person or case appears in only one cell.
- Categorical variables — nominal or ordinal, counted as frequencies.
- Expected count of at least 5 in most cells. If more than 20% of cells have expected counts below 5, use Fisher's exact test instead (especially in 2×2 tables).
A Worked Chi-Square Example With Real Numbers
Let's walk through a chi-square test of independence step by step.
The study: A researcher surveys 150 patients to see whether a new therapy relates to recovery. Patients are split into two groups (Therapy vs. Control), and each is classified as Recovered or Not Recovered.
Here's the observed data (the contingency table):
| Recovered | Not Recovered | Row total | |
|---|---|---|---|
| Therapy | 45 | 30 | 75 |
| Control | 30 | 45 | 75 |
| Column total | 75 | 75 | 150 |
Step 1 — Find the expected counts. For each cell: (row total × column total) ÷ grand total.
For the Therapy/Recovered cell: (75 × 75) ÷ 150 = 37.5. Every cell here expects 37.5 under "no relationship."
Step 2 — Compare observed to expected. The formula sums (observed − expected)² ÷ expected across all four cells:
- Therapy/Recovered: (45 − 37.5)² ÷ 37.5 = 1.5
- Therapy/Not Recovered: (30 − 37.5)² ÷ 37.5 = 1.5
- Control/Recovered: (30 − 37.5)² ÷ 37.5 = 1.5
- Control/Not Recovered: (45 − 37.5)² ÷ 37.5 = 1.5
Step 3 — Add them up. χ² = 1.5 + 1.5 + 1.5 + 1.5 = 6.0.
Step 4 — Find degrees of freedom. df = (rows − 1) × (columns − 1) = (2 − 1) × (2 − 1) = 1.
Step 5 — Check significance. For df = 1, the critical value at α = .05 is 3.84. Our χ² of 6.0 exceeds that, giving p = .014. Since p < .05, the relationship is statistically significant.
Step 6 — Report the effect size. Cramér's V for a 2×2 table = √(χ² ÷ N) = √(6.0 ÷ 150) = 0.20, a small-to-moderate effect.
What Does the Result Mean in Plain English?
Patients in the therapy group recovered at a higher rate (60%) than the control group (40%), and this difference is unlikely to be chance (p = .014). But the effect size (Cramér's V = 0.20) tells us the relationship, while real, is modest — therapy matters, but it's not a dramatic difference. This is why you always pair a chi-square with an effect size: significance tells you the relationship is real; the effect size tells you whether it's big enough to care about.
How Do I Report a Chi-Square Test in APA 7 Format?
APA 7 wants the statistic, degrees of freedom, sample size, p value, and an effect size. For our example:
A chi-square test of independence showed a significant association between treatment group and recovery, χ²(1, N = 150) = 6.00, p = .014, Cramér's V = 0.20.
Notice the APA conventions: χ² and p are italicised, there's no leading zero on p (.014, not 0.014), and the sample size appears inside the parentheses. Getting this formatting right by hand trips up a lot of students, which is exactly the kind of write-up StatRyx generates for you automatically.
Chi-Square vs. Other Common Tests
| Test | Use when… | Data type | Example question |
|---|---|---|---|
| Chi-square | Comparing counts across categories | Categorical × categorical | Is gender related to product choice? |
| Independent t-test | Comparing 2 group means | Categorical × continuous | Do men and women differ in average score? |
| One-way ANOVA | Comparing 3+ group means | Categorical × continuous | Do 3 teaching methods differ in test scores? |
| Fisher's exact | Small samples / low expected counts | Categorical × categorical (2×2) | Same as chi-square, but n is small |