Steply

Chi-square

Test of independence · University Statistics · 22 problems, easy to harder

▶ Watch the first one solved

How we do it

  1. Write the hypotheses
  2. Totals
  3. Expected counts
  4. Each part
  5. Add them
  6. The cut-off
  7. Decide
  8. Say it in words
  9. Check

The steps for Chi-square independence: boys 20 yes 30 no, girls 30 yes 20 no…. Every solution names its steps, so you always know what comes next.

Worked examples

Chi-square independence: boys 20 yes 30 no, girls 30 yes 20 no… Easy

The question

Question: boys: 20 yes, 30 no; girls: 30 yes, 20 no: at the 5% level, is the answer linked to the group?

boys: 20 yes, 30 no; girls: 30 yes, 20 no; α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the group and the answer are independent.

H0 : the group and the answer are independent

Hₐ is what we want to show.

Here: the group and the answer are not independent.

Ha : the group and the answer are not independent

Independent means no link: the answer does not depend on the group.

independent: no link, the answer does not depend on the group

2 Totals

The counts in a table.

Each row's total: boys, 50; girls, 50.

Each column's total: yes, 50; no, 50.

And everyone: 100.

3 Expected counts

If there is no link, each cell expects its row total times its column total, over the grand total.

E = row total × column totaltotal

Boys, yes: 50 times 50, over 100, is 25.

= boys, yes: 50 × 50 ÷ 100 = 25

Boys, no: 50 times 50, over 100, is 25.

= boys, no: 50 × 50 ÷ 100 = 25

Girls, yes: 50 times 50, over 100, is 25.

= girls, yes: 50 × 50 ÷ 100 = 25

Girls, no: 50 times 50, over 100, is 25.

= girls, no: 50 × 50 ÷ 100 = 25

4 Each part

Chi-square adds up, for each cell, the observed minus the expected, squared, over the expected.

χ2 = add up all (O − E)2E

A table: each cell, what we saw, O, and what we expected, E.

20 minus 25 is −5.

Squared, 25.

Over 25: 1.

30 minus 25 is 5.

Squared, 25.

Over 25: 1.

30 minus 25 is 5.

Squared, 25.

Over 25: 1.

20 minus 25 is −5.

Squared, 25.

Over 25: 1.

5 Add them

1 plus 1 plus 1 plus 1 is 4.

χ2 = 1 + 1 + 1 + 1 = 4

6 The cut-off

df is rows minus 1, times columns minus 1: 1 times 1 is 1.

df = (rows − 1)(columns − 1) = (2 − 1)(2 − 1) = 1

Careful!

Not the number of cells minus 1.

Rows minus 1, times columns minus 1: 1.

Careful: not df = 3 ✗

Chi-square is always a right-tail test: big means far from what we expected.

Row 1, column 0.05.

Row 1, column .05: the cut-off is 3.841.

7 Decide

The chi-square curve for df 1.

Past the cut-off, 3.841, is the reject part.

4 is past the cut-off.

So we reject H zero.

= χ2 = 4 > 3.841 → reject H0

8 Say it in words

At the 5% level, there is enough evidence that

In words: at the 5% level, there is enough evidence that the group and the answer are not independent.

the group and the answer are not independent.

9 Check

Let's check: the expected counts give the same row totals.

Boys: 25 plus 25 is 50.

boys: E 25 + 25 = 50 = 50

Girls: 25 plus 25 is 50.

So it is right!

girls: E 25 + 25 = 50 = 50

Let's look back.

First: write the hypotheses.

Then: totals.

Then: expected counts.

Then: each part.

Then: add them.

Then: the cut-off.

Then: decide.

Then: say it in words.

Last: check.

Answer
= χ2 = 4 > 3.841 → reject H0

▶ Watch it solved

Chi-square independence: boys 22 sport 18 music 20 art, girls 18… Medium

The question

Question: boys: 22 sport, 18 music, 20 art; girls: 18 sport, 22 music, 20 art: at the 5% level, is the answer linked to the group?

boys: 22 sport, 18 music, 20 art; girls: 18 sport, 22 music, 20 art; α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the group and the answer are independent.

