OttoLearn

L-REG-4: Solutions — Chi-Square Test of Independence

Module 5 · Regression & Association

How to use this page: Try each problem in the lesson before checking solutions here. If your answer doesn't match, read the solution carefully — especially the part that explains why common wrong answers are wrong. Understanding the error matters more than getting the right answer the first time.

← Back to Lesson L-REG-4

Section 4: Worked Examples Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

Critical values are rounded to three decimals, expected counts to two; values written with are rounded, and every decision is made at full precision.

Example 1 — Smoking and Exercise

The complete five-step solution is in the lesson: with , above 3.841, so reject (); , small.

Example 2 — Commuting by Age

Expected counts :

CarTransitBike or walk
Under 3567.8553.3118.85
35 and over58.1545.6916.15

The smallest is ; the sample is random. Contributions : 3.701, 1.110, 3.528 / 4.318, 1.295, 4.116.

: reject (). There is enough evidence of an association between age group and main way to work; younger commuters bike or walk more and drive less than no link would predict. , small. A survey, so association only.

Example 3 — Cramér’s V

, so : medium.

Example 4 — A Test That Should Not Have Run

and are below 5, so the chi-square approximation is unreliable: combine categories that belong together or use Fisher’s exact test. And even a valid non-significant test says “not enough evidence of an association”, never “independent”.

Section 5: Guided Practice Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

Problem 1 — Reading a Two-Way Table

Compare the rows as percentages: the share of the first row in a column against the share of the second row in the same column. One cell on its own, the row totals, or “are the counts equal?” cannot show a link, because “no link” means the rows split in the same proportions, not that the counts are equal.

Each cell is , to two decimals. Worked instance: 238 students, rows First year 97 and Upper year 141; columns Library 88, Home 104, Café 46.

LibraryHomeCafé
First year35.8742.3918.75
Upper year52.1361.6127.25

Each row adds back to its total (97 and 141) and each column to its total. Two typed values have their own feedback: (an equal split: “no link means equal counts”) and (the row total used twice).

Problem 3 — May the Test Run? How Many Degrees of Freedom?

Condition. The expected counts are shown. The test may run only if every one is at least 5; the observed counts and the sample size do not decide it. The smallest expected count is always the smallest row total times the smallest column total, over . If it is below 5: combine categories that genuinely belong together, or use an exact test.

Degrees of freedom. : 1 for a table, 2 for or , 4 for . The typed values , , and each have their own feedback.

Problem 4 — Reading the Chi-Square Table

(a) . (b) . (c) but : reject at 0.05, fail to reject at 0.01. (d) In the row, , so .

Problem 5 — The Full Five-Step Test

The table is one of six curated tables. Hypotheses about independence; the smallest expected count (all are at least 5); to three decimals (adding contributions rounded to three or four decimals is also accepted); and ; then “sufficient” or “insufficient evidence of an association”, never “independent” and never “causes”.

Section 6: Independent Practice Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

The table, the sample size (80 to 400, never a multiple of 5) and the significance level (, or , stated before the data) all change.

  1. Hypotheses. : the two variables are independent; : they are not.
  2. Condition. Compute every expected count. In about one table in six, one is below 5: then the right report is “no χ² p-value from this table: combine categories or use an exact test”, and the problem stops there.
  3. Statistic. , to three decimals. Sums of contributions rounded before adding, or computed from expected counts rounded to two decimals, are also accepted.
  4. df and the critical value. ; read the row and the column of the stated .
  5. Decision. Reject when is above the critical value.

Worked instance. 238 students, :

LibraryHomeCaféRow total
First year41371997
Upper year476727141
Column total8810446238

Expected counts as in §5 Problem 2 (smallest 18.75). Contributions: 0.735, 0.684, 0.003 / 0.506, 0.471, 0.002, so ; and . Since , fail to reject (software: ).

A table that may not be tested. 118 commuters with column totals 61, 48 and 9, row totals 54 and 64: the smallest expected count is , below 5. Stop, whatever would come out as.

Problem 2 — What May the Report Say?

Five blanks: the critical value (the row , the column of the stated ); whether is above or below it; the decision (“accept” is never right); “enough” or “not enough evidence of an association” (“evidence that there is no association” is never right); and the design. In a survey, an association cannot by itself show that one variable affects the other. In a randomized experiment, where one variable was randomly assigned, an association can be read as its effect. The test is the same in both: the design decides.

For the 238 students at : critical value 4.605 (2 degrees of freedom); is below it; fail to reject; not enough evidence of an association; a survey, so even a link would not show cause.

Problem 3 — Find the Error

The workflow item corrupts one of five claims: df written as , dividing by instead of , checking the observed counts instead of the expected ones, “accept : independent”, or “causes”. The conclusion item corrupts the decision (backwards against the critical value), or the conclusion (“independent” after failing to reject, or “causes” after rejecting a survey result).

Problem 4 — How Strong?

with , to three decimals; the tables span all four bands. Worked instance: a table with and : , so , small. Typed values with their own feedback: without the root, , and .

Problem 5 — Which Analysis Fits?

