Chi-Square Independence
When we collect data on two categorical variables at the same time — for example, a person's preferred social media platform and their age group — we naturally want to know: are these two things related, or are they independent? The Chi-Square Test of Independence is a formal statistical procedure that answers exactly this question. It uses observed counts from a two-way table (also called a contingency table) to decide whether an association between the two categorical variables is real or simply due to random chance. The core idea is to compare what we actually observed in our sample with what we would expect to see if the two variables had absolutely no relationship. If the observed counts are close to the expected counts, the variables are probably independent. If they differ dramatically, we have evidence of an association. The Chi-Square statistic measures the total size of those differences across every cell of the table, turning it into a single number we can look up in a distribution. This test appears everywhere in real-world research: epidemiologists check whether a risk factor is associated with a disease, marketers test whether product preference depends on gender, and educators study whether a teaching method relates to student performance. Mastering Chi-Square Independence gives you a powerful tool for drawing conclusions from categorical data collected across two dimensions simultaneously.
- State the Hypotheses
- Organize Data into a Contingency Table
- Calculate Expected Counts
- Compute the Chi-Square Test Statistic
- Find the P-value and Draw a Conclusion
State the Hypotheses
The null hypothesis H₀ states that the two categorical variables are independent — knowing the value of one tells you nothing about the other. The alternative hypothesis Hₐ states that the two variables are associated (not independent). For example: H₀: Preferred platform and age group are independent. Hₐ: Preferred platform and age group are associated.
Organize Data into a Contingency Table
Arrange the data in an r × c table, where r = number of rows (categories of variable 1) and c = number of columns (categories of variable 2). Each cell contains the observed count O for that combination. Record the row totals, column totals, and the grand total n.
Calculate Expected Counts
If H₀ were true and the variables were truly independent, the expected count for the cell in row i, column j is: E_{ij} = (Row i total × Column j total) / n. Every expected count must be at least 5 for the test to be valid. If some are smaller, you may need to combine categories.
Compute the Chi-Square Test Statistic
For every cell, compute (O − E)² / E, then add them all up. A large χ² value means observed counts deviate substantially from expected counts, giving evidence against H₀. The degrees of freedom for the test are df = (r − 1)(c − 1), where r and c are the number of rows and columns.
Find the P-value and Draw a Conclusion
Use a Chi-Square distribution table or technology with df = (r−1)(c−1) to find the p-value, which is always the area in the RIGHT tail (χ² tests are always right-tailed). If p-value ≤ α (commonly 0.05), reject H₀ and conclude there is evidence of an association between the two variables. If p-value > α, fail to reject H₀.
The Key Equation
- \chi^2 — Chi-Square statistic (dimensionless): The test statistic summarizing how far observed counts deviate from expected counts across all cells; larger values indicate stronger evidence against independence.
- O_{ij} — Observed count (count): The actual number of data values that fall in row i and column j of the contingency table.
- E_{ij} — Expected count (count): The number of data values we would expect in row i, column j if the two variables were truly independent.
- n — Grand total (count): The total number of observations across the entire table.
Worked Example
Problem. A researcher surveys 200 randomly selected high school students, recording their grade level (10th or 11th) and whether they prefer reading fiction or non-fiction. The contingency table is: Fiction: 10th = 55, 11th = 45, Total = 100. Non-fiction: 10th = 25, 11th = 75, Total = 100. Column totals: 10th = 80, 11th = 120, Grand total = 200. At α = 0.05, test whether grade level and reading preference are independent.
Answer. Reject H₀. Grade level and reading preference are associated (χ² = 18.75, df = 1, p ≈ 0.000015).
Origins · 1 minKarl Pearson and how this was discovered
Karl Pearson introduced the Chi-Square test in his landmark 1900 paper 'On the Criterion that a given System of Deviations from the Probable in the Case of a Correlated System of Variables is such that it can be Reasonably Supposed to have Arisen from Random Sampling.' He formally derived the Chi-Square distribution and showed how it could be used to test whether observed frequency data fit an expected distribution — a framework that was then extended to tests of independence in contingency tables. Pearson founded the world's first university statistics department at University College London in 1911, and he also coined the term 'standard deviation,' a word used by millions of students every day.
Related Concepts
- Chi-Square Goodness-of-Fit Test — Both tests use the same χ² statistic and distribution, but the Goodness-of-Fit test checks whether one categorical variable matches a claimed distribution, while Independence checks the relationship between two categorical variables.
- Two-Way Tables and Marginal Distributions — The Chi-Square Independence test is built on data organized in a two-way (contingency) table; understanding row, column, and marginal distributions is essential preparation for the test.
- Introduction to Hypothesis Testing — Chi-Square Independence follows the same four-step hypothesis testing framework (hypotheses, conditions, test statistic, p-value and conclusion) used throughout statistical inference.
- P-Values and Significance Levels — Interpreting the result of a Chi-Square Independence test requires a clear understanding of what a p-value means and how to compare it against a chosen significance level α.