📊 FormStat
FormStat Guides · By Abdul Hannan

Chi-Square Test Explained With a Simple Example for Medical Students

The chi-square test is one of the most commonly used tests in medical research — and one of the most misunderstood. If you have survey data with categories like male/female, yes/no, or smoker/non-smoker, and you want to know whether two such variables are related, this is your test. Let us build it up with a simple example you can follow without a laptop.

When Do You Use the Chi-Square Test?

Use the chi-square test of independence when both your variables are categorical (counted in categories, not measured in numbers) and you want to know if they are associated with each other. Typical medical examples:

If either variable is numeric — like age, weight, or blood sugar — chi-square is the wrong test. (We will come back to this in the mistakes section.)

The Example: Smoking and Cough

Suppose you survey 20 people and record two things: whether they smoke, and whether they have a chronic cough. Your data looks like this 2×2 table:

Cough: YesCough: NoTotal
Smoker8210
Non-smoker2810
Total101020

Just by looking, smokers seem to cough more (8 out of 10) than non-smokers (2 out of 10). But is this a real pattern, or could it just be luck in a small sample? The chi-square test answers exactly that.

How the Test Works (4 Steps)

Step 1: Write down what you observed

That is the table above — your observed counts: 8, 2, 2, 8.

Step 2: Calculate what you would expect if there were NO relationship

If smoking had nothing to do with cough, the cough cases would be spread evenly. The expected count for each cell is (row total × column total) ÷ grand total. Here every cell's expected count is (10 × 10) ÷ 20 = 5.

Step 3: Measure how far observed is from expected

The chi-square statistic adds up (observed − expected)² ÷ expected for every cell:

χ² = (8−5)²/5 + (2−5)²/5 + (2−5)²/5 + (8−5)²/5 = 1.8 + 1.8 + 1.8 + 1.8 = 7.2

Bigger differences between observed and expected give a bigger χ².

Step 4: Convert to a p-value

With 1 degree of freedom, χ² = 7.2 corresponds to p ≈ 0.0073.

What Does p = 0.0073 Actually Mean?

In plain words: if smoking and cough were truly unrelated, there is only a 0.73% chance of seeing a difference this big (or bigger) just by luck. That is so unlikely that we conclude the relationship is real.

The standard cutoff is 0.05 (5%). Because 0.0073 < 0.05, we say the result is "statistically significant" — there is a significant association between smoking and cough in this data. (For a deeper explanation of what p-values really mean, see our dedicated article.)

Fisher's Exact Test: For Small Samples

The chi-square test is an approximation, and it becomes unreliable when any expected count is less than 5 — which happens a lot in small student datasets. In that case, use Fisher's exact test instead. It calculates the exact probability rather than approximating it.

For our example table, Fisher's exact test gives p ≈ 0.023 — still below 0.05, so the conclusion is the same: smoking and cough are significantly associated. Rule of thumb: if any expected count is below 5, report Fisher's exact test; otherwise chi-square is fine. Good software shows you both.

A case where Fisher's exact test is required

Now imagine the same 80%-vs-20% pattern, but with only 10 people:

Cough: YesCough: NoTotal
Smoker415
Non-smoker145
Total5510

Every expected count here is (5 × 5) ÷ 10 = 2.5 — below 5 — so the chi-square approximation is unreliable and Fisher's exact test is required. It gives p ≈ 0.21, which is not significant. Same pattern, but with only 10 people we cannot rule out luck. This is exactly why the "expected count ≥ 5" rule exists, and why small studies need cautious interpretation.

What to write in your methodology section

One honest sentence is enough, for example: "The association between smoking status and chronic cough was assessed with the chi-square test of independence (Fisher's exact test where expected counts were below 5), with statistical significance set at p < 0.05." Examiners love this line — it shows you chose the test deliberately.

Common Mistakes to Avoid

  1. Using chi-square on numeric data. Comparing mean blood sugar between two groups? That needs a t-test, not chi-square. Chi-square is only for categories vs. categories.
  2. Ignoring small expected counts. If any expected count is below 5, the chi-square p-value cannot be trusted — switch to Fisher's exact test.
  3. Thinking "significant" means "big" or "important." A tiny, medically meaningless difference can be statistically significant in a huge sample. Always look at the actual percentages too.
  4. Testing everything and reporting only the significant ones. Running 20 tests and celebrating the one with p < 0.05 is misleading — with enough tests, something will look significant by pure chance.
  5. Forgetting that association is not causation. Chi-square tells you two variables are related — it does not tell you one causes the other.

Run It Free on Your Phone

You do not need SPSS or a laptop for any of this. Run the chi-square test free in FormStat — paste your data, tap your two categorical questions, and get the crosstab, chi-square statistic, p-value, and Fisher's exact test instantly, with a plain-English interpretation.

Try it yourself — free.
Run this analysis in seconds with the FormStat app. No signup, no laptop, works offline.

← All guides