THE VR SCHOOL
  • Schools & Districts
    • License the academy
    • Free program for your students
    • Request a demo
  • Catalog
    • AI & Data
    • Cybersecurity & Web
    • Programming
    • Health Science
    • All Guilds
    • All courses
  • Families
  • Accreditation
  • Log In
  • Request a demo
  • Home
  • Courses

RLP Statistics B — Probability Models and Statistical Inference

Curriculum

  • 4 Sections
  • 20 Lessons
  • 10 Weeks
Expand all sectionsCollapse all sections
  • Unit 1: Continuous Distributions and Sampling Distributions
    5
    • 1.1
      Continuous Random Variables and Density Curves
      50 mins
    • 1.2
      The Normal Distribution
      50 mins
    • 1.3
      When Is a Normal Model Appropriate?
      50 mins
    • 1.4
      Sampling Distributions and the Central Limit Theorem
      50 mins
    • 1.5
      Performance Task — Sampling Distribution Simulation Study
      150 mins
  • Unit 2: Estimating with Confidence
    5
    • 2.1
      Estimating a Proportion with Confidence
      50 mins
    • 2.2
      Confidence Intervals for a Mean
      50 mins
    • 2.3
      What Confidence Means, and What It Does Not
      50 mins
    • 2.4
      Comparing Two Groups with Confidence Intervals
      50 mins
    • 2.5
      Performance Task — Estimation Study
      150 mins
  • Unit 3: Testing Claims: Significance Tests
    5
    • 3.1
      The Logic of a Significance Test
      50 mins
    • 3.2
      t-Tests for Means and Paired Data
      50 mins
    • 3.3
      Errors, Power and Significance in the Real World
      50 mins
    • 3.4
      Two-Sample Tests from Experiments and Observational Data
      50 mins
    • 3.5
      Performance Task — Significance Test Investigation
      150 mins
  • Unit 4: Chi-Square, Regression Inference and the Capstone Study
    5
    • 4.1
      Chi-Square Goodness of Fit
      50 mins
    • 4.2
      Chi-Square Tests for Two-Way Tables
      50 mins
    • 4.3
      Inference for the Slope of a Regression Line
      50 mins
    • 4.4
      Choosing the Right Procedure and Writing It Up
      50 mins
    • 4.5
      Capstone — Full Statistical Inference Study
      200 mins

Chi-Square Tests for Two-Way Tables

Unit 4  ·  Data Investigation Lab  ·  Lesson 17 of 20

Chi-Square Tests for Two-Way Tables

PS.19RLP-STATSB
Hands sort paired rainy-or-dry weather tokens into four cells, revealing strong rain persistence.
By the end of this lesson I can…

carry out chi-square tests of independence and homogeneity on two-way tables, compute expected counts, and connect the 2 × 2 case to the two-proportion z-test.

Instruction

In RLP Statistics A (G.CP.A.4) you judged independence in a two-way table by comparing conditional proportions. The chi-square test turns that judgment into a test.

Two versions, one computation. A test of independence takes one sample and classifies each case by two categorical variables: are the variables associated? A test of homogeneity takes separate samples from several groups: is the distribution of one categorical variable the same in every group? The arithmetic is identical. The design, and so the wording of the hypotheses, differs.

Expected counts. If the variables are independent, each cell’s expected count is

E = (row total × column total) / grand total

and df = (rows − 1)(columns − 1).

Example 1: the 2 × 2 persistence table. St. Louis winters (December-February) 2000-2024, NOAA daily data, with each day paired with the day before (2,256 pairs):

Rain todayDry todayTotal
Rain yesterday294 (E 210.4)394 (E 477.6)688
Dry yesterday396 (E 479.6)1,172 (E 1,088.4)1,568
Total6901,5662,256

For example, E for the first cell is 688 × 690/2,256 ≈ 210.4. Every cell is off by about 84 from its expectation, and χ2 = Σ(O − E)2/E ≈ 68.8 with df = 1. P is effectively zero. Rain today is strongly associated with rain yesterday.

