Blog/The Chi-square Test

Statistics

The Chi-square Test

Are two categorical variables related?

SK

Skari Team

Skari

July 2026·9 min read

Chi-square Test

Compares observed counts across categories against what independence would predict.

Plan APlan BPlan CStayChurn421812203528

Not every relationship is between numbers. Plan tier by gender, churn by region, response by campaign — both sides are categories, so there's no average to compare. The chi-square test of independence is built for exactly this: deciding whether two categorical variables are related or just coincidentally lined up.

Note

The idea is simple: compare the counts you actually observed to the counts you'd expect if the two variables had nothing to do with each other. A big gap is evidence of a relationship.

The Contingency Table

The data goes into a cross-tab: rows for one variable, columns for the other, counts in the cells.

ObservedPlan APlan B
New users12080
Returning users60140

At a glance, new users lean to Plan A and returning users to Plan B. The question is whether that pattern is real or the kind of split you'd see by chance.

Observed vs Expected

The test computes the counts you'd expect in each cell if the two variables were independent — based only on the row and column totals — and compares them to what you observed, as the bars in the figure above contrast.

CellObservedExpected if independent
New · Plan A12090
New · Plan B80110
Returning · Plan A6090
Returning · Plan B140110

The chi-square statistic sums the squared gaps between observed and expected, scaled by expected. Large gaps push the statistic up and the p-value down — evidence the variables move together.

Reading the Result

  • A small p-value means the variables are related — the observed counts differ from independence more than chance would explain
  • The chi-square statistic itself grows with the size of the observed-expected gaps
  • Effect size (Cramér's V) tells you how strong the relationship is, not just whether it exists

Tip

As with any test, significance is not strength. With a large sample, a trivial association can be significant — report an effect size like Cramér's V alongside the p-value.

Assumptions and Limits

  • Independent observations — each person or record counted once
  • Adequate expected counts — a common rule is expected ≥ 5 in most cells
  • Counts, not percentages — chi-square works on raw frequencies
  • It shows association, not direction or cause

Watch out

When expected counts are too small, chi-square becomes unreliable — use Fisher's exact test instead. And remember: a significant result says the variables are linked, not that one causes the other.

Chi-square in the SKARI Statistical Lab

SKARI's Statistical Lab runs the crosstab and chi-square together: pick two categorical variables and it builds the table, computes observed vs expected, and reports the test with an effect size.

  • Crosstab (contingency table) construction from two categorical columns
  • Chi-square statistic, degrees of freedom, and p-value
  • Expected-count check with a Fisher's exact fallback for small cells
  • Cramér's V effect size and a plain-language read of the relationship

Takeaway

You get the table, the test, and the strength of the link in one place — and a warning when expected counts are too small to trust the standard test.

Frequently Asked Questions

What if my cells have tiny counts?

Chi-square gets unreliable below expected counts of about 5. Use Fisher's exact test, which SKARI offers as a fallback.

Does chi-square tell me the direction?

No — it flags that a relationship exists. Read the table cells (or standardized residuals) to see which combinations drive it.

Chi-square or correlation?

Chi-square for two categorical variables; correlation for two numeric ones. They answer the same 'are these related?' question for different data types.

Key Takeaways

For

Categories

not means

Compares

Obs vs Exp

if independent

Small p

Related

beyond chance

Strength

Cramér V

effect size

The chi-square test turns a cross-tab of counts into a clear verdict on whether two categories are linked. Check the expected counts, read significance with an effect size, and remember it shows association, not cause.

Takeaway

Compare what you saw with what independence would predict — a big gap means the two categories genuinely move together.

Hypothesis Testing Basics

The framework behind the test

Correlation ≠ Causation

Related isn't caused

Confidence Intervals

The range behind an estimate