IB Applications and Interpretation SL · χ² and t-tests · Section 2 of 3

χ² goodness-of-fit test

3 worked examples · By Álvaro López

Key idea

A goodness-of-fit test answers one question: do the data I have collected fit a distribution that someone claims? A die that is supposed to be fair, proportions announced by a manufacturer, an even spread of calls across the week. You compare the observed frequencies with the ones you would expect if the claim were true, summarise them in the statistic , and decide using the -value. In the IB exam you may be asked to state the hypotheses, find the expected frequencies and the degrees of freedom, read and from the calculator, and conclude in the context of the problem.

What is being tested

In the independence test you had a table with two variables. Here there is only one categorical variable, with categories, and a distribution proposed in advance that you want to check.

The proposed distribution can be uniform (all categories equally likely) or with given proportions (for example, 50%, 30% and 20%).

Expected frequencies

If is true and the sample has data values in total, the expected frequency of each category is times the probability that assigns to it.

The statistic, the degrees of freedom and the decision

Using and the degrees of freedom, there are two equivalent ways to decide, both at a significance level (usually 5%, that is, ):

  • With the -value: if , reject ; if , do not reject it.
  • With the critical value: if exceeds the critical value of the distribution with those degrees of freedom, reject . It is the same rule, because the critical value is the one that leaves an area to its right.

Density of the chi-squared distribution with 3 degrees of freedom, skewed with a long right tail: the critical value 7.81 leaves an area of 0.05 to its right, the rejection region of H₀, and to its left H₀ is not rejected

The tail is always the right-hand one: the test rejects only when is large, because a very small value indicates an almost perfect fit, not a mismatch.

Worked examples

Example 1 Basic

A six-sided die

A student suspects that a six-sided die is biased. They throw it 120 times and get the following frequencies:

Face 1 2 3 4 5 6
Frequency 15 22 18 25 17 23

Carry out a chi-squared goodness-of-fit test, at the 5% significance level, to decide whether the die is fair.

a) Write down the hypotheses and find the expected frequency of each face.

b) State the degrees of freedom.

c) Find and the -value.

d) Conclude in context.

Solution

a) : the die is fair (each face has probability ). : the die is not fair.

If it is fair, the expected frequency of each face is It is greater than 5, so the test can be applied.

b) There are 6 categories: .

c) Add the contributions of the six faces: The calculator, with the observed and expected lists and 5 degrees of freedom, gives and .

d) As , is not rejected. (With the critical value it is the same: , which is the critical value for 5 degrees of freedom at 5%.) There is not enough evidence to say that the die is biased: the differences observed are consistent with chance.

Example 2 Medium

Advertised sweet colours

A manufacturer advertises that, in each bag of sweets, 50% are red, 30% green and 20% yellow. A customer opens bags, collects 200 sweets and counts 126 red, 46 green and 28 yellow. She wants to know, at the 5% significance level, whether the data are consistent with what the manufacturer advertises.

a) Write down the hypotheses and calculate the expected frequencies of red, green and yellow.

b) State the degrees of freedom.

c) Find and the -value.

d) Conclude in context.

Solution

a) : the proportions are the advertised ones (0.5, 0.3 and 0.2). : the proportions are not the advertised ones.

The expected frequencies come from multiplying the total by each proportion: They add up to 200 and all are greater than 5.

b) There are 3 categories: .

c) The calculator gives and .

d) As , is rejected. (The critical value for 2 degrees of freedom at 5% is , and .) There is evidence that the colour proportions in the bags are not the ones the manufacturer advertises. There are many more reds than expected, and fewer greens and yellows.

Example 3 Hard

School canteen preferences: the significance level matters

A school canteen has four menus. The manager believes that the preferences of the 200 students who eat there are in the ratio (menu A : menu B : menu C : menu D). One day the choice of each student is recorded. Menus A, B and C were chosen by 28, 30 and 54 students, respectively. Every student chose one menu.

a) Find how many students chose menu D.

b) Calculate the expected frequencies of the four menus if the manager is right.

c) State the degrees of freedom.

d) Find .

e) Find the -value.

f) For each significance level, 5% and 10%, state whether the null hypothesis that the preferences follow the ratio is rejected or not.

Solution

a) All 200 students chose a menu, so menu D was chosen by

b) The ratio adds up to , so according to the manager the probabilities are , , and . The expected frequencies are All are greater than 5.

c) There are 4 categories: . The hypotheses are : the preferences follow the ratio ; : they do not follow it.

d)

e) With 3 degrees of freedom, the calculator gives .

f) Compare with each level:

  • At 5%: , so is not rejected. (Critical value .)
  • At 10%: , so is rejected. (Critical value .)

The conclusion depends on the level chosen: with a 5% risk of error there is not enough evidence against the manager; accepting a 10% risk, there is. A -value this close to the thresholds indicates a borderline case, and it is worth collecting more data before deciding.

In the exam: the significance level is set before looking at the data and is given in the question; do not choose it to get the conclusion you prefer. Marks are given for writing the hypotheses, the expected frequencies, the degrees of freedom, the -value and the explicit comparison of with , and for finishing with a conclusion in context (“the data do not fit the manager's ratio”), not just “ is rejected”.

Common mistakes

Summary

  • Goodness of fit: one variable with categories and a proposed distribution. : the data follow that distribution; : they do not follow it.
  • Expected frequencies: (uniform: ). They add up to and must all be .
  • Statistic: . Degrees of freedom: .
  • Reject if (equivalent to critical value). Only the right-hand tail counts.
  • The GDC gives and from the observed and expected lists; you write the set-up yourself.
  • Always conclude in context, and if say “there is no evidence to reject ”, not “it is proved”.
Maths classes in Aldaia and online

Want to work on it together?

Free first consultation: we look at your level and your exam, and build a plan. Álvaro replies on WhatsApp.

Message us on WhatsApp