Data and statistics · cheat sheet

Chi-square test

A test of whether two category variables are linked, by comparing the counts in a table with the counts expected if they weren't.

Common practice
5 steps
Used by Process Improvement Specialist

What it is

The chi-square test checks whether two categorical variables are independent, by comparing observed counts with the counts expected if they were.

When to use it

When both things are categories: band and outcome, region and complaint type, shift and defect type.

Why it works

It tests links between categories in one step.

Do

  • Look at which cells contribute most: they tell the story.

Don't

  • Using percentages instead of counts.
  • Expected counts below 5 in many cells (combine categories).

Step by step

  1. Table of counts
  2. Expected counts Row × column ÷ total.
  3. Cell contributions
  4. Sum and degrees of freedom
  5. p-value
Also called: Chi-square test of independence, contingency table testPrint the blank template ↗

Worked example

The situation. Complaints by region and type (service, product, billing).

  1. Region C has far more product complaints than expected.

The result. Region C's product complaints traced to one warehouse's storage.

Chi-square worksheet Print blank
PartValue
Chi-square19.4
Degrees of freedom4
p-value0.0006

Filled in for: Complaints by region and type (service, product, billing).

CategoryObservedExpected(O − E)² ÷ E

Copy this structure, or print the blank version and fill it in by hand. Sum = chi-square ______ degrees of freedom = (rows − 1) × (columns − 1) ______ p ______

Before you use it: check these

CheckIf it fails
Counts, not percentagesConvert back to counts
Expected counts of 5 or more in most cellsCombine categories, or use an exact test
Each item counted onceCheck for items in more than one cell

How to do it with real data

The full calculation, as it happens in the story: the data, every step, how to read the result, and the spreadsheet functions to do it yourself.

Worked example with real data

Do long waits cause more missed appointments?

From Day 35: The vicious circle of the Process Improvement Specialist story

Astrid (Data Analyst) groups the 1,400 appointments by how many days ahead they were booked.

Share of appointments missed, by days booked ahead, in percent0102030400 to 3: 660 to 34 to 7: 10104 to 78 to 14: 18188 to 14Over 14: 2929Over 14

Step by step

  1. HypothesesH0: missing an appointment doesn't depend on how far ahead it was booked
  2. Expected countsrow total × column total ÷ 1,400; for 0 to 3 days, missed: 300 × 220 ÷ 1,400= 47.1
  3. Each cell(observed − expected)² ÷ expected; for that cell (18 − 47.1)² ÷ 47.1= 18.0
  4. Chi-squareadd all 8 cells= 74.6
  5. Degrees of freedom(4 rows − 1) × (2 columns − 1)= 3
  6. p-value= below 0.0001
Booked how far aheadMissedAttendedShare missed
0 to 3 days182826%
4 to 7 days3834210%
8 to 14 days7634418%
More than 14 days8821229%

How to read the result

The longer patients wait, the more likely they are to miss the appointment: from 6% to 29%. Long waits cause missed appointments, which waste slots, which make waits longer: a vicious circle.

What it led to

Shorter waits will reduce missed appointments by themselves. The benefits estimate (8% missed after the project) is realistic.

Do it in a spreadsheet

Expected count=$E2*B$6/$E$6 (row and column totals in E and row 6)
p-value=CHISQ.TEST(B2:C5,G2:H5) (observed, expected)
Try it yourself: What is the expected number of missed appointments booked more than 14 days ahead, if waiting made no difference?

300 × 220 ÷ 1,400 = 47.1. The clinic saw 88, nearly twice as many.

In the roles

How a Process Improvement Specialist uses it

Missed appointments by days booked ahead: chi-square 74.6, p below 0.0001; from 6% to 29%.

Questions people ask

Can I use percentages?

No: always use counts.

Related techniques

← All techniques and tools