Statistical Methods Atlas
Atlas › Test Association › Chi-Square Test of Independence

Chi-Square Test of Independence

Tests whether two categorical variables are related — e.g., is employment type (permanent/contract) associated with turnover (stayed/left)?

Test AssociationBivariate also known as: Pearson chi-square, χ² test, Crosstab test

✓ When to use

  • Two nominal (or ordinal-treated-as-nominal) variables summarized in a contingency table.
  • Independence questions: does department relate to gender composition? Does plan type relate to churn?
  • Adequate expected counts (≥ 5 in at least 80% of cells, none below 1).

✗ When NOT to use

  • Small samples/sparse tables (2×2 with low expected counts) — use Fisher's Exact Test.
  • Paired/repeated categorical measurements (same people before-after) — use McNemar's test.
  • Ordered categories where trend matters — consider the linear-by-linear association test or ordinal methods.
  • You need adjusted estimates with covariates — logistic regression.

Data requirements

Dependent / outcome variableOne categorical variable (r categories).
Independent / grouping variableAnother categorical variable (c categories) — the test is symmetric.
DesignIndependent observations; each case in exactly one cell.
Sample size guidanceTotal n such that expected counts stay ≥ 5; as a rule of thumb n ≥ 5×(r×c).

Assumptions

Hypotheses

H₀ — The two variables are independent — the distribution of one is the same at every level of the other.
H₁ — The variables are associated — cell probabilities differ from the independence pattern.

The concept

Under independence, each cell's expected count is (row total × column total)/n. The χ² statistic sums (observed − expected)²/expected across cells: it grows as the table strays from the independence pattern, and is referred to a chi-square distribution with (r − 1)(c − 1) df.

Significance says nothing about strength: report Cramér's V (or φ for 2×2) as effect size (V ≈ .10 small, .30 medium, .50 large for df* = 1). In tables larger than 2×2, standardized (adjusted) residuals > |2| identify which specific cells drive the association.

Worked example

A 2×2 table of employment type (permanent n = 180, contract n = 120) by one-year turnover (stayed/left). Contract: 38 of 120 left (31.7%); permanent: 27 of 180 left (15.0%).

Result: χ²(1, N = 300) = 11.62, p = .001, φ = .20 — contract staff are twice as likely to leave.

How to run it

tab <- table(df$emp_type, df$turnover)
tab
chisq.test(tab)                      # with Yates correction for 2x2
chisq.test(tab)$expected             # check expected counts
chisq.test(tab)$stdres               # standardized residuals

library(effectsize); cramers_v(tab)

Interpreting the output

APA-style reporting

A chi-square test of independence showed a significant association between employment type and turnover, χ²(1, N = 300) = 11.62, p = .001, φ = .20; contract employees (31.7%) were more likely to leave than permanent employees (15.0%).

Common mistakes

Related methods

Fisher's Exact TestSmall expected countsChi-Square Goodness-of-Fit TestOne variable vs expected proportionsBinary Logistic RegressionAdd covariates / model the oddsCohen's KappaAgreement, not association
← Point-Biserial CorrelationFisher's Exact Test →