Steply

Chi-square independence: online 60 happy 40 unhappy, shop 45 happy…

Step by step, with the reason for every step · Chi-square · University Statistics

Step by step

The question

Question: online: 60 happy, 40 unhappy; shop: 45 happy, 55 unhappy: at the 2.5% level, is the answer linked to the group?

online: 60 happy, 40 unhappy; shop: 45 happy, 55 unhappy; α = 0.025

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: online, 100; shop, 100.

Each column's total: happy, 105; unhappy, 95.

And everyone: 200.

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

Online, happy: 100 times 105, over 200, is 52.5.

= online, happy: 100 × 105 ÷ 200 = 52.5

Online, unhappy: 100 times 95, over 200, is 47.5.

= online, unhappy: 100 × 95 ÷ 200 = 47.5

Shop, happy: 100 times 105, over 200, is 52.5.

= shop, happy: 100 × 105 ÷ 200 = 52.5

Shop, unhappy: 100 times 95, over 200, is 47.5.

= shop, unhappy: 100 × 95 ÷ 200 = 47.5

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.

60 minus 52.5 is 7.5.

Squared, 56.25.

Over 52.5: 1.0714.

40 minus 47.5 is −7.5.

Squared, 56.25.

Over 47.5: 1.1842.

45 minus 52.5 is −7.5.

Squared, 56.25.

Over 52.5: 1.0714.

55 minus 47.5 is 7.5.

Squared, 56.25.

Over 47.5: 1.1842.

5 Add them

1.0714 plus 1.1842 plus 1.0714 plus 1.1842 is 4.5112.

χ2 = 1.0714 + 1.1842 + 1.0714 + 1.1842 = 4.5112

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.025.

Row 1, column .025: the cut-off is 5.024.

7 Decide

The chi-square curve for df 1.

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

4.5112 is not past the cut-off.

So we do not reject H zero.

= χ2 = 4.5112 < 5.024 → do not reject H0

8 Say it in words

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

In words: at the 2.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.

Online: 52.5 plus 47.5 is 100.

online: E 52.5 + 47.5 = 100 = 100

Shop: 52.5 plus 47.5 is 100.

So it is right!

shop: E 52.5 + 47.5 = 100 = 100

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.5112 < 5.024 → do not reject H0

Your turn

Try this one yourself, then check:

online: 61 happy, 40 unhappy; shop: 46 happy, 55 unhappy; α = 0.025
Show the answer
do not reject H0

More from Chi-square

The whole lesson: Chi-square →