Chi-squared Test (AI HL)

The χ2\chi^2 test compares observed frequencies with the frequencies expected if H0H_0 were true. The independence test checks whether two categorical variables are related, and the goodness-of-fit test checks whether data follow a given distribution. A large value of χ2\chi^2, or a small p-value, is evidence against H0H_0. It's part of the broader Hypothesis Testing topic.

28 questions on this sub-topic.

Syllabus

CodeSyllabus content
SL4.11Formulation of null and alternative hypotheses (H0H_0 and H1H_1), significance levels and p-values. The χ2\chi^2 test for independence (contingency tables, degrees of freedom, critical value) and the χ2\chi^2 goodness-of-fit test - only upper-tail tests at common significance levels (1%, 5%, 10%) are set, and expected frequencies must be greater than 5.

Official IB source: Mathematics: applications and interpretation subject brief (PDF, ibo.org).

Skills practised on this page:

Degrees of freedom and expected frequency

Degrees of freedom (independence)

ν=(r−1)(c−1)\nu = (r-1)(c-1)

Not in the formula booklet. rr rows and cc columns in the contingency table - once the totals are fixed, only this many cells can vary freely.

Expected frequency (independence)

E=(row total)(column total)grand totalE = \dfrac{(\text{row total})(\text{column total})}{\text{grand total}}

Not in the formula booklet. The GDC computes every expected frequency for you, but you should be able to find one by hand.

Need the full syllabus wording and formula-booklet reference table? See Hypothesis Testing.

Key terms

What are observed and expected frequencies?

Observed frequencies are the counts actually collected. Expected frequencies are the counts predicted if H0H_0 is true, and for a contingency table each is row total×column totalgrand total\dfrac{\text{row total}\times\text{column total}}{\text{grand total}}.

e.g. A cell with row total 4040, column total 3030 and grand total 120120 has expected frequency 40×30120=10\dfrac{40\times30}{120}=10.

What are the hypotheses for an independence test?

H0H_0 states that the two variables are independent, and H1H_1 states that they are not independent. Write them in the context of the question.

e.g. For a table with 33 year groups and 44 favourite subjects, H0H_0 is that favourite subject is independent of year group, and H1H_1 is that it is not independent of year group.

What is a goodness-of-fit test?

It tests whether observed frequencies match a stated distribution, such as equal probabilities for a fair die. H0H_0 says the data fit the model.

e.g. A die rolled 6060 times is expected to show each face 60×16=1060\times\dfrac16=10 times if it is fair.

What does the chi-squared statistic measure?

It adds (fo−fe)2fe\dfrac{(f_o-f_e)^2}{f_e} over every cell, so it measures the total gap between observed and expected frequencies. The larger it is, the stronger the evidence against H0H_0.

e.g. A cell with fo=14f_o=14 and fe=10f_e=10 contributes (14−10)210=1.6\dfrac{(14-10)^2}{10}=1.6.

Worked examples

1
Medium
GDC
[4 marks]

In a contingency table, a row total is 60, the column total is 75 and the grand total is 200.

(a) Find the expected frequency for that cell.

(b) State the formula used.

Worked solution

(a) E=60×75200E = \dfrac{60 \times 75}{200} M1
E=22.5.E = 22.5. A1

(b) E=(row total)(column total)grand total.E = \dfrac{(\text{row total})(\text{column total})}{\text{grand total}}. M1 A1On the GDC. Find the expected frequency for that cell. The calculator shows about 22.5. The calculator steps below are for (a).

TI-84 Plus CE: 2nd mode then type ((60 * 75)/(200)) enterCasio fx-CG50: MENU Run-Matrix then type ((60 * 75)/(200)) EXECasio fx-CG100: HOME Calculate then type ((60 * 75)/(200)) EXETI-Nspire CX: home Calculator then type ((60 * 75)/(200)) enterFull GDC guide: Enter a calculation on the home screen Topic page

M1 Substituting row total 6060, column total 7575 and grand total 200200 A1 Correct answer of 22.522.5 M1 Stating the correct Formula A1 Correct answer of E = (row total)(column total)/grand total
2
Medium
GDC
[5 marks]

A χ2\chi^2 test of independence on a 4×34\times3 table gives χ2=13.1.\chi^2 = 13.1. The critical value at the 5% level is 12.59.

(a) Find the degrees of freedom.

(b) State the conclusion at the 5% level.

Worked solution

(a) ν=(4−1)(3−1)\nu = (4-1)(3-1) M1
ν=6.\nu = 6. A1

(b) 13.1>12.5913.1 > 12.59, so reject H0H_0: R1 A1
the variables are not independent. A1On the GDC. Find the degrees of freedom. The calculator shows about 6. The calculator steps below are for (a).