Classify both variables first. Two categorical variables call for a χ² test (postal-code region and grocery chain; a 1–5 satisfaction label and campus; blood type and flu; area code and carrier). Two quantitative variables call for correlation and regression (sleep and exam score; weight and fuel use; temperature and cones sold; experience and salary). One of each needs another method (smoking and lung capacity; jersey number and points; province and rent; coffee size and minutes). Codes, labels and jersey numbers are categories even when they are written as numbers.

Problem 6 — Association or Cause?

A significant χ² from a survey shows association. Some cases have a lurking variable (stress behind coffee and insomnia; age behind gaming and glasses; hot weather behind ice cream and drownings); others have reverse causation (income makes owning a car affordable; people who are overweight may switch to diet soda; struggling students sign up for tutoring).

Problem 7 — Pooled or Split?

Severe cases: A , B . Mild cases: both 90%. A looks better pooled (78% against 73%) only because 80 of its 100 patients were mild cases, which recover more often whatever the treatment: severity is a lurking variable. The records suggest B is no worse, but because doctors chose the treatment, only a randomized trial would compare the treatments fairly.

Problem 8 — Physical Activity and Stress

Expected counts 21.54, 26.92, 21.54 / 18.46, 23.08, 18.46, all at least 5. , , above 5.991: reject (). , small. The reply: evidence of an association, of small strength; a requirement for every employee would need evidence of an effect (a randomized study) and of its benefits, harms and costs.

Mixed Review

Review 1 (L-INF-5). is right-sided because the suspicion came before the data. , compared with . Each context keeps realistic values (a city’s mean commute between 24 and 40 minutes, weekly study hours between 12 and 22).

Review 2 (L-INF-6). Two-sided; check and with the claimed ; , compared with 1.960.

Section 7: Mastery Check Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

Question 1 — Feynman Test

The model answer is in the lesson: a p-value measures evidence against independence, not strength; grows with , so report Cramér’s V too.

Question 2 — Expected Counts, and May the Test Run?

(a) Each cell to two decimals, as in §5 Problem 2; about one table in six has an expected count below 5 (the explanation says so). (b) Compute the smallest expected count yourself: the smallest row total times the smallest column total, over . At least 5: the test may run. Below 5: combine categories or use an exact test.

Question 3 — The Statistic and Its Degrees of Freedom

Solve on paper, then type to three decimals; the steps, if you open them, ask for the condition, , , the critical value at the stated , and the decision. The worked instance in §6 Problem 1 shows the method.

Question 4 — The Conclusion

As in §6 Problem 2: critical value, comparison, decision, evidence, design. The study design (survey or randomized experiment) is stated in the stem.

Question 5 — Which Analysis?

Classify both variables. A department number, a postal code or a rating used as a label is categorical; a measured amount is quantitative. Two categorical: χ² test. Two quantitative: correlation and regression. One of each: neither, in this module.

Section 8: Boss Fight Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

Path A — The Admissions Audit

The college is fictional and its records are generated. Worked instance:

Men (admitted / applied)Women (admitted / applied)
Programme X180 / 30032 / 50
Programme Y20 / 10055 / 250
Both programmes200 / 40087 / 300
  1. The pooled gap. Sex and admission are both categorical: a χ² test on the table. , , far above 3.841 (; ). Not chance.
  2. Inside each programme. X: 60% of men and 64% of women, . Y: 20% of men and 22% of women, . Neither is significant, and women’s rates are higher in both.
  3. Who applied where. 250 of the 300 women (83%) applied to Y, which admits about one applicant in five of either sex; most men applied to X, which admits most. The programme is a lurking variable: Simpson’s paradox, as at Berkeley.
  4. Verdict. No sign of a gap in the admission decisions; the records cannot by themselves prove or rule out bias in individual files.

In about one college in three, programme Y also admits women at a significantly lower rate: then part of the pooled gap is real, and Y’s decisions deserve a closer look.

Path B — The Fact-Checker

Claim 1 (a correlation on codes). The numbers only label categories, so means nothing: changing the codes would change it. Test the table with a χ² test. For example, region codes 1–3 against two grocery chains with counts 34, 28 / 41, 22 / 19, 37 (): , , above 5.991, so reject .

Claim 2 (a huge sample, a “strong link”). . For example, from a table with : , negligible. The link is real, but “strong” is wrong: the sample is huge.

Claim 3 (a cause from a survey). The data show an association; because they are observational, they cannot show cause. The clearest alternative is named in the claim’s context: a lurking variable (regular routines behind breakfast and grades; hot weather behind ice cream and drownings) or reverse causation (back pain keeping people from standing desks; struggling students signing up for tutoring).

Section 9: Challenge Problems Solutions

▾

A tag such as (C2 + C3) after a title names the Core Concepts parts the problem draws on, so you know where to look back.

Challenge 1 — The Same Percentages, a Bigger Survey

: 8.333 at , 16.667 at 400, 33.333 at 800. at every size. Every test rejects at 0.05, but the strength never changes: report V beside .

Challenge 2 — A 3×3 Table

, , far above 9.488; : small with the standard bands, medium with the bands for . The full solution is in the lesson.

Challenge 3 — The Lady Tasting Tea

All expected counts are : no χ² test. If she were guessing, each of the ways to choose four cups would be equally likely, so : evidence she can tell (Fisher’s exact test).

← Return to Lesson L-REG-4