Scribe logoScribeNotes & practice
Sign inStart free
  1. Notes
  2. ›AP Statistics
  3. ›3 Inference for Categorical Data: Proportions
  4. ›3.14 Setting up a chi-square test for two-way tables

AP Statistics · Unit 3 · Inference for Categorical Data: Proportions

3.14 Setting up a chi-square test for two-way tables

Write hypotheses for a chi-square test of homogeneity or independence, check its conditions, and calculate expected counts for a two-way table.

  • 4 min read
  • 5 parts
  • 10 questions
  • Draft
Start a Quick 5 on this topic→Jump to the 10 questions
1/5Two-way tables organize counts for categorical variables
  1. 1Two-way tables organize counts for categorical variables
  2. 2The study design decides which chi-square test to use
  3. 3The hypotheses describe populations, not samples
  4. 4Expected counts show what the null hypothesis predicts
  5. 5Valid conclusions need randomness, independence, and expected counts of at least 5
  6. Check your recall
  7. Practice: 10 questions
1

Part 1 of 5: Two-way tables organize counts for categorical variables

Proportion tests handle two groups and a yes-or-no outcome. Real data often have more groups or more categories than that. A two-way table lays out counts for any number of groups and categories.

Each cell holds the number of individuals with one particular combination. The chi-square test compares these observed counts with the counts we would expect if the null hypothesis were true. It judges whether the pattern could easily come from chance alone.

These tests need actual counts, with each individual in exactly one cell. Percentages and proportions are not enough. Convert percentages back to counts before you start.

Key terms · tap one for its definition

two-way table

A two-way table is a table of counts in which rows represent categories of one variable and columns represent categories of another.

chi-square test

A chi-square test is a significance test that compares observed counts in a table with the counts expected when the null hypothesis is true.

Part 1 done

2

Part 2 of 5: The study design decides which chi-square test to use

Two versions of the test use the same calculations. The test of homogeneity asks whether a categorical variable has the same distribution in several populations. The test of independence asks whether two categorical variables are associated in one population.

Choosing between the two tests

FeatureHomogeneityIndependence
Data collectionSeparate random samples, or randomized treatment groupsOne random sample
VariablesOne variable measured in each groupTwo variables measured on each individual
QuestionIs the distribution the same in every group?Are the variables associated?
Feature
Data collection
Homogeneity
Separate random samples, or randomized treatment groups
Independence
One random sample
Feature
Variables
Homogeneity
One variable measured in each group
Independence
Two variables measured on each individual
Feature
Question
Homogeneity
Is the distribution the same in every group?
Independence
Are the variables associated?

The calculations will not reveal the design, so read the description of the data. Look for separate samples from each group, or for one sample sorted two ways.

Exam tip

Choose the test from how the data were collected, not from how the table looks.

Key terms · tap one for its definition

test of homogeneity

A test of homogeneity is a chi-square test of whether one categorical variable has the same distribution in several populations or treatment groups.

test of independence

A test of independence is a chi-square test of whether two categorical variables are associated among the individuals of one population.

Part 2 done

Quick check

One question on the part you just read

Easy

Identify the correct formula for the expected count of a cell in a two-way table.
Show answer and explanation

Answer: B · Worked explanation

The expected count multiplies the row and column totals, then divides by the table total, so the cell reflects both overall percentages. Adding the totals mixes up the operation. Dividing a row total by the number of columns assumes equal columns, which the data do not require.
3

Part 3 of 5: The hypotheses describe populations, not samples

Once the test is chosen, the hypotheses follow a fixed pattern. Write both in context, using the names of the variables and groups.

  • Homogeneity: H0H_0H0​ says the variable has the same distribution in all populations; HaH_aHa​ says it does not
  • Independence: H0H_0H0​ says the two variables are independent in the population; HaH_aHa​ says they are not

The alternative never specifies which groups or categories differ. It says only that the distributions are not all the same, or that an association exists.

Common mistake

Do not write the hypotheses about the sample. The sample counts will almost never match exactly, so the claim must be about the population.

Part 3 done

4

Part 4 of 5: Expected counts show what the null hypothesis predicts

The conditions and the test statistic both use expected counts, so we calculate them next. The expected count for a cell is the count we would anticipate if H0H_0H0​ were true. If every group had the same distribution, each group would match the overall column percentages.

The formula is expected count=(row total)(column total)table total\text{expected count} = \frac{(\text{row total})(\text{column total})}{\text{table total}}expected count=table total(row total)(column total)​.

Expected counts need not be whole numbers, so keep the decimals. Each row of expected counts adds to its row total. Each column adds to its column total.

Worked example

Finding expected counts

Separate random samples of freshmen and seniors are asked their favorite lunch. Freshmen: 50 pizza, 30 salad, 40 wrap. Seniors: 20 pizza, 30 salad, 30 wrap. Find the expected counts.
  1. 1
    Row totals: freshmen 120 and seniors 80. Column totals: pizza 70, salad 60, wrap 70. Table total: 200.
  2. 2
    Freshmen pizza: 120×70200=42\frac{120 \times 70}{200} = 42200120×70​=42. Freshmen salad: 120×60200=36\frac{120 \times 60}{200} = 36200120×60​=36. Freshmen wrap: 42.
  3. 3
    Seniors pizza: 80×70200=28\frac{80 \times 70}{200} = 2820080×70​=28. Seniors salad: 80×60200=24\frac{80 \times 60}{200} = 2420080×60​=24. Seniors wrap: 28.
  4. 4
    Check that each row of expected counts adds to its row total.