The link to z. The two-proportion z-test in Lesson 3.4 gave z ≈ 8.29 for the same data, and 8.292 ≈ 68.8. For a 2 × 2 table, the chi-square test and the two-sided two-proportion z-test are the same test. The z-test can also be one-sided and gives a confidence interval for the difference, so it is usually more informative.

Example 2: a 3 × 2 table with a dose-response pattern. Split “rain yesterday” by amount:

YesterdayRain todayDry todayP(rain today)
Dry3961,1720.253
Light (0.01-0.24 in)1742840.380
Heavy (0.25 in or more)1201100.522

χ2 ≈ 83.3, df = (3 − 1)(2 − 1) = 2, P far below 0.001. The conditional proportions tell the story the P-value cannot: the more it rained yesterday, the more likely rain is today. A dose-response pattern like this is one of the signs, discussed in RLP Statistics A, that an association may reflect a real mechanism. Here the mechanism is storm systems that last for days.

Conditions. Random sampling or independent observations, and all expected counts at least 5 (all are here: the smallest is 70.3). As before, consecutive days are not independent draws, which makes the P-value too small. With effects this large, the conclusion stands, but a report should say so.

After a significant result, report the conditional proportions (A1.DS.A.4 / A1.DS.A.4a / A1.DS.A.4b) and the largest contributions to χ2. “Associated” is the conclusion. The proportions show the direction and size.

Tools. Spreadsheet: build the expected table with formulas, then =CHISQ.TEST(observed, expected) for the P-value. CODAP: put one variable on each axis of a graph to see the two-way table. Python (optional): scipy.stats.chi2_contingency in JupyterLite.

📖 Read for this lesson

The reading opens over the lesson; close it to come back to exactly where you were. The checks below draw on it.

  • A Two-by-Two from a Randomized Trial, and a Two-by-Two That Fails Its Conditions1954 poliomyelitis vaccine field trial, paralytic-case counts as reported by Francis et al., American Journal of Public Health 45 (1955), supplement; NOAA NCEI GHCN-Daily, station USW00013994 (St. Louis Lambert International Airport), PRCP, 2000-2024; retrieved 2026-11-10 · about 4 min

    A two-way table from a randomized trial, so homogeneity is something you have tested rather than defined, with chi-square = z-squared checked on it; and the real St. Louis table of heavy-rain days, whose expected count of 1.7 fails the condition.

Vocabulary in context

  • test of independence — A chi-square test of association between two categorical variables measured on one sample.
  • test of homogeneity — A chi-square test of whether several populations have the same distribution of a categorical variable.
  • expected count (two-way) — (row total × column total) / grand total, the count expected if the variables are independent.
  • dose-response — A pattern in which a larger amount of an explanatory variable goes with a steadily larger response.

Formative check

Work through these before moving on. They are not graded — they tell you whether the standard below has landed yet.

Fill in the blank

The expected count for ‘rain yesterday, rain today’ is 688 × 690 / 2,256 ≈ ; the 3 × 2 table has df = .

+50 XP

For the 2 × 2 persistence table, χ² ≈ 68.8 and the two-proportion z ≈ 8.29. How are they related?

8.29² ≈ 68.8. The z version adds the option of one-sided tests and an interval for the difference.

Simulation & tools

Build the persistence table from raw daily data

Data: NOAA NCEI GHCN-Daily, St. Louis Lambert International Airport (USW00013994), 2000-2024 (import URL from Unit 1). In CODAP or a spreadsheet:

  1. Add rain = PRCP ≥ 0.01 and rain_yesterday (in a spreadsheet, the previous row’s rain; in CODAP, prev(rain)). Add month and keep December-February.
  2. Make a graph with rain_yesterday on one axis and rain on the other to get the two-way counts. Check them against 294, 394, 396 and 1,172.
  3. Compute expected counts and χ2 in a spreadsheet, and the P-value with CHISQ.TEST.
  4. Repeat with heavy = PRCP ≥ 1.5 for all months. Is heavy rain also persistent? Check the expected counts condition first. Heavy rain is rare, even in St. Louis.

