Tutorials › AP Statistics › Running the Chi-Square Test on a Calculator

Expected counts and chi-square conclusions · Tutorial 572 of 1000

Running the Chi-Square Test on a Calculator

Practice running a chi-square test on a calculator and checking that its output matches the table and question.

Intermediate 9 min read

What You'll Learn

  • Enter observed counts in a matrix with the correct row and column order.
  • Run the calculator’s chi-square test using the observed matrix.
  • Read the chi-square statistic, degrees of freedom, and upper-tail p-value.
  • Find and interpret the expected counts matrix produced by the calculator.
  • Check calculator output against table totals and the test’s conditions.

From a Two-Way Table to Calculator Output

In “Entering Two-Way Data Into a Matrix on the Calculator,” you learned to enter a table of observed counts into a matrix. Now you will use that matrix to run a chi-square test and read the calculator’s results. The calculator can quickly find the test statistic, p-value, degrees of freedom, and expected counts, but it cannot check whether the study design or test conditions are appropriate.

On a TI-84-style calculator, the test is usually listed as \(\chi^2\)-Test in the STAT TESTS menu. The calculator uses the observed matrix as input and calculates an expected-count matrix as part of the test. The expected matrix is commonly stored in \([B]\), while the observed matrix is entered in \([A]\). Calculator models and menu layouts can vary, so check the labels on your screen.

Definition: The observed matrix contains the counts from the two-way table. The expected matrix contains the counts predicted for each cell under the test’s null model. Keep the same row and column order in the matrix as in the original table.

The calculator reports \(X^2\), \(p\), and \(df\). Here, \(X^2\) is the overall chi-square statistic, \(p\) is the upper-tail p-value, and \(df\) is the degrees of freedom. As covered in “Degrees of Freedom for a Two-Way Table,” a table with \(r\) rows and \(c\) columns has \(df=(r-1)(c-1)\). The test also produces an expected matrix, which you can inspect to check the expected-count condition.

Running the Test and Checking the Output

After entering the observed counts in \([A]\), open STAT TESTS and select \(\chi^2\)-Test. Set the Observed field to \([A]\). Set the Expected field to \([B]\), or to another matrix if you want to store the expected counts elsewhere. Choose Calculate. Do not enter your own expected counts as the observed matrix: the calculator calculates them from the observed table and the null model.

1
Check the observed matrix.
Confirm that its dimensions match the number of row and column categories, and that its entries are observed counts in the correct order.
2
Choose the test inputs.
Select \([A]\), or the matrix containing your observed counts, as Observed. Choose a matrix for the Expected output.
3
Run the test.
Select Calculate. Record the displayed \(X^2\), \(p\), and \(df\).
4
Inspect the expected matrix.
Open the matrix you selected for Expected. Check its dimensions, compare its entries with the table margins, and find the smallest expected count.

A useful output check is to compare the displayed degrees of freedom with the table dimensions. The expected counts should also add to the same row totals and column totals as the observed table, apart from small rounding differences on the screen. These checks can reveal a transposed matrix, a missing category, or a mistake in the input.

Calculator output: The test screen’s \(X^2\) is the overall statistic; \(p\) is the right-tail probability for that statistic and the displayed \(df\); and the Expected matrix gives the null-model count for every cell. Use full calculator precision for the test and round values when reporting them.

The p-value’s meaning and upper-tail direction were explained in “Finding the P-Value for a Chi-Square Statistic.” A calculator does not make the p-value the probability that the null hypothesis is true. Nor does it decide whether the study’s sampling or assignment process supports the test. You still need to check the conditions, including the random condition, independence, the 10% condition when sampling without replacement, and whether every expected count is at least 5.

Worked Example: Running a Test of Independence

Worked Example: Running a Test of Independence

An invented survey takes a random sample of 120 library cardholders from a district with 3,000 cardholders. Each person is classified by age group and preferred way to receive library notices. The observed table is:

Age groupEmailTextPrinted noticeTotal
Younger adults30201060
Older adults20251560
Total504525120