Answer: The expected counts are 42, 36, 42 for freshmen and 28, 24, 28 for seniors.

Expected counts for the lunch survey

GroupPizzaSaladWrap
Freshmen423642
Seniors282428
Group
Freshmen
Pizza
42
Salad
36
Wrap
42
Group
Seniors
Pizza
28
Salad
24
Wrap
28

Key term

expected count

The expected count for a cell is its row total times its column total, divided by the table total, assuming the null hypothesis is true.

Part 4 done

Quick check

One question on the part you just read

Easy

Identify the correct pair of hypotheses for a test of independence.
Show answer and explanation

Answer: B · Worked explanation

The null hypothesis is the claim of no association, so it says the variables are independent. Reversing the claims puts the association in the null. Hypotheses about equal cell counts are wrong, because cells in a valid table are rarely equal even when the variables are independent.
5

Part 5 of 5: Valid conclusions need randomness, independence, and expected counts of at least 5

With expected counts in hand, we can finish checking the conditions. Check each of these:

  • Random: separate random samples, one random sample, or random assignment
  • Independent: each sample is less than 10% of its population when sampling without replacement
  • Large counts: every expected count is at least 5

In the lunch survey, the smallest expected count is 24, so the large counts condition is met. Write the check using the actual numbers, not just a statement that it holds.

Common mistake

Checking that the observed counts are at least 5 is not enough. The condition applies to the expected counts.

Note read

Check your recall[13 marks]

6 written questions. Answer each one in your head or on paper, then open the mark scheme.

  1. 1.Identify[2 marks]

    Identify the chi-square test that fits random samples of 150 residents from each of three cities, each asked whether they usually travel by car, bus, or bike.

    Show mark schemeHide mark scheme

    Model answer

    A test of homogeneity fits, because separate random samples were taken from three populations and one categorical variable was measured in each.

    • 1 mark for identifying the test of homogeneity
    • 1 mark for justifying it with separate random samples from several populations
  2. 2.Identify[2 marks]

    Identify the null and alternative hypotheses for one random sample of 300 adults classified by age group and favorite social media site.

    Show mark schemeHide mark scheme

    Model answer

    H0H_0H0​: Age group and favorite site are independent in the population of adults. HaH_aHa​: Age group and favorite site are not independent.

    • 1 mark for stating the null hypothesis of independence in context
    • 1 mark for stating the alternative hypothesis of an association in context
  3. 3.Calculate[2 marks]

    Calculate the expected count for a cell in a table with row total 90, column total 60, and table total 240.

    Show mark schemeHide mark scheme

    Model answer

    90×60240=5400240=22.5\frac{90 \times 60}{240} = \frac{5400}{240} = 22.524090×60​=2405400​=22.5.

    • 1 mark for using row total times column total divided by table total
    • 1 mark for obtaining 22.5
  4. 4.Describe[3 marks]

    Describe the conditions for using a chi-square test with a two-way table.

    Show mark schemeHide mark scheme

    Model answer

    The data must come from random samples or random assignment. Observations must be independent, with each sample under 10% of its population when sampling without replacement. Every expected count must be at least 5.

    • 1 mark for stating random sampling or random assignment
    • 1 mark for stating independence including the 10% condition
    • 1 mark for stating that all expected counts are at least 5
  5. 5.Determine[2 marks]

    Determine whether the large counts condition is met when the expected counts are 12.5, 8.0, 4.5, and 15.0.

    Show mark schemeHide mark scheme

    Model answer

    The condition is not met, because the expected count of 4.5 is less than 5.

    • 1 mark for identifying 4.5 as an expected count below 5
    • 1 mark for concluding that the condition is not met
  6. 6.Explain[2 marks]

    Explain why the alternative hypothesis for a test of homogeneity does not say which groups differ.

    Show mark schemeHide mark scheme

    Model answer

    The alternative states only that the distribution of the variable is not the same in all groups. The test checks whether any difference exists overall, not where the difference lies.

    • 1 mark for stating that the alternative says the distributions are not all the same
    • 1 mark for explaining that the test does not identify which groups differ

Practice this topic

10 quick-fire multiple-choice questions, easy to hard. Tap an answer to see if you're right and the worked explanation. (The written questions with mark schemes are under “Check your recall” above.)

0 right0 of 10 answered

Includes the 2 quick checks in the note above.

3.

Easy·Identify[1 mark]

Separate random samples of students from each of three schools are asked to pick a favorite sport from a list. Identify the appropriate test.
Show answer and explanation

Answer: B · Worked explanation