H0 : the group and the answer are independent

Hₐ is what we want to show.

Here: the group and the answer are not independent.

Ha : the group and the answer are not independent

Independent means no link: the answer does not depend on the group.

independent: no link, the answer does not depend on the group

2 Totals

The counts in a table.

Each row's total: boys, 60; girls, 60.

Each column's total: sport, 40; music, 40; art, 40.

And everyone: 120.

3 Expected counts

If there is no link, each cell expects its row total times its column total, over the grand total.

E = row total × column totaltotal

Boys, sport: 60 times 40, over 120, is 20.

= boys, sport: 60 × 40 ÷ 120 = 20

Boys, music: 60 times 40, over 120, is 20.

= boys, music: 60 × 40 ÷ 120 = 20

Boys, art: 60 times 40, over 120, is 20.

= boys, art: 60 × 40 ÷ 120 = 20

Girls, sport: 60 times 40, over 120, is 20.

= girls, sport: 60 × 40 ÷ 120 = 20

Girls, music: 60 times 40, over 120, is 20.

= girls, music: 60 × 40 ÷ 120 = 20

Girls, art: 60 times 40, over 120, is 20.

= girls, art: 60 × 40 ÷ 120 = 20

4 Each part

Chi-square adds up, for each cell, the observed minus the expected, squared, over the expected.

χ2 = add up all (O − E)2E

A table: each cell, what we saw, O, and what we expected, E.

22 minus 20 is 2.

Squared, 4.

Over 20: 0.2.

18 minus 20 is −2.

Squared, 4.

Over 20: 0.2.

20 minus 20 is 0.

Squared, 0.

Over 20: 0.

18 minus 20 is −2.

Squared, 4.

Over 20: 0.2.

22 minus 20 is 2.

Squared, 4.

Over 20: 0.2.

20 minus 20 is 0.

Squared, 0.

Over 20: 0.

5 Add them

0.2 plus 0.2 plus 0 plus 0.2 plus 0.2 plus 0 is 0.8.

χ2 = 0.2 + 0.2 + 0 + 0.2 + 0.2 + 0 = 0.8

6 The cut-off

df is rows minus 1, times columns minus 1: 1 times 2 is 2.

df = (rows − 1)(columns − 1) = (2 − 1)(3 − 1) = 2

Careful!

Not the number of cells minus 1.

Rows minus 1, times columns minus 1: 2.

Careful: not df = 5 ✗

Chi-square is always a right-tail test: big means far from what we expected.

Row 2, column 0.05.

Row 2, column .05: the cut-off is 5.991.

7 Decide

The chi-square curve for df 2.

Past the cut-off, 5.991, is the reject part.

0.8 is not past the cut-off.

So we do not reject H zero.

= χ2 = 0.8 < 5.991 → do not reject H0

8 Say it in words

At the 5% level, there is not enough evidence that

In words: at the 5% level, there is not enough evidence that the group and the answer are not independent.

the group and the answer are not independent.

This does not prove H zero is true.

We just cannot rule it out.

not rejecting H0 does not prove H0

9 Check

Let's check: the expected counts give the same row totals.

Boys: 20 plus 20 plus 20 is 60.

boys: E 20 + 20 + 20 = 60 = 60

Girls: 20 plus 20 plus 20 is 60.

So it is right!

girls: E 20 + 20 + 20 = 60 = 60

Let's look back.

First: write the hypotheses.

Then: totals.

Then: expected counts.

Then: each part.

Then: add them.

Then: the cut-off.

Then: decide.

Then: say it in words.

Last: check.

Answer
= χ2 = 0.8 < 5.991 → do not reject H0

▶ Watch it solved

Chi-square independence: junior 30 bus 20 car 10 walk, senior 20 bus… Harder

The question

Question: junior: 30 bus, 20 car, 10 walk; senior: 20 bus, 35 car, 15 walk: at the 5% level, is the answer linked to the group?

junior: 30 bus, 20 car, 10 walk; senior: 20 bus, 35 car, 15 walk; α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the group and the answer are independent.

H0 : the group and the answer are independent

Hₐ is what we want to show.

Here: the group and the answer are not independent.