State. Let the population be the district’s library cardholders. The question is whether age group and preferred notice method are independent in this population. The null hypothesis states that they are independent; the alternative states that they are associated.

Plan. This is a chi-square test of independence because one sample is classified by two categorical variables. The sample is random, and each cardholder contributes to only one cell. For sampling without replacement, the 10% condition holds because \(120\le0.10(3000)=300\). We will check the expected-count condition using the calculator’s expected matrix.

Do. Enter the observed counts into a \(2\times3\) matrix in the same order as the table:

$$ [A]= \begin{bmatrix} 30&20&10\\ 20&25&15 \end{bmatrix} $$

Select \([A]\) as Observed, \([B]\) as Expected, and run \(\chi^2\)-Test. The calculator reports \(X^2\approx3.5556\), \(df=2\), and \(p\approx0.1690\). Inspecting \([B]\) gives the expected counts:

$$ [B]= \begin{bmatrix} 25&22.5&12.5\\ 25&22.5&12.5 \end{bmatrix} $$

Check the expected matrix using the margins. Each row total is 60, the column totals are 50, 45, and 25, and the grand total is 120. For example, the expected count for younger adults who prefer email is \(60(50)/120=25\). The six expected counts sum across rows and columns to the table’s margins. The smallest is \(12.5\), so every expected count is at least 5.

As a hand check of the statistic, the cell contributions are \(25/25=1\), \(6.25/22.5\approx0.2778\), \(6.25/12.5=0.5\), and the same three contributions in the second row. Their sum is \(3.5556\). The degrees of freedom are \((2-1)(3-1)=2\), matching the calculator. The p-value is the upper-tail area for \(X^2=3.5556\) and \(df=2\), approximately \(0.1690\).

Conclude. Assuming age group and preferred notice method are independent among district cardholders, the probability of obtaining a chi-square statistic at least as large as \(3.5556\) is about \(0.1690\). At \(\alpha=0.05\), this p-value is greater than the significance level, so fail to reject the null hypothesis. The sample does not provide convincing evidence of an association between age group and preferred notice method.

Worked Example: A Test of Homogeneity

Worked Example: A Test of Homogeneity

In an invented experiment, 90 seedlings are randomly assigned to one of three watering schedules. After a set period, each seedling is classified as having acceptable growth or needing additional care. The observed counts are:

Watering scheduleAcceptable growthNeeds careTotal
Schedule A24630
Schedule B151530
Schedule C111930
Total504090

This is a chi-square test of homogeneity: the experiment compares the distribution of one categorical outcome across three treatment groups. The null hypothesis is that the growth-outcome distribution is the same for all three schedules; the alternative is that at least one schedule has a different distribution.

The experiment uses random assignment, each seedling is assigned to one schedule, and the seedlings are treated as independent experimental units. The expected counts under the null are \(30(50)/90\approx16.67\) for acceptable growth and \(30(40)/90\approx13.33\) for needing care in each schedule. All expected counts are at least 5.

Enter the observed matrix and run the test:

$$ [A]= \begin{bmatrix} 24&6\\ 15&15\\ 11&19 \end{bmatrix} \qquad [B]\approx \begin{bmatrix} 16.67&13.33\\ 16.67&13.33\\ 16.67&13.33 \end{bmatrix} $$

The calculator reports \(X^2\approx11.9700\), \(df=(3-1)(2-1)=2\), and \(p\approx0.0025\), rounded to four decimal places. As a check, the statistic’s six cell contributions are approximately \(3.2267\), \(4.0333\), \(0.1667\), \(0.2083\), \(1.9267\), and \(2.4083\), which sum to \(11.9700\). The expected matrix has row totals of 30 and column totals of approximately 50 and 40.

The p-value is the probability, if all three schedules have the same growth-outcome distribution, of obtaining a chi-square statistic at least as large as \(11.9700\). The small p-value indicates that the observed counts would be unusual under that null model. Because this was a randomized experiment, evidence of a difference among outcome distributions can be attributed to the watering schedules, provided the experiment was carried out as described.

