Chi-Square CalculatorChi-Square Calculator
Guide

Which Chi-Square Test Should You Use?

All three chi-square tests use the same formula. Which one you are doing depends on how many variables you have and how the data were collected.

Checked on November 21, 2026. Results computed by our statistics engine, version 1.0.0.

In short

  • One variable: goodness of fit
  • One sample, two variables: independence
  • Several samples, one variable: homogeneity
On this page

The decision in three questions

Your dataTestNull hypothesis
One categorical variable and a target distributionGoodness of fitThe proportions equal the stated ones
One sample, two categorical variablesIndependenceThe two variables are unrelated
Separate samples from two or more groups, one categorical variableHomogeneityEvery group has the same distribution
The same subjects measured twice, yes or noMcNemarNo change between measurements

If your outcome is a measurement such as height or a test score rather than a category, chi-square is not the right tool; a test for means, such as a t-test or analysis of variance, is.

Goodness of fit: one variable

A goodness-of-fit test compares one row of counts with a distribution fixed in advance. R's simplest example has 3 categories with counts 20, 15, 25, tested against equal shares: χ² = 2.50, df 2, p = 0.2865. No evidence against equal shares. Use the goodness of fit calculator.

Independence: one sample, two variables

A test of independence starts with a single sample and classifies each member two ways. In the survey on the home page, 2,757 people were each classified by gender and by party. The question is whether the two variables are related, and the conclusion is worded that way: χ² = 30.07, df 2, p = 2.954 × 10−7, so there is evidence of an association between gender and party identification.

Homogeneity: several samples, one variable

A test of homogeneity starts with separate samples, one per group, often of sizes the researcher chose, and records one variable. Suppose two groups of 40 and 60 were sampled separately and each person chose one of three options (the small table used on the hand calculation page). The question is whether the groups share one distribution of choices.

The arithmetic is identical to independence: χ² = 2.778, df 2, p = 0.2494. Only the conclusion changes: "no evidence that the distribution of choices differs between the groups". Many textbooks treat the two as one test for this reason.

When chi-square is the wrong test

  • Paired or repeated data. The same people measured twice violate independence. For a yes or no outcome measured twice, use the McNemar test.
  • Percentages, means or rates. Chi-square needs counts. Convert back to counts first.
  • Ordered categories with a trend in mind. A plain chi-square ignores order. A trend test (such as Cochran-Armitage) is more powerful for that question.
  • Very small expected counts. Use an exact test; see the expected counts guide.
  • One observation in several cells. If people can tick more than one box, the cells are not mutually exclusive and the test does not apply.

Writing the hypotheses

For independence: "H0: gender and party identification are independent. H1: they are associated." For homogeneity: "H0: the distribution of choices is the same in both groups." For goodness of fit: "H0: the population proportions are equal." State the hypotheses in words about your variables, then report the test. The APA guide shows how.