Chi-squared Test (AI HL)
The test compares observed frequencies with the frequencies expected if 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 , or a small p-value, is evidence against . It's part of the broader Hypothesis Testing topic.
28 questions on this sub-topic.
Syllabus
| Code | Syllabus content |
|---|---|
| SL4.11 | Formulation of null and alternative hypotheses ( and ), significance levels and p-values. The test for independence (contingency tables, degrees of freedom, critical value) and the 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:
- Compare a p-value to a given significance level and state a conclusion in context.
- Carry out a chi-squared test for independence, including finding expected values and degrees of freedom, using a GDC.
- Carry out a chi-squared goodness-of-fit test using a GDC.
Degrees of freedom and expected frequency
Degrees of freedom (independence)
Not in the formula booklet. rows and columns in the contingency table - once the totals are fixed, only this many cells can vary freely.
Expected frequency (independence)
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 is true, and for a contingency table each is .
e.g. A cell with row total , column total and grand total has expected frequency .
What are the hypotheses for an independence test?
states that the two variables are independent, and states that they are not independent. Write them in the context of the question.
e.g. For a table with year groups and favourite subjects, is that favourite subject is independent of year group, and 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. says the data fit the model.
e.g. A die rolled times is expected to show each face times if it is fair.
What does the chi-squared statistic measure?
It adds over every cell, so it measures the total gap between observed and expected frequencies. The larger it is, the stronger the evidence against .
e.g. A cell with and contributes .
Worked examples
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) M1
A1
(b) M1 A1On the GDC. Find the expected frequency for that cell. The calculator shows about 22.5. The calculator steps below are for (a).
A test of independence on a table gives 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) M1
A1
(b) , so reject : 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).
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,
Six faces give A1
Why. Once five expected counts are fixed, the sixth is determined by the total - hence one fewer degree of freedom than categories.
Common mistakes
- Forgetting to state the conclusion in context. "Reject " 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. 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.
Needed before most t-tests - to find or confirm the sample mean and standard deviation you'll feed into the test.
- Enter the data into a list.
- STAT → Edit → type values into L1. Then STAT → CALC → 1:1-Var Stats, choose L1, Calculate.TI-84
- Add a Lists & Spreadsheet page, name a column and enter data; then a Calculator page → menu → Statistics → Stat Calculations → One-Variable Statistics.Nspire
- Statistics menu → enter data in List 1 → CALC (F2) → 1-VAR.Casio
- Read (mean), (sample sd) or (population sd), and the five-number summary.
- For frequency data, put values in one list and frequencies in another and set the frequency list.
Tip: vs : use (population) for a complete data set, (sample) for a sample. A t-test always uses the sample standard deviation.
Underpins normal-based hypothesis tests and critical-value questions - converts a significance level into a critical z-value.
- Work out the area to the LEFT of the value you want.
- 2nd → VARS (DISTR) → invNorm(area, μ, σ). Newer OS lets you pick the tail.TI-84
- menu → Probability → Distributions → Inverse Normal; enter the area, μ and σ.Nspire
- 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 -by- contingency table, .
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 . 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 categories and no parameters estimated from the data, . A die with six categories has .
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 , then recalculate the degrees of freedom.
Ready to practise properly?
28 chi-squared-test questions, marked instantly like the real exam.