Most of the statistics taught in the early parts of a research methods course, like the t-test or ANOVA, need numerical data that behaves in a predictable way. But a huge amount of the data researchers actually collect isn’t numerical at all. It’s categorical: yes or no, urban or rural, hypertensive or non-hypertensive. The chi-square test is the tool built specifically for this kind of data, and once you understand how it works, you’ll start noticing it in public health reports, market research, and social science papers everywhere.
Table of Contents
- What makes a test “non-parametric”?
- The chi-square statistic, explained simply
- Breaking down the chi-square formula
- A worked example: blood pressure across urban and rural India
- Setting up the table
- Calculating the expected frequencies
- Plugging in the numbers
- Degrees of freedom and the critical value
- Interpreting the result
- Assumptions and when not to use chi-square
- Why this test matters beyond the textbook
What makes a test “non-parametric”?
Parametric tests, like the t-test, assume your data follows a certain distribution (usually a normal curve) and that you’re working with continuous numbers like height, income, or test scores. The chi-square test doesn’t need any of that. It’s classified as a nonparametric hypothesis test because it works directly with frequencies and counts rather than means and standard deviations, and it makes no assumption about how the underlying population is distributed.
This is exactly why chi-square is so useful for categorical variables. You can’t calculate an “average” religion, gender, or diagnosis. What you can do is count how many people fall into each category and compare that count to what you’d expect if there were no real pattern at all.
The chi-square statistic, explained simply
At its core, the chi-square (denoted χ²) statistic measures how far your observed data strays from what you’d expect purely by chance. If two categorical variables are genuinely unrelated, the numbers in each category should roughly match a predictable, proportional pattern. When the actual counts deviate sharply from that pattern, chi-square captures the size of that deviation as a single number.
A small χ² value means your observed data is close to what chance alone would produce, so there’s probably no real relationship. A large χ² value means the gap is too big to be a coincidence, suggesting a genuine association between the variables.
Breaking down the chi-square formula
The formula looks intimidating at first, but each piece has a simple job:
χ² = Σ [ (O − E)² / E ]
Here’s what each symbol means:
O is the observed frequency, the actual count you recorded in each category.
E is the expected frequency, the count you’d predict if the two variables had no relationship at all.
Σ (sigma) tells you to add up this calculation across every single category or cell in your table.
You square the difference between observed and expected so that negative and positive deviations don’t cancel each other out, then divide by the expected value to keep large categories from unfairly dominating the total. Add up this ratio across every cell, and you get your chi-square statistic.
A worked example: blood pressure across urban and rural India
Chi-square is used constantly in Indian public health research. Large-scale surveys like the ICMR-INDIAB study have documented meaningful differences in hypertension rates between urban and rural populations across Indian states, which makes this a natural real-world example of the test in action.
Imagine a researcher surveys 200 adults, 100 from urban areas and 100 from rural areas, and records whether each person is hypertensive or non-hypertensive. The results form a classic 2×2 contingency table:
Setting up the table
Urban, hypertensive: 40. Urban, non-hypertensive: 60.
Rural, hypertensive: 25. Rural, non-hypertensive: 75.
Column totals: 65 hypertensive, 135 non-hypertensive, out of 200 total subjects.
Calculating the expected frequencies
Before you can compute chi-square, you need to know what each cell would look like if location and blood pressure status were completely unrelated. The formula for this is:
E = (Row total × Column total) / Grand total
For urban, hypertensive: (100 × 65) / 200 = 32.5. Because the row and column totals are symmetric here, all four expected values in this example work out to either 32.5 or 67.5.
Plugging in the numbers
Applying the formula to each of the four cells:
Urban, hypertensive: (40 − 32.5)² / 32.5 = 1.73
Urban, non-hypertensive: (60 − 67.5)² / 67.5 = 0.83
Rural, hypertensive: (25 − 32.5)² / 32.5 = 1.73
Rural, non-hypertensive: (75 − 67.5)² / 67.5 = 0.83
Adding these four values gives a chi-square statistic of 5.12.
Degrees of freedom and the critical value
A chi-square value on its own doesn’t tell you anything until you compare it against a benchmark, and that benchmark depends on your degrees of freedom (df). For any contingency table, this is calculated as:
df = (number of rows − 1) × (number of columns − 1)
For a 2×2 table, this always comes out to (2−1) × (2−1) = 1, regardless of how large your sample is. Once you know the degrees of freedom, you look up the corresponding critical value in a chi-square distribution table at your chosen significance level, typically 0.05. At df = 1, that critical value is 3.84.
Interpreting the result
The decision rule is straightforward: if your calculated χ² value exceeds the critical value, you reject the null hypothesis (which states there is no association between the two variables). If it doesn’t, you fail to reject it.
In the blood pressure example, the calculated value of 5.12 is higher than the critical value of 3.84. This means the researcher would reject the null hypothesis and conclude there is a statistically significant association between where someone lives and whether they are hypertensive. This lines up with what large Indian public health surveys have consistently found, that hypertension prevalence differs meaningfully between urban and rural populations, even though the exact numbers vary by region and study.
It’s worth being careful here: a significant chi-square result tells you two variables are associated, not that one causes the other. Living in a city doesn’t directly cause high blood pressure; the association is likely explained by a mix of factors like diet, physical activity, stress, and access to healthcare that differ between urban and rural settings.
Assumptions and when not to use chi-square
Chi-square isn’t a universal tool for every dataset. A few conditions need to hold for the test to give reliable results:
Independence of observations: Each subject should be counted in only one cell, and one person’s response shouldn’t influence another’s.
Adequate sample size: Expected frequencies in each cell should generally be 5 or higher. When samples are small or cell counts are sparse, researchers often switch to Fisher’s exact test instead, since it’s built for smaller samples where the chi-square approximation becomes unreliable.
Categorical data only: The variables involved need to be nominal or ordinal, not continuous.
Ignoring these assumptions doesn’t just weaken your findings, it can produce a completely misleading p-value.
Why this test matters beyond the textbook
Once you start looking for it, chi-square shows up everywhere: testing whether a new teaching method changes pass rates across different student groups, checking whether smoking status is linked to a health outcome, or seeing if voting preference is independent of income bracket. The reason it’s one of the most widely used tests in fields like public health and social science is precisely because so much of the real world is measured in categories rather than clean numerical scales.
Learning to read a chi-square result also makes you a more critical consumer of research. When a news article or a report claims that two factors are “linked,” there’s a good chance a chi-square test (or something built on similar logic) is sitting behind that claim.
What do you think? If you were designing a survey on your own campus, what two categorical variables would you want to test for an association, and why do you think they might (or might not) be related?
References
- https://www.scribbr.com/statistics/chi-square-tests/
- https://www.nature.com/articles/jhh201457
- https://libguides.library.kent.edu/spss/chisquare
- https://pmc.ncbi.nlm.nih.gov/articles/PMC13289999/
- https://www.graphpad.com/quickcalcs/contingency1/
- https://journals.lww.com/ijcf/fulltext/2024/10020/chi_square_test__a_parametric_or_nonparametric.1.aspx
Leave a Reply