IB

View all Questions

Question

Mathematics

How do you run a chi-squared test of independence on a calculator?

Answer

Mathematics

Expert Answer

For a chi-squared test of independence, enter the observed frequencies, the counts you collected, as a matrix, select the calculator's two-way χ2\chi^2 test, and compare its pp-value with your chosen significance level. Use counts, not percentages, and leave row and column totals out of the matrix.

The example below uses a TI-84 Plus CE. Other models use different menus, but the statistical setup is the same. The Casio and TI-Nspire equivalents are summarised after the TI-84 steps.

Start with the data and hypotheses

Suppose a random sample of 120 students records each person's usual journey to school and preferred revision format. Each student appears in exactly one cell.

JourneyVideoWritten notesPractice questionsTotal
Bus32181060
Walk or cycle16242060
Total484230120

We want to test whether journey type and preferred revision format are associated. Before calculating, state:

  • H0H_0: journey type and preferred revision format are independent.
  • H1H_1: journey type and preferred revision format are not independent.

Use a significance level of α=0.05\alpha=0.05. The observations should be independent, and the categories should be mutually exclusive, so each observation fits in only one cell. The expected counts must also be large enough for the chi-squared approximation to be reliable. In this example all expected counts exceed 5.

Enter the observed matrix

  1. Press 2nd → x⁻¹ to open MATRIX.
  2. Select EDIT, then [A]. Use an unused matrix or save any existing contents first.
  3. Set its dimensions to 2 rows × 3 columns.
  4. Enter the six counts, row by row: 32, 18, 10, then 16, 24, 20.

The totals help you check the data, but are not additional observations. Including them would change the test.

Run the test

Press STAT, move to TESTS, and choose χ²-Test. Set Observed to [A] and Expected to [B], then choose Calculate. Matrix [B] is where the calculator will store its expected counts, so use a destination you can overwrite.

Choose χ²-Test, not χ²GOF-Test. Independence tests whether the categorical variables are associated; goodness of fit compares observed counts for a single categorical variable with a specified distribution.

For our table, the calculator gives

χ2=9.523…,p=0.008549…,df=2.\chi^2=9.523\ldots,\qquad p=0.008549\ldots,\qquad df=2.

In a written answer, give these to 3 significant figures: χ2=9.52\chi^2=9.52 and p=0.00855p=0.00855.

Other calculators

  • Casio fx-CG50: MENU → Statistics → TEST → CHI → 2WAY. Enter the counts into Mat A through ►MAT, leave Expected as Mat B, then Execute.
  • TI-Nspire CX: first store the counts as a matrix, for example obs:=[[32,18,10][16,24,20]]. Then menu → Statistics → Stat Tests → χ² 2-way Test, and enter obs as the observed matrix. The expected counts are stored as stat.ExpMatrix.

Check the expected counts

Open matrix [B] through the matrix menu. It should contain:

JourneyVideoWritten notesPractice questions
Bus242115
Walk or cycle242115

These are the counts predicted under independence. For example, 48 of the 120 students prefer video. If that proportion also applies to the 60 bus students, the expected video count is

E=60×48120=24.E=\frac{60\times48}{120}=24.

Each cell contributes (O−E)2/E(O-E)^2/E to the test statistic. The bus/video cell contributes (32−24)2/24=8/3(32-24)^2/24=8/3. Adding all six contributions gives 200/21=9.523…200/21=9.523\ldots

The degrees of freedom reflect how many cell counts can vary once the row and column totals are fixed. Here they are

df=(2−1)(3−1)=2.df=(2-1)(3-1)=2.

An unexpected matrix or different dfdf is a reason to check your dimensions and entries before interpreting the result.

Write the conclusion in context

Since p=0.00855<0.05p=0.00855<0.05, reject H0H_0. There is evidence at the 5% significance level of an association between journey type and preferred revision format in the population sampled.

This does not show that travelling by bus causes students to prefer videos. Nor is the pp-value the probability that H0H_0 is true. It is the probability of obtaining a test statistic at least as large as 9.529.52 if H0H_0 were true.

Practise the full process

Put the full process into practice with the animal-activity question in the AI SL Mock Exam, Set 1, Paper 2. Try checking an expected count before running the test, then explain what the result says about the relationship between road distance and animal activity.

Answered by Revision Village IB Expert

Interested in diving deeper into this concept?

Explore More IB Mathematics Resources

Over 80% of IB students globally are experiencing the power of Revision Village