Menu
Sign up Sign in

AI HL · 13.4

Hypothesis Testing

13.4.8

Combining categories in a chi-squared test

13.4.8

Combining categories in a chi-squared test

Target: I can find the expected frequencies for a contingency table and pick out those that are 5 or less. (+3 more)

By the end of this section

Key points

Why categories are combined

  • The chi-squared test is reliable only when every expected frequency is greater than 5. A very small expected frequency makes \(\dfrac{(O-E)^2}{E}\) too large and the test unreliable.
  • Always look at the whole expected matrix before you run the test. The observed counts can all look reasonable while an expected frequency is small.
  • If an expected frequency is 5 or less, do not carry on with that table. Combine categories, then start again.

How to combine

  • Combine whole rows or whole columns, never single cells.
  • Combine neighbouring categories (age 13 to 14 with 15 to 16), or categories that are alike in meaning (cheque with cash). Do not join categories that have nothing in common just to reach 5.
  • Add the observed counts, then find the expected frequencies again from the new table. Check that every one is greater than 5. If one is not, combine again.
  • Combine as little as you can: each merge loses detail. Start with the categories that have the smallest expected frequencies.

Justify and conclude

  • Say which expected frequencies were 5 or less, which categories you combined and why. This is part of the answer.
  • The hypotheses stay the same: \(H_0\) the two variables are independent, \(H_1\) they are not independent.
  • The degrees of freedom come from the combined table: df = (rows − 1)(columns − 1). Combining always lowers df.
  • Conclude in context from the p-value. If you do not reject \(H_0\), say there is insufficient evidence, not that the variables are independent.

On the calculator

The expected matrix

  • Run the chi-squared test for independence on the observed matrix.
  • Open the stored expected matrix and read every entry.
  • Look for any value of 5 or less before you trust the p-value.

Screenshot and video to come

Testing the combined table

  • Enter a new observed matrix with the combined rows or columns.
  • Run the test again and read \(\chi^2\), the p-value and df.
  • Check the new expected matrix has no value of 5 or less, and that df matches the smaller table.

Screenshot and video to come

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
Combining age groups

A library records what 149 visitors borrowed and their age group. A chi-squared test for independence is to be used to see whether the item borrowed is linked to age. (a) Find the expected frequencies. (b) Combine columns so that every expected frequency is greater than 5, and give the new table. (c) Test, at the 5% significance level, whether the item borrowed and the age group are independent.

ItemUnder 1212 to 1516 or overFiction35314Non-fiction22221Magazines31615
Working
  1. Expected values

    From the calculator: Fiction: 3.76, 42.8, 23.5; Non-fiction: 2.42, 27.5, 15.1; Magazines: 1.83, 20.8, 11.4

    Expected frequencies come from the calculator's stored matrix. Row total × column total ÷ grand total gives each one.

  2. Find the small ones

    Under 12: 3.76, 2.42, 1.83. All are 5 or less.

    The whole Under 12 column is below 5. A chi-squared test needs every expected frequency greater than 5.

  3. Combine

    Under 12 + 12 to 15 = Under 16. New table: Fiction: 56, 14; Non-fiction: 24, 21; Magazines: 19, 15

    Combine neighbouring age groups. Under 12 is next to 12 to 15, so they form one group. Add the observed counts.

  4. Check again

    New expected frequencies: Fiction: 46.5, 23.5; Non-fiction: 29.9, 15.1; Magazines: 22.6, 11.4. The smallest is 11.4.

    Every expected frequency is now greater than 5, so the test can go ahead.

  5. Hypotheses and df

    H0: item borrowed and age group are independent. H1: they are not independent. df = (3 − 1)(2 − 1) = 2

    The degrees of freedom use the new, smaller table.

  6. Test

    From the calculator: χ² = 10.9, p = 0.00421

    Enter the combined table as the observed matrix.

  7. Conclude

    0.00421 < 0.05, so reject H0. There is sufficient evidence, at the 5% significance level, that the item borrowed is not independent of age group.

    Compare p with 0.05 and answer in context.

Video walkthrough coming
Combining rows

A clinic records how long 241 patients waited and whether they came to the morning or the evening clinic. The results are shown. A chi-squared test for independence is used to test whether waiting time is linked to the clinic. (a) Find the expected frequencies and say which rows must be combined. (b) Find the degrees of freedom after combining. (c) Carry out the test at the 5% significance level.

WaitMorning clinicEvening clinicUnder 10 min544910 to 20 min2320 to 30 min45Over 30 min6559
Working
  1. Expected values

    From the calculator: Under 10 min: 53.4, 49.6; 10 to 20 min: 2.59, 2.41; 20 to 30 min: 4.67, 4.33; Over 30 min: 64.3, 59.7

    Read the whole expected matrix before you decide what to combine.

  2. Choose rows

    10 to 20 min (2.59, 2.41) and 20 to 30 min (4.67, 4.33) are below 5. Combine them: 10 to 30 min.

    Both small rows are next to each other, so they join to make one natural group. Justify the choice by naming the rows and their values.

  3. New table

    New table: Under 10 min: 54, 49; 10 to 30 min: 6, 8; Over 30 min: 65, 59. Smallest expected frequency: 6.74

    Add the observed counts, then recalculate the expected values. All are greater than 5.

  4. Degrees of freedom

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

    Before combining it would have been (4 − 1)(2 − 1) = 3. Use the smaller table.

  5. Test

    H0: waiting time and clinic are independent. H1: they are not independent. From the calculator: χ² = 0.483, p = 0.785

    State the hypotheses in context, then use the calculator on the combined table.

  6. Conclude

    0.785 > 0.05, so do not reject H0. There is insufficient evidence, at the 5% significance level, that waiting time is not independent of clinic.

    A large p-value means the data are consistent with independence. It does not prove independence.

Video walkthrough coming
Justifying the groups

234 students were asked how often they buy lunch at school. The results are shown. Test, at the 5% significance level, whether the answer is independent of the year group. Combine categories first if you need to, and say why.

Buys lunchNeverRarelyMost daysEvery dayYear 10479516Year 11668812
Working
  1. Expected values

    From the calculator: Year 10: 5.21, 6.78, 95.4, 14.6; Year 11: 4.79, 6.22, 87.6, 13.4

    One expected frequency is 5 or less, in the Never column.

  2. Justify the grouping

    Never: 5.21 and 4.79. Rarely: 6.78 and 6.22. Combine Never and Rarely: Never or rarely.

    The Never column has an expected frequency of 5 or less. It is next to Rarely and means almost the same thing, so combine them. Most days and Every day are already greater than 5 and stay as they are.

  3. New table

    New table: Year 10: 11, 95, 16; Year 11: 12, 88, 12. Smallest expected: 11.0

    Every expected frequency is greater than 5.

  4. Test

    H0: how often a student buys lunch and year group are independent. H1: they are not independent. df = (2 − 1)(3 − 1) = 2. From the calculator: χ² = 0.456, p = 0.796

    The calculator gives df too. Check it matches the new table.

  5. Conclude

    0.796 > 0.05, so do not reject H0. There is insufficient evidence, at the 5% significance level, that how often a student buys lunch is not independent of year group.

    Do not reject H0. Say what that means in context.

Video walkthrough coming