Steply

Chi-square

Goodness of fit · University Statistics · 21 problems, easy to harder

▶ Watch the first one solved

How we do it

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

The steps for Chi-square: a die is rolled 60 times: 8, 12, 9, 11, 6, 14; is it…. Every solution names its steps, so you always know what comes next.

Worked examples

Chi-square: a die is rolled 60 times: 8, 12, 9, 11, 6, 14; is it… Easy

The question

Question: a die is rolled 60 times, and the faces 1 to 6 come up 8, 12, 9, 11, 6, 14 times: at the 5% level, is the die fair?

a die, 60 rolls: 8, 12, 9, 11, 6, 14; fair? α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the die is fair.

H0 : the die is fair

Hₐ is what we want to show.

Here: the die is not fair.

Ha : the die is not fair

2 Expected counts

If H zero is true, each cell expects n times its part.

E = n × p (if H0 is true)

Each face: 60 times 1/6 is 10.

E = 60 × 16 = 10

Every expected count is at least 5, so the test works.

all E at least 5: the test works

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

8 minus 10 is −2.

Squared, 4.

Over 10: 0.4.

12 minus 10 is 2.

Squared, 4.

Over 10: 0.4.

9 minus 10 is −1.

Squared, 1.

Over 10: 0.1.

11 minus 10 is 1.

Squared, 1.

Over 10: 0.1.

6 minus 10 is −4.

Squared, 16.

Over 10: 1.6.

14 minus 10 is 4.

Squared, 16.

Over 10: 1.6.

Careful!

We always divide by the expected count, not the observed one.

Careful: divide by E (expected), not by O

4 Add them

0.4 plus 0.4 plus 0.1 plus 0.1 plus 1.6 plus 1.6 is 4.2.

χ2 = 0.4 + 0.4 + 0.1 + 0.1 + 1.6 + 1.6 = 4.2

5 The cut-off

df is the number of cells minus 1: 6 minus 1 is 5.

df = k − 1 = 6 − 1 = 5

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

Row 5, column 0.05.

Row 5, column .05: the cut-off is 11.070.

6 Decide

The chi-square curve for df 5.

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

4.2 is not past the cut-off.

So we do not reject H zero.

= χ2 = 4.2 < 11.070 → do not reject H0

7 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 die is not fair.

the die is not fair.

This does not prove H zero is true.

We just cannot rule it out.

not rejecting H0 does not prove H0

8 Check

Let's check: the expected counts add up to 60, like the observed ones.

E: 10 + 10 + 10 + 10 + 10 + 10 = 60 = n

And the differences O minus E add up to 0.

So it is right!

O − E: (−2) + 2 + (−1) + 1 + (−4) + 4 = 0

Let's look back.

First: write the hypotheses.

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.2 < 11.070 → do not reject H0

▶ Watch it solved

Chi-square goodness of fit: observed 60, 30, 10; expected 50%, 30%… Medium

The question

Question: we saw the counts 60, 30, 10, and expected 50%, 30%, 20%: at the 5% level, do the data fit?

observed 60, 30, 10; expected 50%, 30%, 20%; α = 0.05

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the data fit the expected parts.

H0 : the data fit the expected parts

Hₐ is what we want to show.

Here: the data do not fit.

Ha : the data do not fit

2 Expected counts

If H zero is true, each cell expects n times its part.

E = n × p (if H0 is true)

A: 100 times 0.5 is 50.

E(A) = 100 × 0.5 = 50

B: 100 times 0.3 is 30.

E(B) = 100 × 0.3 = 30

C: 100 times 0.2 is 20.

E(C) = 100 × 0.2 = 20

Every expected count is at least 5, so the test works.

all E at least 5: the test works

3 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 50 is 10.

Squared, 100.

Over 50: 2.

30 minus 30 is 0.

Squared, 0.

Over 30: 0.

10 minus 20 is −10.

Squared, 100.

Over 20: 5.

Careful!

We always divide by the expected count, not the observed one.

Careful: divide by E (expected), not by O

4 Add them

2 plus 0 plus 5 is 7.

χ2 = 2 + 0 + 5 = 7

5 The cut-off

df is the number of cells minus 1: 3 minus 1 is 2.

df = k − 1 = 3 − 1 = 2

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.

6 Decide

The chi-square curve for df 2.

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

7 is past the cut-off.

So we reject H zero.

= χ2 = 7 > 5.991 → reject H0

7 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 data do not fit.

the data do not fit.

8 Check

Let's check: the expected counts add up to 100, like the observed ones.

E: 50 + 30 + 20 = 100 = n

And the differences O minus E add up to 0.

So it is right!

O − E: 10 + 0 + (−10) = 0

Let's look back.

First: write the hypotheses.

Then: expected counts.

Then: each part.

Then: add them.

Then: the cut-off.

Then: decide.

Then: say it in words.

Last: check.

Answer
= χ2 = 7 > 5.991 → reject H0

▶ Watch it solved

Chi-square goodness of fit: observed 90, 60, 50; expected 50%, 25%… Harder

The question

Question: we saw the counts 90, 60, 50, and expected 50%, 25%, 25%: at the 1% level, do the data fit?

observed 90, 60, 50; expected 50%, 25%, 25%; α = 0.01

1 Write the hypotheses

H₀ is the "nothing new" idea.

Here: the data fit the expected parts.

H0 : the data fit the expected parts

Hₐ is what we want to show.

Here: the data do not fit.

Ha : the data do not fit

2 Expected counts

If H zero is true, each cell expects n times its part.

E = n × p (if H0 is true)

A: 200 times 0.5 is 100.

E(A) = 200 × 0.5 = 100

B: 200 times 0.25 is 50.