Ha : the group and the answer are not independent

Independent means no link: the answer does not depend on the group.

independent: no link, the answer does not depend on the group

2 Totals

The counts in a table.

Each row's total: junior, 60; senior, 70.

Each column's total: bus, 50; car, 55; walk, 25.

And everyone: 130.

3 Expected counts

If there is no link, each cell expects its row total times its column total, over the grand total.

E = row total × column totaltotal

Junior, bus: 60 times 50, over 130, is about 23.0769.

= junior, bus: 60 × 50 ÷ 130 ≈ 23.0769

Junior, car: 60 times 55, over 130, is about 25.3846.

= junior, car: 60 × 55 ÷ 130 ≈ 25.3846

Junior, walk: 60 times 25, over 130, is about 11.5385.

= junior, walk: 60 × 25 ÷ 130 ≈ 11.5385

Senior, bus: 70 times 50, over 130, is about 26.9231.

= senior, bus: 70 × 50 ÷ 130 ≈ 26.9231

Senior, car: 70 times 55, over 130, is about 29.6154.

= senior, car: 70 × 55 ÷ 130 ≈ 29.6154

Senior, walk: 70 times 25, over 130, is about 13.4615.

= senior, walk: 70 × 25 ÷ 130 ≈ 13.4615

4 Each part

Chi-square adds up, for each cell, the observed minus the expected, squared, over the expected.

χ2 = add up all (O − E)2E

A table: each cell, what we saw, O, and what we expected, E.

30 minus 23.0769 is 6.9231.

Squared, 47.9293.

Over 23.0769: 2.0769.

20 minus 25.3846 is −5.3846.

Squared, 28.9939.

Over 25.3846: 1.1422.

10 minus 11.5385 is −1.5385.

Squared, 2.367.

Over 11.5385: 0.2051.

20 minus 26.9231 is −6.9231.

Squared, 47.9293.

Over 26.9231: 1.7802.

35 minus 29.6154 is 5.3846.

Squared, 28.9939.

Over 29.6154: 0.979.

15 minus 13.4615 is 1.5385.

Squared, 2.367.

Over 13.4615: 0.1758.

5 Add them

2.0769 plus 1.1422 plus 0.2051 plus 1.7802 plus 0.979 plus 0.1758 is 6.3592.

χ2 = 2.0769 + 1.1422 + 0.2051 + 1.7802 + 0.979 + 0.1758 = 6.3592

6 The cut-off

df is rows minus 1, times columns minus 1: 1 times 2 is 2.

df = (rows − 1)(columns − 1) = (2 − 1)(3 − 1) = 2

Careful!

Not the number of cells minus 1.

Rows minus 1, times columns minus 1: 2.

Careful: not df = 5 ✗

Chi-square is always a right-tail test: big means far from what we expected.

Row 2, column 0.05.

Row 2, column .05: the cut-off is 5.991.

7 Decide

The chi-square curve for df 2.

Past the cut-off, 5.991, is the reject part.

6.3592 is past the cut-off.

So we reject H zero.

= χ2 = 6.3592 > 5.991 → reject H0

8 Say it in words

At the 5% level, there is enough evidence that

In words: at the 5% level, there is enough evidence that the group and the answer are not independent.

the group and the answer are not independent.

9 Check

Let's check: the expected counts give the same row totals.

Junior: 23.0769 plus 25.3846 plus 11.5385 is 60.

junior: E 23.0769 + 25.3846 + 11.5385 = 60 = 60

Senior: 26.9231 plus 29.6154 plus 13.4615 is 70.

So it is right!

senior: E 26.9231 + 29.6154 + 13.4615 = 70 = 70

Let's look back.

First: write the hypotheses.

Then: totals.

Then: expected counts.

Then: each part.

Then: add them.

Then: the cut-off.

Then: decide.

Then: say it in words.

Last: check.

Answer
= χ2 = 6.3592 > 5.991 → reject H0

▶ Watch it solved

Practice

Try each one, then open the answer. Stuck? Open the problem to watch every step.

