Analyze · Categorical

Chi-Square Test of Independence

Tests whether two categorical variables are associated by comparing the observed cell counts of a contingency table with the counts expected if the variables were independent.

In the menus Analyze › Categorical › Chi-Square Test of Independence

Also searched as chi square chisquare chi squared chi-squared test chi square test chi square test of association test of association association between categorical variables

When to use it

You have two categorical (nominal/ordinal) variables and want to know whether they are associated.

When not to: You want to test marginal change in paired binary outcomes (use McNemar's test), repeated or clustered responses have been stacked as independent sampling units, expected counts are too low in a 2x2 table (consider Fisher's exact test), or a larger table is too sparse for the chi-square approximation (consider a suitable exact or Monte Carlo procedure). A joint before/after table with one independent subject per cell contribution can still be analyzed for association; that is a different question from change.

Step by step

  1. Open it from the menu

    Click Analyze in the menu bar; under Categorical choose Chi-Square Test of Independence.

  2. Fill in the form

    Choose the columns: Rows of the table, Columns of the table. The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: How strict to be, Small-table correction (Yates). Change one only when your question needs it.

  4. Run the analysis

    Press Run analysis. The Result Card opens on its Results tab.

What to choose in the form

Fields of the Chi-Square Test of Independence form
Rows of the table Row Var requiredOne categorical or ordered categorical column. A category column. Its groups become the rows of the table.
Columns of the table Col Var requiredOne categorical or ordered categorical column. Another category column. The test asks whether the mix of one differs across the other.
How strict to be AlphaThe cut-off for the p-value. Below it, the card reports evidence that the two columns are related. Not sure? Keep 0.05. It is the usual convention in most fields.
Small-table correction (Yates) Yates' continuity correctionUsed only for a 2×2 table: makes the p-value slightly more careful when counts are small. Not sure? Keep it on. It is the usual default; larger tables ignore it.

How to read the card

The Results tab starts with what to know first (rows left out, checks that did not pass), then the interpretation in words and the Key Results; charts and assumption checks follow further down. Learn More explains the method in plain words. Read a Result Card covers all four tabs.

What it assumes

Adequate expected counts (chi-square)

If it does not hold: When too many cells have an expected count below 5, the chi-square distribution is a poor approximation to the test statistic's true sampling distribution, making the p-value unreliable.

How to check: Checked directly: the card computes the minimum expected cell count and the share of cells below 5, flagging it as a warning and recommending an exact test (Fisher's) or combining sparse categories.

Independence of observations

If it does not hold: The subject-level sampling units must be independent for the ordinary Pearson reference distribution. Each unit contributes once to a joint cell. The two variables within that unit may be associated: their independence is the null hypothesis being tested, not an assumption required for running the test. Stacking repeated responses or correlated clusters as if they were independent units requires a different analysis.

How to check: Not checked by KernelStats: assumed by design; stated directly as a standing reminder.

A worked example

Testing whether penguin species is associated with the island it was observed on, across all 344 penguins in a 3x3 contingency table.

Result: chi2(4) = 299.6, p < .001, Cramer's V = 0.66, labeled 'large' using the df*=2-adjusted thresholds.

Species and island are very strongly associated: certain species are found overwhelmingly on specific islands rather than being evenly distributed, and the large, table-size-adjusted Cramer's V confirms this is a substantial, not merely statistically detectable, association.

From the Statistics Library.

The code tabs

Code gives this analysis as Python, R and MATLAB code (and SAS where the tab offers it), reading the data the way KernelStats did. Export sends the card to a report or to slides. See The Code tab.

Understand the statistics

Ask Oobi

Type one of these into Ask Oobi beside your data:

  • Is penguin species associated with the island it lives on?
  • Explain the chi-square test of independence in plain words.
  • What does chi-square distribution mean?

Last reviewed November 16, 2026.

Report an unclear step