Chi-square test of independence
Test whether two categorical variables are related, with Cramér's V and Fisher's exact test.
7 min read
Try it
One click opens the “Teaching-method study” sample dataset with this test selected and the variables filled in. Or use your own data.
The chi-square test of independence asks whether two categorical variables are related. For example: is teaching method related to passing the exam? Is gender related to choice of faculty?
When to use it
- You have two categorical variables measured on the same people.
- Each person is counted in exactly one cell of the table (independent observations).
- The data are counts, not percentages or means.
The idea
Build a contingency table and compare the observed counts (O) with the expected counts (E): the counts you would expect if the two variables were unrelated.
The further the observed counts are from the expected counts, the larger χ². The effect size is Cramér's V, from 0 to 1.
Assumption: expected counts
- No more than 20% of cells should have expected counts below 5, and none should be below 1 (Cochran, 1954).
- For 2×2 tables, Lucidstat always computes Fisher's exact test and Yates' corrected χ² as well. With small expected counts, report Fisher's exact test.
- For tables larger than 2×2 with small expected counts, consider merging categories that belong together.
Worked example
The "Teaching-method study" sample (90 students) tests whether teaching method is related to the exam result (pass/fail).
| Method | Fail | Pass | Total |
|---|---|---|---|
| Active learning | 16 (53.3%) | 14 (46.7%) | 30 |
| Flipped | 14 (46.7%) | 16 (53.3%) | 30 |
| Lecture | 23 (76.7%) | 7 (23.3%) | 30 |
| Total | 53 | 37 | 90 |
Every expected count is 17.67 (fail) or 12.33 (pass), all above 5, so the assumption is met.
Result: χ²(2, N = 90) = 6.15, p = .046, Cramér's V = .26.
How to read it
- p = .046 is below .05: teaching method and exam result are significantly related.
- Use the row percentages to see the direction: 76.7% of the lecture group failed, compared with about 47–53% in the other two groups.
- Cramér's V = .26 is small for this table (df* = 1; benchmarks .10 small, .30 medium, .50 large).
A chi-square test of independence showed a significant association between Method and Result, χ²(2, N = 90) = 6.15, p = .046, Cramér's V = .26, a small association.
ผลการทดสอบไคสแควร์ พบว่า วิธีสอนและผลสอบมีความสัมพันธ์กันอย่างมีนัยสำคัญทางสถิติที่ระดับ .05 (χ²(2, N = 90) = 6.15, p = .046) โดยมีความสัมพันธ์อยู่ในระดับเล็ก (Cramér's V = .26)
Common mistakes
- Entering percentages instead of counts. χ² must be computed from actual counts.
- Counting the same person more than once, for example with multiple-response questions.
- Not checking expected counts, especially with small samples or many categories.
- Interpreting Cramér's V without considering table size. The benchmarks change with df*.
References
- Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451.
- Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum.
- Cramér, H. (1946). Mathematical methods of statistics. Princeton University Press.
Try it
One click opens the “Teaching-method study” sample dataset with this test selected and the variables filled in. Or use your own data.