E(B) = 200 × 0.25 = 50

C: 200 times 0.25 is 50.

E(C) = 200 × 0.25 = 50

Every expected count is at least 5, so the test works.

all E at least 5: the test works

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

90 minus 100 is −10.

Squared, 100.

Over 100: 1.

60 minus 50 is 10.

Squared, 100.

Over 50: 2.

50 minus 50 is 0.

Squared, 0.

Over 50: 0.

Careful!

We always divide by the expected count, not the observed one.

Careful: divide by E (expected), not by O

4 Add them

1 plus 2 plus 0 is 3.

χ2 = 1 + 2 + 0 = 3

5 The cut-off

df is the number of cells minus 1: 3 minus 1 is 2.

df = k − 1 = 3 − 1 = 2

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

Row 2, column 0.01.

Row 2, column .01: the cut-off is 9.210.

6 Decide

The chi-square curve for df 2.

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

3 is not past the cut-off.

So we do not reject H zero.

= χ2 = 3 < 9.210 → do not reject H0

7 Say it in words

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

In words: at the 1% level, there is not enough evidence that the data do not fit.

the data do not fit.

This does not prove H zero is true.

We just cannot rule it out.

not rejecting H0 does not prove H0

8 Check

Let's check: the expected counts add up to 200, like the observed ones.

E: 100 + 50 + 50 = 200 = n

And the differences O minus E add up to 0.

So it is right!

O − E: (−10) + 10 + 0 = 0

Let's look back.

First: write the hypotheses.

Then: expected counts.

Then: each part.

Then: add them.

Then: the cut-off.

Then: decide.

Then: say it in words.

Last: check.

Answer
= χ2 = 3 < 9.210 → do not 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: a die is rolled 60 times: 8, 12, 9, 11, 6, 14; is it fair, alpha 0.05
    Answer
    = χ2 = 4.2 < 11.070 → do not reject H0
  2. chi-square goodness of fit: observed 30, 50, 20; expected 25%, 50%, 25%, alpha 0.05
    Answer
    = χ2 = 2 < 5.991 → do not reject H0
  3. chi-square goodness of fit: observed 18, 22, 20, 40; expected equal, alpha 0.05
    Answer
    = χ2 = 12.32 > 7.815 → reject H0
  4. chi-square goodness of fit: observed 45, 55; expected 50%, 50%, alpha 0.05
    Answer
    = χ2 = 1 < 3.841 → do not reject H0
  5. chi-square: a die is rolled 120 times: 18, 22, 20, 25, 15, 20; is it fair, alpha 0.05
    Answer
    = χ2 = 2.9 < 11.070 → do not reject H0
  6. chi-square goodness of fit: observed 35, 40, 25; expected equal, alpha 0.05
    Answer
    = χ2 = 3.4999 < 5.991 → do not reject H0
  7. chi-square: a die is rolled 30 times: 4, 6, 5, 5, 3, 7; is it fair, alpha 0.05
    Answer
    = χ2 = 2 < 11.070 → do not reject H0

Medium

  1. chi-square goodness of fit: observed 60, 30, 10; expected 50%, 30%, 20%, alpha 0.05
    Answer
    = χ2 = 7 > 5.991 → reject H0
  2. chi-square goodness of fit: observed 50, 70, 30, 50; expected equal, alpha 0.01
    Answer
    = χ2 = 16 > 11.345 → reject H0
  3. chi-square: a die is rolled 60 times: 5, 8, 9, 8, 10, 20; is it fair, alpha 0.05
    Answer
    = χ2 = 13.4 > 11.070 → reject H0
  4. chi-square goodness of fit: observed 28, 22, 50; expected 25%, 25%, 50%, alpha 0.10
    Answer
    = χ2 = 0.72 < 4.605 → do not reject H0
  5. chi-square goodness of fit: observed 64, 36; expected 75%, 25%, alpha 0.05
    Answer
    = χ2 = 6.4533 > 3.841 → reject H0
  6. chi-square goodness of fit: observed 12, 18, 30, 40; expected 10%, 20%, 30%, 40%, alpha 0.05
    Answer
    = χ2 = 0.6 < 7.815 → do not reject H0
  7. chi-square goodness of fit: observed 52, 48; expected equal, alpha 0.05
    Answer
    = χ2 = 0.16 < 3.841 → do not reject H0

Harder

  1. chi-square goodness of fit: observed 90, 60, 50; expected 50%, 25%, 25%, alpha 0.01
    Answer
    = χ2 = 3 < 9.210 → do not reject H0
  2. chi-square: a die is rolled 300 times: 42, 55, 38, 61, 50, 54; is it fair, alpha 0.05
    Answer
    = χ2 = 7.4 < 11.070 → do not reject H0
  3. chi-square goodness of fit: observed 102, 48, 50; expected 60%, 20%, 20%, alpha 0.05
    Answer
    = χ2 = 6.8 > 5.991 → reject H0
  4. chi-square goodness of fit: observed 15, 25, 35, 45, 30; expected equal, alpha 0.025
    Answer
    = χ2 = 16.6666 > 11.143 → reject H0
  5. chi-square goodness of fit: observed 160, 25, 15; expected 70%, 20%, 10%, alpha 0.05
    Answer
    = χ2 = 9.7321 > 5.991 → reject H0
  6. chi-square: a die is rolled 180 times: 25, 35, 30, 20, 40, 30; is it fair, alpha 0.05
    Answer
    = χ2 = 8.3332 < 11.070 → do not reject H0
  7. chi-square goodness of fit: observed 33, 47, 70, 50; expected 20%, 20%, 30%, 30%, alpha 0.05
    Answer
    = χ2 = 5.7834 < 7.815 → do not reject H0