Worked Example: Catching a Matrix-Order Error

Worked Example: Catching a Matrix-Order Error

Suppose an invented random sample of 120 residents is classified by whether residents usually commute by bicycle or another method, and whether they have enrolled in a community travel workshop. The observed table is:

Usual commuteEnrolledNot enrolledTotal
Bicycle421860
Other method283260
Total7050120

The correct observed matrix is \([A]=\begin{bmatrix}42&18\\28&32\end{bmatrix}\). If the entries are accidentally entered as \(\begin{bmatrix}42&28\\18&32\end{bmatrix}\), the calculator will still run, but it is analyzing a different table. Always compare each matrix row with the corresponding table row before selecting Calculate.

For the correctly entered matrix, the expected matrix is

$$ [B]= \begin{bmatrix} 35&25\\ 35&25 \end{bmatrix} $$

The calculator gives \(X^2=6.7200\), \(df=(2-1)(2-1)=1\), and \(p\approx0.0095\), rounded to four decimal places. A hand check gives four contributions: \(49/35=1.4\), \(49/25=1.96\), \(49/35=1.4\), and \(49/25=1.96\). They sum to \(6.72\). Each expected row total is 60, and the expected column totals are 70 and 50, matching the observed margins.

Before interpreting the output, check the design and conditions. The survey used a random sample; each resident is counted once; and if the population contains at least 1,200 residents, the 10% condition holds because \(120\le0.10(1200)=120\). Every expected count is at least 5. These checks support using the chi-square test of independence for this table.

Common Mistakes and AP Exam Tip

  • Reversing rows or columns: A calculator cannot tell whether the matrix matches your table. Enter counts in the same category order and check each row before calculating.
  • Putting expected counts in the Observed field: The observed matrix must contain the actual counts. Let the test calculate the expected matrix from the observed counts and null model.
  • Ignoring the expected matrix: Running the test does not establish that the expected-count condition is met. Open the output matrix and check every cell, especially the smallest expected count.
  • Assuming the calculator checks conditions: It does not verify random sampling or assignment, independence, or the 10% condition. State and check those from the study description.
  • Using the wrong degrees of freedom: Confirm that the reported value matches \((r-1)(c-1)\) for the entered table’s dimensions.
  • Rounding too early: Use the calculator’s displayed statistic and p-value, retaining precision until the final report. Small differences in displayed expected counts may result from rounding and need not change the test output.
  • Calling the p-value a left-tail area: The chi-square test uses the upper tail. The reported calculator p-value is the probability of a statistic at least as large as the observed one, assuming the null hypothesis is true.

For a full-credit response about calculator output, identify the test and observed matrix, report \(X^2\), \(df\), and the p-value, and show the expected matrix or its smallest value when checking conditions. Interpret the p-value in context under the null hypothesis. A test decision and its contextual conclusion require comparing the p-value with \(\alpha\), a topic developed further in “Making a Decision in a Chi-Square Test.”

Key takeaway: Enter observed counts in the correct order, run \(\chi^2\)-Test with that matrix as Observed, and inspect the resulting statistic, degrees of freedom, p-value, and expected matrix. The calculator supplies results; you remain responsible for checking the study design and conditions.

Check Your Understanding

Use the calculator workflow and output checks from this tutorial to answer each question.

  1. A table has three row categories and two column categories. What degrees of freedom should the calculator report?
  2. What belongs in the Observed matrix, and what does the calculator put in the Expected matrix?
  3. A student enters a \(2\times3\) table in a \(3\times2\) matrix with the counts rearranged. Why might the calculator still produce output, and what should the student check?
  4. A test screen reports \(X^2=4.8\), \(df=2\), and \(p=0.0907\). What does the p-value mean under the null hypothesis?
  5. The smallest entry in the expected matrix is 4.6. Has the expected-count condition been met? What should be reported about this check?