Separate random samples from three populations, with one categorical variable measured in each, call for a test of homogeneity. A test of independence needs a single sample classified two ways. A two-proportion test compares only two groups with a yes-or-no outcome, and a one-proportion test uses one sample.
4.

Medium·Calculate[2 marks]

A table has row total 150, column total 80, and table total 400. Calculate the expected count for the cell in that row and column.
Show answer and explanation

Answer: D · Worked explanation

150×80400=12000400=30\frac{150 \times 80}{400} = \frac{12000}{400} = 30400150×80​=40012000​=30. The value 80 comes from dividing the product by the row total, and 150 from dividing by the column total. The value 230 adds the two totals, which does not follow the formula.
5.

Medium·Identify[2 marks]

One random sample of 400 adults is asked about commute type (car, transit, bike, or walk) and income level (low, middle, or high). Identify the alternative hypothesis.
Show answer and explanation

Answer: A · Worked explanation

A single sample classified on two variables calls for a test of independence, and the alternative says there is an association in the population. Hypotheses about the sample are wrong because the sample counts are already known. A one-sided claim is not possible here, and the independence statement is the null.
6.

Medium·Determine[2 marks]

A chi-square test has expected counts of 6.2, 4.8, 9.0, and 11.5. Determine whether the large counts condition is met.
Show answer and explanation

Answer: A · Worked explanation

Every expected count must be at least 5, and 4.8 falls short, so the condition is not met. A cutoff of 4 is not the rule, and the total of the expected counts does not matter. Expected counts are almost never equal, so unequal values do not break the condition.
7.

Medium·Identify[2 marks]

Separate random samples of customers from four stores are asked to rate satisfaction as low, medium, or high. Identify the null hypothesis.
Show answer and explanation

Answer: D · Worked explanation

A test of homogeneity states that the distribution of the variable is the same in every population. Satisfaction here is categorical, so a mean makes no sense. Hypotheses about the four samples are wrong because they must describe all customers of the stores, not only those sampled.
8.

Hard·Determine[2 marks]

A random sample of 100 people is classified by group, with row totals 18 and 82, and by response, with column totals 20 and 80. Determine whether the large counts condition is met.
Show answer and explanation

Answer: D · Worked explanation

The smallest expected count belongs to the smallest row and smallest column: 18×20100=3.6\frac{18 \times 20}{100} = 3.610018×20​=3.6, which is below 5. The condition concerns expected counts, so totals and sample size cannot settle it. The cutoff of 30 belongs to a different rule, and column totals are not expected counts.
9.

Hard·Identify[2 marks]

Volunteers are randomly assigned to one of three study methods, and each student's result is recorded as pass or fail. Identify the correct test and randomness condition.
Show answer and explanation

Answer: D · Worked explanation

Random assignment creates three treatment groups, and the outcome distribution is compared across groups, which is a homogeneity setting. Random assignment meets the randomness condition for an experiment. Volunteers are not a random sample, but that limits generalizing rather than the test. Independence needs a single sample sorted two ways.
10.

Hard·Determine[2 marks]

In a table, the row total is 60 and the expected counts across three columns are 18, 24, and a missing value. Determine the missing expected count.
Show answer and explanation

Answer: B · Worked explanation

Expected counts in a row add to the row total, so the missing value is 60−18−24=1860 - 18 - 24 = 1860−18−24=18. The value 42 is the sum of the two known counts, not the missing one. The value 24 and the value 12 do not make the row sum to 60.

Keep going

Next topic3.15 Carrying out a chi-square test for two-way tablesPrevious topic3.13 Carrying out a two-proportion test

More in Unit 3 · Inference for Categorical Data: Proportions

  1. 3.7Carrying out a test for a proportionNotes · 10 questions
  2. 3.8Errors in testsNotes · 10 questions
  3. 3.9Differences in sample proportionsNotes · 10 questions
  4. 3.10Interval for a difference of proportionsNotes · 10 questions
  5. 3.11Claims from a difference intervalNotes · 10 questions
  6. 3.12Setting up a two-proportion testNotes · 10 questions
  7. 3.13Carrying out a two-proportion testNotes · 10 questions
  8. 3.14Setting up a chi-square test for two-way tablesNotes · 10 questions
  9. 3.15Carrying out a chi-square test for two-way tablesNotes · 10 questions

All AP Statistics topics →

Draft: written by Scribe and checked automatically, not yet by a subject reviewer.

Practice questions are original, written by Scribe and checked automatically for correctness.

Topic codes follow the official numbering. Not endorsed by College Board or any exam board.

On this page

0/5 read

  1. 1Two-way tables organize counts for categorical variables
  2. 2The study design decides which chi-square test to use
  3. 3The hypotheses describe populations, not samples
  4. 4Expected counts show what the null hypothesis predicts
  5. 5Valid conclusions need randomness, independence, and expected counts of at least 5
  6. Check your recall
  7. Practice: 10 questions
All coursesScribeHow it worksPricingPrivacyTerms

Notes and questions are written by Scribe in our own words. Topic codes follow the official course numbering so you can find your place. Not produced or endorsed by the IB, College Board, AQA, OCR, Pearson Edexcel or any exam board.

© 2026 Scribe