Statistics and research

Chi-square test of independence calculator

Chi-square test for a contingency table of counts: expected counts, adjusted residuals, likelihood-ratio G², Cramér’s V and Yates’s correction for 2×2.

Runs in your browser. What you enter stays on this page and is not uploaded.

One row per line; separate the columns with spaces, tabs or commas. Paste straight from a spreadsheet.

Results

χ²30.0701df2p-value2.954e-7Cramér’s V0.1044
Pearson chi-square
30.070149
Degrees of freedom (r − 1)(c − 1)
2
p-value
2.954e-7
Likelihood-ratio G²
30.016693 (p 3.034e-7)
Cramér’s V
0.104436
Total count n
2,757
Conclusion
Row and column variables are associated (significant at the 5% level).
Observed counts
Column 1Column 2Column 3
Row 1762327468
Row 2484239477
Expected counts under independence
Column 1Column 2Column 3
Row 1703.67319.65533.68
Row 2542.33246.35411.32
Adjusted standardized residuals (beyond ±1.96 stands out at 5%)
Column 1Column 2Column 3
Row 14.5020.6995-5.316
Row 2-4.502-0.69955.316

Expected count = row total × column total / n. Cramér’s V = √(χ² / (n (min(r, c) − 1))) uses the uncorrected χ².

Method and limits

How to use it

Paste a table of counts — one row per line, columns separated by spaces, tabs or commas. Each cell is the number of cases with that combination of row and column categories. Yates’s correction applies only to 2×2 tables (as R’s default).

Formulas

  • Expected count Eij = (row i total × column j total) / n.
  • Pearson χ² = Σ (O − E)² / E with (r − 1)(c − 1) degrees of freedom; p is the right tail of the chi-square distribution.
  • Yates (2×2): Σ (|O − E| − min(0.5, |O − E|))² / E.
  • Likelihood ratio G² = 2 Σ O ln(O / E).
  • Cramér’s V = √(χ² / (n (min(r, c) − 1))); for 2×2 the signed phi coefficient is also shown.
  • Adjusted standardized residual = (O − E) / √(E (1 − row share)(1 − column share)); values beyond ±1.96 point to the cells driving the association.

Assumptions and limits

  • Counts of independent cases; each case in exactly one cell. Not for percentages, means or repeated measurements of the same people (use McNemar’s test for paired 2×2 data).
  • Expected counts: at least 80% of cells 5 or more and none below 1 (Cochran 1954). Otherwise combine categories, or use Fisher’s exact test for 2×2 tables.
  • A significant result shows association, not causation, and with large n even trivial associations are significant — report Cramér’s V.

Worked example

R’s chisq.test example (Agresti 2007: gender by party identification, 2,757 people): χ² = 30.07 with 2 df, p = 2.954e-7, Cramér’s V = 0.104. Adjusted residuals of ±4.5 and ±5.3 show the association lies in the first and third columns.

References

Related tools

Share this page

Remind me to visit Contifield

Adds a repeating reminder to your calendar, titled “Contifield Reminder: Visit www.contifield.com”.