Skip to content

Chi-square test

A chi-square test checks whether two categories are related, like plan type and churn, by comparing the counts you got with the counts you'd expect if they weren't.

Select any words here to ask your Maestro about them.

With 100 customers, a chi-square test of plan vs. leaving gives p = 0.086. You collect data on 400 customers with exactly the same percentages. What happens to the p-value?

Customers of a subscription app, by plan. Example data.

What it's for: finding out whether two categories are related: plan and churn, campaign and purchase, store and payment method. It works on a cross-tabulated frequency table, like the one a pivot table gives you.

How to read it: it compares each count with the count you'd expect if there were no relationship. When the gap is bigger than chance usually produces, the p-value comes out small.

Where it breaks: when expected cells fall below 5, or when the same customer is counted in two cells. And even a significant result shows a relationship, not a cause: see correlation vs. causation.

How it's used

One in Excel

Chi-square in Excel

  1. Put the counts in B2:C3: plans in rows; left and stayed in columns
  2. Expected for each cell, in F2:G3: its row total × its column total ÷ the grand totalIt's what you'd see if the plan had nothing to do with leaving.
  3. marked: =CHISQ.TEST(B2:C3, F2:G3)What happened first, then what you expected. It returns the p-value.
  4. Check that every expected cell is at least 5
The test compares what happened with what chance alone would give; the further apart they are, the smaller the p-value.

When to look closer

Excel or Python?

One table, two tools

  1. marked: Excel, =CHISQ.TEST: p = 0.086

You run the 100-customer table in Excel and in Python (scipy), each with its default settings. Do they give the same p-value?

Ask your Maestro about Chi-square test

It answers from the free course page closest to this word, the way it answers while you study.

Example

You: What does "Chi-square test" mean, in plain words?

Your Maestro: I'll explain it with a case of yours: it sticks better than a definition. Which two things at work would you like to test for a relationship?

Asking about: Answers from the page "How do you know it's right?"

Only this browser keeps what you ask here. How it works

Learn more

  • P-value

    A p-value is the probability of seeing a result at least as extreme as yours if there were truly no effect. The smaller it is, the more surprising your result would be without one.

  • Frequency table

    A frequency table counts how often each value shows up (absolute frequency). Relative frequency is that count over the total: 5 of 10 = 50%.

  • Pivot table

    A pivot table summarizes a long table in seconds: it groups by the columns you pick and sums, counts or averages another, with no formulas.

  • Correlation vs. causation

    Correlation means two numbers move together; causation means changing one changes the other. Moving together doesn't prove that one causes the other.

The whole glossary