Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Statistics formulas

Chi-square statistic

Compare observed categorical counts with counts expected under a null model.

Statistics · Hypothesis tests
$$\chi^2=\sum\frac{(O-E)^2}{E}$$

Chi-square statistic is one of 2 hypothesis tests formulas in the statistics section of this library, and it is used at ap · university level.

Why chi-square statistic works

Each cell contributes a squared gap between what was seen and what the model predicted, divided by the prediction. That division puts the gap in context: missing by 5 is a serious error when only 10 were expected and almost nothing when 1000 were. Adding the contributions gives one number that grows as the table drifts from the model.

What each symbol means

$O$ and $E$ are observed and expected cell counts.

Chi-square statistic: when it holds

Counts must be independent and expected counts sufficiently large for the chi-square approximation.

When it stops applying

It assumes independent counts and expected values large enough for the chi-square curve to approximate the true distribution, usually taken as every expected count at least 5. With expected counts of 1 or 2 the p-value can be far off, and an exact test such as Fisher's is the right tool instead.

Chi-square statistic: a worked example

A cell with $O=12,E=10$ contributes $(12-10)^2/10=0.4$.

The mistake to avoid

What people do: Entering percentages into the table rather than raw counts.

Why it goes wrong: Percentages throw away the sample size, which is the only thing that makes a gap convincing. Sixty against fifty out of 100 contributes 2 to the total, but 600 against 500 out of 1000 contributes 20.

Do this instead: Always build the table from actual frequencies. Convert to percentages afterwards for describing the result, never before computing it.

Chi-square statistic: step by step

  1. Name the unknown, and the unit the answer has to come out in.
  2. Match the symbols to your values. $O$ and $E$ are observed and expected cell counts.
  3. Check the conditions before substituting. Counts must be independent and expected counts sufficiently large for the chi-square approximation.
  4. Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most statistics slips.

Where this formula fits

Subject
Statistics formulas — 21 entries in this library
Topic
Hypothesis tests
Level
AP · University

Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where chi-square statistic comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.

Questions about chi-square statistic

Which number goes in the denominator, observed or expected?

Always expected. It sets the scale that the gap is being judged against, and using the observed count instead changes the answer and breaks the reference distribution.

How do I compute the expected counts for a two-way table?

Multiply the row total by the column total and divide by the grand total. That is what the counts would look like if the two variables carried no information about each other.

How many degrees of freedom should I use?

For a goodness-of-fit test it is the number of categories minus one. For a two-way table it is the rows minus one times the columns minus one.

Can the statistic come out negative?

No. Every term is a square divided by a positive expected count, so the total is zero or more, and zero would mean the observed counts matched the model exactly.

Stuck on a problem?

Work a chi-square statistic problem step by step

Type your own problem, or upload a photo of it. You get the method, the answer, and a check you can repeat yourself.