Chi-Square Test of Independence

Verified

Categorical

Independently verified. Every statistic this test reports has been re-derived against an independent reference — never the library the pipeline itself calls — the rendered output was read back in a browser, and the result is locked with a committed regression suite.

Run this test straight away on a free built-in teaching dataset — no data of your own needed — or bring your own. Either opens the guided workspace: variable setup, assumption diagnostics, results with effect sizes and confidence intervals, figures, and APA-ready reporting.

Loading teaching datasets…

Or use your own dataset

Loading your datasets…

Omnibus test of association between two categorical variables in an r × c contingency table.

Compares observed cell counts to those expected under independence (row_i × col_j / N) via χ² = Σ (O − E)² / E with df = (r−1)(c−1). Reports the χ² statistic, p, Cramér's V effect size, and per-cell standardised residuals to localise WHERE the association lives. The engine auto-checks Cochran's expected-count rule (all expected ≥ 1, ≤ 20% < 5) and routes to Fisher's exact / Monte-Carlo p when violated.

Worked example

Is smoking status associated with regular exercise?

300 adults were cross-classified by smoking (yes/no) and regular exercise (yes/no); a chi-square test of independence checks for association.

Result

Smoking and exercise were associated, χ²(1, N = 300) = 22.2, p < .001, φ = .27 — smokers were less likely to exercise regularly.

How you'd report it (APA)

A chi-square test showed a significant association between smoking and regular exercise, χ²(1, N = 300) = 22.2, p < .001, φ = .27.

Try it yourself: Load this ready-made sample and follow the run above.

When to use it

  • Two nominal / categorical variables
    A political poll crosses respondent education level (4 categories) with party preference (5 parties).
  • Test of homogeneity (same distribution across groups)
    Three regional samples (n = 200 each) are surveyed on political preference (5 parties).

When NOT to — use instead

Hypotheses

H₀: the two categorical variables are independent — P(row = i AND col = j) = P(row = i) · P(col = j) for all (i, j).
Hₐ: the two variables are associated.

Parameter tested: joint distribution P(row, col)

Assumptions (and what to do if they fail)

Expected counts are adequate — at least 80% of cells have E ≥ 5 AND no cell has E < 1 (Cochran's rule).medium

Check: Count cells with expected count < 5 and report the minimum expected count.

If violated: Sparse tables inflate the χ² Type I error rate.

The χ² test of independence is insensitive to the ORDERING of category levels. If a meaningful ordering exists, a trend test is more powerful.low

Check: Note whether either variable is ordinal.

If violated: Treating an ordered variable as nominal loses power.

Ready to run a Chi-Square Test of Independence on your own data?

Guided setup, automatic assumption checks, effect sizes, figures and an APA write-up.

Run this test →