TI-84 Plus CE: 2nd mode then type (4-1)(3-1) enterCasio fx-CG50: MENU Run-Matrix then type (4-1)(3-1) EXECasio fx-CG100: HOME Calculate then type (4-1)(3-1) EXETI-Nspire CX: home Calculator then type (4-1)(3-1) enterFull GDC guide: Enter a calculation on the home screen Topic page

M1 Df formula A1 ν=6\nu=6 R1 Compare A1 Reject A1 Concluding the variables are not independent since 13.1>12.5913.1>12.59
3
Easy
GDC
[1 marks]

A goodness-of-fit test checks whether a six-sided die is fair (6 categories), with no parameters estimated.
State the degrees of freedom.

Worked solution

For a GOF test with no estimated parameters, ν=(categories)−1.\nu=(\text{categories})-1.
Six faces give ν=6−1\nu=6-1 =5.=5. A1
Why. Once five expected counts are fixed, the sixth is determined by the total - hence one fewer degree of freedom than categories.

A GDC is permitted on this paper, so you may evaluate or verify this result directly on the calculator.

A1 ν = 5

Common mistakes

  • Forgetting to state the conclusion in context. "Reject H0H_0" alone rarely earns full marks - the final answer needs to say what that means for the actual situation, e.g. "there is evidence the machine underfills."
  • Mixing up rows and columns in the degrees-of-freedom formula. ν=(r−1)(c−1)\nu = (r-1)(c-1) uses the number of rows and columns in the table, not the total number of cells or the sample size.
  • Ignoring the expected-frequency condition. The test is only valid on this course when every expected frequency exceeds 5 - if a question mentions combining categories, this condition is usually why.

Using your GDC

Every step below is a real button sequence, not a vague "use your calculator" hint - covering the TI-84 Plus, TI-Nspire, and Casio fx-9860/fx-CG50. Pick your model to filter down to just the steps that apply to you.

Show steps for:
One-variable statistics (mean, median, standard deviation)

Needed before most t-tests - to find or confirm the sample mean and standard deviation you'll feed into the test.

  1. Enter the data into a list.
  2. STAT → Edit → type values into L1. Then STAT → CALC → 1:1-Var Stats, choose L1, Calculate.TI-84
  3. Add a Lists & Spreadsheet page, name a column and enter data; then a Calculator page → menu → Statistics → Stat Calculations → One-Variable Statistics.Nspire
  4. Statistics menu → enter data in List 1 → CALC (F2) → 1-VAR.Casio
  5. Read x¯\bar x (mean), SxS_x (sample sd) or σx\sigma_x (population sd), and the five-number summary.
  6. For frequency data, put values in one list and frequencies in another and set the frequency list.

Tip: SxS_x vs σx\sigma_x: use σx\sigma_x (population) for a complete data set, SxS_x (sample) for a sample. A t-test always uses the sample standard deviation.

Inverse normal (find the value for a given probability)

Underpins normal-based hypothesis tests and critical-value questions - converts a significance level into a critical z-value.

  1. Work out the area to the LEFT of the value you want.
  2. 2nd → VARS (DISTR) → invNorm(area, μ, σ). Newer OS lets you pick the tail.TI-84
  3. menu → Probability → Distributions → Inverse Normal; enter the area, μ and σ.Nspire
  4. Main menu → Statistics → DIST → NORM → InvN; set the tail and enter area, σ, μ.Casio

Tip: invNorm needs the area to the LEFT. For a 5% upper-tail critical value, use area = 0.95.

See the full GDC guide for more calculator models and topics.

Quick questions

How do I find degrees of freedom for a chi-squared test of independence?

For an rr-by-cc contingency table, ν=(r−1)(c−1)\nu = (r-1)(c-1).

What condition must expected frequencies satisfy?

Every expected frequency must be greater than 5 for the chi-squared test to be valid on this course. See the parent topic's GDC guidance for how to run the test itself.

What is the conclusion if chi-squared is greater than the critical value?

Reject H0H_0. The same decision comes from a p-value less than the significance level. State the conclusion in context, such as that the two variables are not independent.

What are the degrees of freedom for a goodness-of-fit test?

With kk categories and no parameters estimated from the data, ν=k−1\nu=k-1. A die with six categories has ν=5\nu=5.

What if an expected frequency is not greater than 5?

The test is not valid as it stands. Combine neighbouring categories (or rows or columns) so that every expected frequency is greater than 55, then recalculate the degrees of freedom.

Ready to practise properly?

28 chi-squared-test questions, marked instantly like the real exam.