Choose one route. All three earn full credit and all three end in the same two chi-square tests.

  • Route 1 — build the tables from the raw data, as steps 1-4 describe.
  • Route 2 — work from the tables printed in this lesson. No internet needed. Compute all four expected counts, the four contributions, χ2 and df by hand for the 2 × 2 winter table, then all six for the 3 × 2 table. You should recover χ2 ≈ 68.8 on 1 df and χ2 ≈ 83.3 on 2 df.
  • Route 3 — work from the printed heavy-rain table below, a real table built from the same NOAA file (each day from January 2, 2000 to December 31, 2024 paired with the day before, a “heavy” day being 1.5 inches or more of rain). It is here so that step 4’s question can be answered without a download, and so that you meet a table where the conditions fail.
    All-year pairsHeavy todayNot heavy todayTotal
    Heavy yesterday13112125
    Not heavy yesterday1128,8949,006
    Total1259,0069,131
    Check your work: the expected count in the top-left cell is 125 × 125/9,131 ≈ 1.71, far below 5, so the expected-counts condition fails and no P-value from this table can be trusted. Report that as your answer. If you compute the statistic anyway you will get χ2 ≈ 76.6 on 1 df, almost all of it (74.5) from that one tiny-expectation cell, which is exactly the way the test misbehaves when a cell is nearly empty. The conditional proportions are still worth reporting: 13/125 ≈ 0.104 after a heavy day against 112/9,006 ≈ 0.0124 after any other day.

Open in a new tab ↗  ·  CODAP, Concord Consortium · MIT open source

For the 3 × 2 table, compute all six expected counts and contributions, confirm χ² ≈ 83.3, and identify the two largest contributions. Then write a four-sentence conclusion that reports the conditional proportions, names the dose-response pattern, and states one reason the P-value is too small to take literally.

0 words
Quick self-check

How confident are you that you can carry out and interpret chi-square tests on two-way tables and connect them to two-proportion tests?

Not yetVery confident

Practice

Work these on paper or in your notebook, then open Check your answer. Aim for all of Fluency and Application; try at least one Challenge.

Printable version: this unit’s practice workbook (PDF)

Fluency

Build speed and accuracy with the core skill.

  1. A table has 3 rows and 4 columns. What are the df for a chi-square test of independence?
    Check your answer
    Answer: 6.
    (3 − 1)(4 − 1).
  2. Row total 688, column total 690, grand total 2,256. Find the expected count.
    Check your answer
    Answer: ≈ 210.4.
  3. Independence or homogeneity? One random sample of students is classified by grade and by preferred study time.
    Check your answer
    Answer: Independence.
  4. Independence or homogeneity? Separate random samples from three high schools are asked the same yes/no question.
    Check your answer
    Answer: Homogeneity.
  5. For a 2 × 2 table, how is χ² related to the two-proportion z statistic?
    Check your answer
    Answer: χ² = z².

Application

Use the skill in context. Show your reasoning.

  1. Springfield winter persistence table (2000-2024): rain-rain 234, rain-dry 350, dry-rain 353, dry-dry 1,319. Carry out the chi-square test of independence, with the expected counts.
    Check your answer
    Answer: Expected: 152.0, 432.0, 435.0, 1,237.0; χ² ≈ 80.8, df = 1, P far below 0.001. Rain today is strongly associated with rain yesterday at Springfield, as at St. Louis.
  2. Springfield winter days by yesterday’s rain (dry / light 0.01-0.24 in / heavy ≥ 0.25 in) and today’s (rain / dry): dry 353, 1,319; light 126, 241; heavy 108, 109. Test for association and describe the pattern with conditional proportions.
    Check your answer
    Answer: χ² ≈ 97.7, df = 2, P far below 0.001. P(rain today) ≈ 0.211 after a dry day, 0.343 after a light-rain day and 0.498 after a heavy-rain day: a dose-response pattern.
  3. Kansas City, July-August 2000-2024: 90°F or above yesterday & today 466; yesterday, not today 182; not yesterday, 90°F or above today 179; neither 723. Test whether hot days are independent of the previous day, and explain what this means for any binomial model of hot days.
    Check your answer
    Answer: χ² ≈ 420.8, df = 1, P far below 0.001. P(90°F or above | 90°F or above yesterday) ≈ 0.719 against 0.198 after a cooler day. Hot days are strongly dependent, so a binomial model that assumes independent days will understate how often hot spells and cool spells occur.
  4. Rainy days by season, 2000-2024 (Dec-Feb, Mar-May, Jun-Aug, Sep-Nov): St. Louis 690, 866, 691, 599; Springfield 587, 838, 674, 590. Test whether the two stations have the same seasonal distribution of rainy days.
    Check your answer
    Answer: χ² ≈ 4.60, df = 3, P ≈ 0.204. Proportions in each season: St. Louis 0.242, 0.304, 0.243, 0.210; Springfield 0.218, 0.312, 0.251, 0.219. No convincing difference in the seasonal pattern.
    Test of homogeneity on counts of rainy days (the days are not independent, so treat the P-value as approximate).