Easy

  1. chi-square independence: boys 20 yes 30 no, girls 30 yes 20 no, alpha 0.05
    Answer
    = χ2 = 4 > 3.841 → reject H0
  2. chi-square independence: men 40 yes 60 no, women 50 yes 50 no, alpha 0.05
    Answer
    = χ2 = 2.0202 < 3.841 → do not reject H0
  3. chi-square independence: young 25 tea 25 coffee, old 15 tea 35 coffee, alpha 0.05
    Answer
    = χ2 = 4.1666 > 3.841 → reject H0
  4. chi-square independence: city 30 bus 20 car, town 20 bus 30 car, alpha 0.10
    Answer
    = χ2 = 4 > 2.706 → reject H0
  5. chi-square independence: left 18 win 22 lose, right 22 win 18 lose, alpha 0.05
    Answer
    = χ2 = 0.8 < 3.841 → do not reject H0
  6. chi-square independence: adults 35 yes 15 no, teens 25 yes 25 no, alpha 0.05
    Answer
    = χ2 = 4.1666 > 3.841 → reject H0
  7. chi-square independence: east 50 agree 50 disagree, west 65 agree 35 disagree, alpha 0.05
    Answer
    = χ2 = 4.6036 > 3.841 → reject H0

Medium

  1. chi-square independence: boys 22 sport 18 music 20 art, girls 18 sport 22 music 20 art, alpha 0.05
    Answer
    = χ2 = 0.8 < 5.991 → do not reject H0
  2. chi-square independence: morning 30 pass 10 fail, evening 20 pass 20 fail, alpha 0.05
    Answer
    = χ2 = 5.3334 > 3.841 → reject H0
  3. chi-square independence: north 45 yes 55 no, south 30 yes 70 no, alpha 0.01
    Answer
    = χ2 = 4.8 < 6.635 → do not reject H0
  4. chi-square independence: dogs 40 walk 10 run, cats 25 walk 25 run, alpha 0.05
    Answer
    = χ2 = 9.8902 > 3.841 → reject H0
  5. chi-square independence: first 15 red 25 blue 10 green, second 25 red 15 blue 10 green, alpha 0.05
    Answer
    = χ2 = 5 < 5.991 → do not reject H0
  6. chi-square independence: weekday 60 early 40 late, weekend 40 early 60 late, alpha 0.01
    Answer
    = χ2 = 8 > 6.635 → reject H0
  7. chi-square independence: plan 32 better 18 same, none 20 better 30 same, alpha 0.05
    Answer
    = χ2 = 5.7692 > 3.841 → reject H0
  8. chi-square independence: boys 10 math 15 art 25 sport, girls 15 math 20 art 15 sport, alpha 0.10
    Answer
    = χ2 = 4.2142 < 4.605 → do not reject H0

Harder

  1. chi-square independence: junior 30 bus 20 car 10 walk, senior 20 bus 35 car 15 walk, alpha 0.05
    Answer
    = χ2 = 6.3592 > 5.991 → reject H0
  2. chi-square independence: a 20 yes 30 no, b 25 yes 25 no, c 35 yes 15 no, alpha 0.05
    Answer
    = χ2 = 9.3751 > 5.991 → reject H0
  3. chi-square independence: online 60 happy 40 unhappy, shop 45 happy 55 unhappy, alpha 0.025
    Answer
    = χ2 = 4.5112 < 5.024 → do not reject H0
  4. chi-square independence: small 12 low 18 high, medium 20 low 20 high, large 28 low 12 high, alpha 0.01
    Answer
    = χ2 = 6.7465 < 9.210 → do not reject H0
  5. chi-square independence: group1 25 a 25 b 30 c, group2 35 a 15 b 30 c, alpha 0.05
    Answer
    = χ2 = 4.1666 < 5.991 → do not reject H0
  6. chi-square independence: x 40 yes 20 no, y 30 yes 30 no, z 20 yes 40 no, alpha 0.01
    Answer
    = χ2 = 13.3332 > 9.210 → reject H0
  7. chi-square independence: spring 20 rain 30 dry, summer 10 rain 40 dry, autumn 25 rain 25 dry, alpha 0.05
    Answer
    = χ2 = 10.0479 > 5.991 → reject H0