Challenge

Stretch problems. Expect to think before you write.

  1. A student converts a two-way table of counts to percentages before computing χ². What goes wrong, and why?
    Check your answer
    Answer: χ² depends on the sample size: (O − E)²/E scales with the counts. Using percentages (as if n were 100) gives the wrong statistic, usually far too small for large samples or too large for small ones.

Review

Keep earlier skills sharp.

  1. (Unit 3) Two-proportion z-test: 294/688 against 396/1,568. Find the pooled proportion.
    Check your answer
    Answer: 0.3059.
  2. (RLP Statistics A) From a two-way table, how do you check independence?
    Check your answer
    Answer: Compare a conditional proportion with the overall proportion (or P(A and B) with P(A)P(B)).

Missouri Learning Standards — Mathematics (data and probability) addressed: A1.DS.A.4, A1.DS.A.4a, A1.DS.A.4b, G.CP.A.4, MP.5, MP.7

Extends beyond Missouri Statistics (enrichment): content Missouri places after Statistics

Instructional focus: Chi-square tests of independence and homogeneity on real two-way tables

Reading

A Two-by-Two from a Randomized Trial, and a Two-by-Two That Fails Its Conditions

1954 poliomyelitis vaccine field trial, paralytic-case counts as reported by Francis et al., American Journal of Public Health 45 (1955), supplement; NOAA NCEI GHCN-Daily, station USW00013994 (St. Louis Lambert International Airport), PRCP, 2000-2024; retrieved 2026-11-10 · SLS original, with published trial figures and public domain NOAA data

Why this reading. The lesson’s two tables are printed and its open question can be answered from them. What the lesson lacks is a two-way table from a designed study, so that the difference between a test of independence and a test of homogeneity is a difference you have met in data rather than in a definition. The 1954 polio vaccine trial is that table, and it is the same 2 × 2 the two-proportion z-test handles, so the χ2 = z2 identity can be checked on it. Then the real St. Louis table of heavy-rain days that the lesson’s Route 3 works from, with its failing expected count worked in full.

Table 1. The 1954 poliomyelitis vaccine field trial, randomized arm

In 1954, in parts of the United States where health authorities agreed to it, children in grades 1 to 3 whose parents consented were assigned at random to receive Salk vaccine or a saline placebo, with neither families nor diagnosing physicians told which. Cases were counted through the polio season. The figures below are the paralytic-polio counts as reported by Thomas Francis Jr. and colleagues in their 1955 evaluation; they are the figures reproduced in this course’s Algebra 2B reading on study design.

Randomized, placebo-controlled armParalytic polioNo paralytic polioTotalRate per 100,000
Vaccinated33200,712200,74516.4
Placebo115201,114201,22957.1
Total148401,826401,97436.8

This is a test of homogeneity: two groups formed by the design, one categorical response, and the question is whether the distribution of that response is the same in both. H0: the proportion developing paralytic polio is the same for vaccinated and placebo children. Expected counts, E = row total × column total / grand total:

Expected under H0Paralytic polioNo paralytic polio
Vaccinated73.91200,671.09
Placebo74.09201,154.91

Every expected count is above 5, and random assignment gives independence within the design. Contributions:

Contribution (O − E)2/EParalytic polioNo paralytic polio
Vaccinated22.640.0083
Placebo22.590.0083

χ2 = 45.25, df = 1. Table 3 of the critical-values reading gives 10.83 at the 0.001 tail; P is about 2e-11. Notice where the statistic lives: almost all of it in the two small cells. The two huge “no polio” cells contribute 0.0167 between them, because a discrepancy of 41 against an expectation of 200,000 is nothing. The two-proportion z: pooled p̂ = 148/401,974 = 0.000368; z = (0.000164 − 0.000571)/√(0.000368(1 − 0.000368)(1/200,745 + 1/201,229)) = -6.73, and -6.732 = 45.25. Same test.

The conclusion and its scope. Because assignment was random, the association is causal: the vaccine reduced paralytic polio in these children, by 1 − 16.4/57.1 = 71%, with the effect size stated as the rate ratio or as the difference of 40.7 cases per 100,000. The trial did not randomly select children from the country, so generalizing to all children was an argument about similarity, and it was made: the vaccine was licensed the day the results were announced. Compare the observed-control arm of the same trial (vaccinated second-graders against unvaccinated first- and third-graders, 38 of 221,998 against 330 of 725,173, χ2 = 35.3), where the same arithmetic runs on groups nobody assigned, and the conclusion has to stop at “associated”.

Table 2. The real St. Louis heavy-rain persistence table

The lesson’s Route 3 prints this table. It is a real one, built from the same NOAA file as the winter table (St. Louis Lambert International Airport, GHCN-Daily PRCP): each day from January 2, 2000 to December 31, 2024 paired with the day before it, with a “heavy” day defined as 1.5 inches or more of rain. Heavy days are rare (125 of 9,131), which is what breaks the conditions. Retrieved 2026-11-10.

All-year pairs, 2000–2024Heavy rain todayNot heavy todayTotalP(heavy today)
Heavy rain yesterday131121250.104
Not heavy yesterday112889490060.0124
Total125900691310.0137

Expected count for the heavy–heavy cell: 125 × 125/9,131 = 1.71. The condition fails: an expected count of 1.71 is below 5, and no P-value from this table is trustworthy. Computed anyway, χ2 = 76.6 on 1 df, 74.5 of it from that one cell. The conditional proportions remain worth reporting and are the honest result: heavy rain followed heavy rain on 13 of 125 occasions (0.104) and followed a day that was not heavy on 112 of 9,006 (0.0124), about 8 times as often. A 2 × 2 table with a rare event needs either more data or a different procedure (an exact test), and the right report says so.

Independence or homogeneity?

TableHow the data aroseWhich testH0 in words
Winter persistence (lesson)One record; every day classified by yesterday’s rain and today’sIndependenceToday’s rain is independent of yesterday’s
Polio trialTwo groups created by random assignment; response recorded in eachHomogeneityThe polio rate is the same in both treatment groups
Heavy-rain persistenceOne record, two classificationsIndependence (conditions fail)Today’s rain is independent of yesterday’s

The arithmetic is identical; the wording of the hypotheses and, above all, the scope of the conclusion are not. Random assignment is what turns “associated” into “caused”, and no chi-square statistic, however large, does that on its own.

Sources: NOAA NCEI, Daily Summaries (GHCN-Daily) data search (ncei.noaa.gov); NOAA NCEI Access Data Service (the query used here) (ncei.noaa.gov); University of Michigan School of Public Health, the 1955 polio vaccine trial announcement (sph.umich.edu)

Up NextComplete & Continue →

Leave a Reply Cancel reply

Chi-Square Goodness of Fit
Prev
Inference for the Slope of a Regression Line
Next

© 2026 The VR School | Career content by Wiley | Powered by Sejal Learning Systems.

Join free · Accreditation · Privacy Policy · Terms of Service

Modal title

Main Content