11.4 Test for Homogeneity

A new question answered by an existing procedure. A goodness-of-fit test can decide whether a population fits a given distribution, but it cannot decide whether two populations follow the same unknown distribution — and that second question is often the one that matters, since a researcher comparing men with women or before with after usually has no external distribution to test against. The test for homogeneity fills the gap, and the book is explicit that its statistic is computed exactly as the test of independence's: expected counts from the margins, the same sum of squared departures, the same right tail, the same requirement of at least five per cell. The hypotheses are worded about two populations having the same distribution, the degrees of freedom are the number of columns minus one for the usual two-population case, and the conclusion is only that the distributions differ — never how.

Subject: Statistics · 67 slides · symbolic lesson

Open the interactive version of this deck

What this lesson covers

The lesson, slide by slide

1. Test for Homogeneity

Title

Statistics · Chapter 11 — The Chi-Square Distribution

Do two populations share the same distribution? The independence arithmetic, asked a different question

2. What this lesson gives you

Objectives

Section 11.2 tested one sample against a distribution somebody claimed. Section 11.3 tested whether two variables measured on one sample are related. This section asks a third question, and it is the one researchers ask most often: do two populations, sampled separately, have the same distribution?

Nothing in this section is new arithmetic. The marks are lost on wording and design: hypotheses written about variables instead of populations, a conclusion that claims to know how two groups differ, and a test chosen from the shape of a table instead of from how the data were collected. Each of those has its own slide.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 578-581 — the section this deck covers

3. Before anything new: an expected count from the margins

Warm-up

Section 11.3 ended with Example 11.7: 400 De Anza students classified by need to succeed and by anxiety level. The independence test's expected count came from the row total, the column total and the grand total. Recall it now, because this whole section reuses it.

high anxietymed-low anxietyrow total
high need35155
low need1552
column total5763400

Discussion prompt

If need and anxiety are independent, how many students would you expect to have a high need and a high anxiety level? And how many a low need and a med-low anxiety level?

Keep that formula in hand. A test for homogeneity builds its expected counts in exactly this way, sums exactly the same terms, and reads exactly the same right tail. What changes is the question the numbers answer, and therefore the words you are allowed to write at the end.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.3, p. 578 — Example 11.7

4. The gap this test fills

Section

Part 1

5. What goodness of fit can decide, and what it cannot

Concept

The book opens the section with one precise sentence. The goodness-of-fit test can decide whether a population fits a given distribution, but it will not suffice to decide whether two populations follow the same unknown distribution.

Look at the word given. A goodness-of-fit test needs a yardstick written down in advance: equal shares, national percentages, a binomial model. Every expected count was a known proportion times the sample size.

\[ \text{goodness of fit: } E_i = n \cdot p_i, \quad p_i \text{ known in advance} \]

Figure (svg): Two panels of bar charts. Left, titled goodness of fit: orange bars for the share of 600 far-western families with 0, 1, 2, 3 and 4 or more streaming services, beside dashed blue outline bars for the claimed national percentages 10, 16, 55, 11 and 8. Right, titled homogeneity: cyan bars for the share of 250 men in dormitories, apartments, with parents and other, beside orange bars for the share of 300 women. The left panel has a known yardstick; the right panel has only two samples.

On the left, one sample is held up against a distribution somebody published. On the right there is nothing to hold either sample against: the only question is whether the two bar patterns are the same pattern.

Now look at the right-hand panel. Men and women college students each have some distribution of living arrangements, but nobody has published either one. There is no yardstick. All you have is two samples, and the only sensible question is whether they came from populations with the same pattern.

\[ \text{homogeneity: } H_0: \text{ population 1 and population 2 have the same distribution} \]

The word homogeneity means sameness of kind. The test asks whether two populations are homogeneous, the same in distribution, without ever needing to know what that common distribution is.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 578 — the opening paragraph of the section

6. Example 11.8: two samples, one question

Concept

Here is the book's first example. 250 randomly selected men college students and 300 randomly selected women college students were asked about their living arrangements. Each answered with one of four categories.

dormitoryapartmentwith parentsothertotal
men72844945250
women91868835300

Notice how the table was made. The researchers decided in advance to sample 250 men and 300 women, so the row totals were fixed before any student answered. The column totals, by contrast, came out of the data.

The question is whether men and women college students have the same distribution of living arrangements. It is about two populations, all men college students and all women college students, not about these 550 people. So the hypotheses name the populations.

\[ H_0: \text{ the distribution of living arrangements is the same for men and women} \]

\[ H_a: \text{ the distribution of living arrangements is not the same} \]

Raw counts are hard to compare here because the groups are different sizes: 91 women in dormitories against 72 men tells you little when there are 50 more women. The next slide turns each row into percentages of its own group.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8, Table 11.19

7. Men and women, as percentages of their own group

Picture it

Divide each count by its row total and the two groups become comparable. A distribution is a set of percentages, so this is the picture the null hypothesis is really about.

\[ \text{men in dormitories: } \frac{72}{250} = 0.288, \qquad \text{women: } \frac{91}{300} = 0.303 \]

Figure (svg): Grouped bar chart of living arrangements as percentages of each group. Dormitory: men 28.8 percent, women 30.3 percent. Apartment: men 33.6, women 28.7. With parents: men 19.6, women 29.3. Other: men 18.0, women 11.7.

Dormitories look alike. The visible differences are with parents, where women run about ten points higher, and other, where men run about six points higher.

If the null hypothesis were true, the cyan and orange bars would be the same height in every category, apart from the ordinary wobble of random sampling. They are close for dormitories, about one and a half points apart.

Elsewhere the gaps are bigger. Women live with parents at 29.3 percent against the men's 19.6; men fall into the other category at 18.0 percent against 11.7. Your eye says these look different. The test's job is to say whether gaps this large are bigger than two random samples of 250 and 300 would usually produce when the populations really match.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8

8. Eyeball it before the test

Estimation

Before computing anything, use the picture. You have seen two samples of a few hundred differ by about ten percentage points in one category and six in another.

Predict first

With 250 men and 300 women, gaps of about ten points with parents and six points in other, roughly where will the p-value land?

  • a few percent: near the 5 percent line
  • above one half
  • below one in a million
  • exactly zero

Correct: a few percent: near the 5 percent line

Why: For a few hundred people a percentage wobbles by about three or four points, so a ten-point gap is between two and three standard errors. That is suspicious but not overwhelming, which puts the p-value in the region of a few percent. The book's answer is 0.0175.

\[ SE \approx \sqrt{0.25 \cdot 0.75 \left(\frac{1}{250} + \frac{1}{300}\right)} \approx 0.037 \]

The rough standard error comes from Chapter 10's two-proportion test, using a shared proportion of about one quarter for the with-parents category. Ten points is about 2.6 of those, which is unusual but nowhere near impossible.

An estimate like this is the best protection against a wrong curve or a slipped decimal later. If your final p-value had come out as 0.6 or as 0.000001, something would need rechecking.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-580 — Example 11.8

9. Trap: one sample used as the known distribution

Trap

The trap

No distribution is given, so a first attempt borrows one. It takes the women's percentages as the truth and runs a goodness-of-fit test on the men:

\[ E_{\text{men}} = 250 \cdot \frac{91}{300}, \; \ldots \]

\[ = 75.83, \; 71.67, \; 73.33, \; 29.17 \]

\[ \chi^2 = 18.99, \; df = 3, \; p = 0.0003 \]

Wrong. It treats the women's sample percentages as if they had no error at all.

The fix

Both samples wobble. The homogeneity test pools them and charges both for sampling error:

\[ \chi^2 = 10.13, \; df = 3, \; p = 0.0175 \]

The borrowed yardstick made the evidence look sixty times stronger than it is. Which group was chosen as the standard would change the answer too, a sure sign the method is wrong.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 578 — two populations, unknown distribution

10. The book's summary of the test

Concept

The book gathers the whole test into one box. Read it as a checklist; every part except the hypotheses and the uses is borrowed from section 11.3.

partwhat the book sayswhere it comes from
hypothesesH₀: the distributions of the two populations are the same. Hₐ: they are not the same.new to this section
test statistica χ² statistic, computed the same way as the test of independence§11.3, unchanged
degrees of freedomdf = number of columns − 1the two-row case of (r − 1)(c − 1)
requirementevery expected count at least five§11.2 and §11.3, unchanged
common usesmen vs women, before vs after, east vs westtwo populations compared

The common uses all share one shape: two groups compared with each other, not against an outside standard. The book adds that the variable is categorical with more than two possible response values. With exactly two values, such as yes or no, Chapter 10's two-proportion test would do the job and say which group is higher; Part 4 shows the two tests then agree exactly.

One line in the box needs care. The book's NOTE says the expected value for each cell must be at least five; its Requirements line says all values in the table. The condition is on the expected counts, as in every chi-square test. An observed count of 3 is no problem.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — hypotheses, statistic, df, requirements, common uses

11. Reading the hypotheses

Notation

The hypotheses are short, but every word in them is load-bearing. Hover over each piece before writing your own.

Annotate

On: \( H_0: D_{\text{pop 1}} = D_{\text{pop 2}} \quad \text{vs} \quad H_a: D_{\text{pop 1}} \ne D_{\text{pop 2}} \)

  • A whole distribution: the full set of percentages across every category, not one percentage.
  • Populations, such as all men and all women college students; never the 250 and 300 sampled.
  • Same in every category at once. The null names no particular percentages: the common distribution is unknown.
  • Different somewhere. It does not say in which category, or in which direction, or by how much.

The equals sign in the null says only that the two distributions match each other. It does not say they match any particular list of percentages, which is the whole difference from goodness of fit. That is also why the expected counts will have to be estimated from the data.

The not-equal sign in the alternative is the weakest possible claim of difference. It is satisfied by one category being off by a little, or by every category being off by a lot. Keep that in mind: a rejection proves only this weakest claim, and the book says so explicitly at the end of Example 11.8.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — the hypotheses

12. Homogeneity, or goodness of fit?

Sorting

For each study, decide whether the question compares a sample with a known distribution, or compares two samples with each other. Look for whether a yardstick is given.

Sort into buckets

Sort each study by the test it needs.

homogeneity: two samples, compared
Car types driven by 100 families and by 200 singles; Voter preferences in surveys before and after an earthquake; Majors chosen by samples of East Coast and West Coast freshmen
goodness of fit: one sample, known yardstick
Blood types of 500 donors compared with published national percentages; Whether a die lands equally often on each face; Streaming services of far-western families against the national distribution
h
Two populations are sampled separately and no distribution is given for either. The only question is whether they share one: men against women, before against after, east against west.
g
One sample and a distribution written down in advance: national percentages, or equal shares for a fair die. Expected counts are the sample size times the known proportions.

The streaming-services study is the one that catches people. It does compare the far West with the nation, which sounds like two populations, but the national distribution is published and treated as known. Only the far West was sampled, so it is goodness of fit.

If the national figures had instead come from a second sample, the same question would become a test for homogeneity. The test depends on where the comparison numbers come from, not on the words east and west.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4 and §11.5, pp. 578-582 — when each test applies

13. The arithmetic is unchanged

Section

Part 2

14. If the null is true, both groups share one pooled distribution

Concept

To build expected counts you need to say what the table should look like if the null hypothesis holds. The null says men and women have the same distribution, but it does not say what that distribution is. So estimate it, using everybody.

\[ \hat p_{\text{dorm}} = \frac{72 + 91}{250 + 300} = \frac{163}{550} = 0.2964 \]

This is the same move as the pooled proportion of Chapter 10's two-proportion test: when the null says two groups share a proportion, the best estimate of it combines both samples. Here you do it for every category at once.

\[ \frac{163}{550}, \; \frac{170}{550}, \; \frac{137}{550}, \; \frac{80}{550} = 0.2964, \; 0.3091, \; 0.2491, \; 0.1455 \]

Figure (svg): Three horizontal bars, each split into four coloured segments for dormitory, apartment, with parents and other. Men: 28.8, 33.6, 19.6 and 18.0 percent. Women: 30.3, 28.7, 29.3 and 11.7 percent. Pooled, all 550 students: 29.6, 30.9, 24.9 and 14.5 percent, outlined in yellow.

The pooled bar sits between the two groups in every segment, closer to the women's because there are more women. It is the null hypothesis's single shared distribution, estimated from everybody.

The pooled bar is a weighted compromise. In every segment it sits between the men's and the women's values, nearer to the women's because they are 300 of the 550. Under the null, that pooled distribution is what both groups are drawn from.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 578 — follow the same procedure as with the test of independence

15. From the pooled share to row times column over total

Concept

Now turn the pooled shares into expected counts. Under the null, 29.64 percent of men should be in dormitories, just like everybody else, and there are 250 men.

\[ E_{\text{men, dorm}} = 250 \times \frac{163}{550} \]

Rearrange that product and it is exactly the formula from section 11.3. The row total is the size of this group, and the column total over the grand total is the pooled share of this category.

\[ E = (\text{row total}) \times \frac{\text{column total}}{\text{grand total}} = \frac{(\text{row total})(\text{column total})}{\text{grand total}} \]

\[ E_{\text{men, dorm}} = \frac{(250)(163)}{550} = \frac{40750}{550} = 74.09 \]

That is why the book can say: compute the statistic the same way as the test for independence. The reasoning is different, a pooled distribution applied to each fixed group rather than a product of independent marginal probabilities, but the number that comes out is identical.

Two checks come free. Each row of expected counts adds to its row total, because the pooled shares add to one. Each column adds to its column total, because 250 over 550 plus 300 over 550 is one.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 578-579 — the statistic is computed as in the test of independence

16. Example 11.8: the men's expected counts

Worked example

Build the first row of expected counts. Each is the men's row total, 250, times a column total, divided by the 550 students in the whole table.

Find the margins

Why: the column totals add each category over both groups.

\[ 72 + 91 = 163, \quad 84 + 86 = 170, \quad 49 + 88 = 137, \quad 45 + 35 = 80 \]

Find the grand total

Why: both samples together.

\[ n = 250 + 300 = 550 \]

The column totals are where the data enter the expected counts. Each one pools men and women, so each expected count already contains information from both samples, which is exactly what the null hypothesis of a shared distribution asks for.

Dormitory

Why: row total times column total over the grand total.

\[ E = \frac{(250)(163)}{550} = \frac{40750}{550} = 74.0909 \]

Apartment

Why: the same row total, the next column.

\[ E = \frac{(250)(170)}{550} = \frac{42500}{550} = 77.2727 \]

With parents

Why: column total 137.

\[ E = \frac{(250)(137)}{550} = \frac{34250}{550} = 62.2727 \]

Other

Why: column total 80.

\[ E = \frac{(250)(80)}{550} = \frac{20000}{550} = 36.3636 \]

Every expected count in this row is 250 over 550, about 0.4545, times its column total. That common multiplier is the men's share of the whole table, and it is why the expected mosaic later draws a perfectly straight split line.

Read the with-parents cell in words. If men and women lived the same way, about 62 of the 250 men would live with their parents. Only 49 do, which is the largest shortfall in the men's row and the first hint of where any difference lies.

Check the row adds to 250

Why: the pooled shares add to one, so the expected row must reproduce the men's total.

\[ 74.0909 + 77.2727 + 62.2727 + 36.3636 = 250.0000 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8

17. Example 11.8: the women's expected counts

Worked example

The women's row uses the row total 300 with the same column totals. Compute it directly, then confirm it by a shortcut that needs no multiplication at all.

Dormitory

Why: row total 300, column total 163.

\[ E = \frac{(300)(163)}{550} = \frac{48900}{550} = 88.9091 \]

Apartment

Why: column total 170.

\[ E = \frac{(300)(170)}{550} = \frac{51000}{550} = 92.7273 \]

Expected counts need not be whole numbers. 88.9091 women is an average over many imaginary repetitions of the survey, so keep four decimal places now; rounding to whole students would shift the statistic in its second decimal place.

With parents

Why: column total 137.

\[ E = \frac{(300)(137)}{550} = \frac{41100}{550} = 74.7273 \]

Other

Why: column total 80.

\[ E = \frac{(300)(80)}{550} = \frac{24000}{550} = 43.6364 \]

The smallest expected count in the whole table is the men's other cell, 36.36. Every expected count is far above five, so the chi-square approximation is safe and the test may go ahead.

\[ \min E = 36.36 \ge 5 \]

Check each column against its total

Why: in a two-row table the women's expected count is the column total minus the men's, so subtraction must give the same numbers.

\[ 163 - 74.0909 = 88.9091, \quad 137 - 62.2727 = 74.7273 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8

18. An expected count for you

Fill the middle

Example 11.9 surveyed 430 voters before an earthquake and 636 after, about three candidates. In total 381 of the 1,066 voters preferred Perez. Fill in the expected number of before-voters preferring Perez if preferences did not change.

Fill in the blanks

E = \frac163830153.69 = \frac___}___ = ___

Why: Row total 430 times column total 381 is 163,830, and dividing by the grand total 1,066 gives 153.69. The survey actually found 167, about thirteen more than the null predicts.

Interpret it before moving on. If the electorate's preferences were the same before and after, the pooled Perez share, 381 out of 1,066 or 35.7 percent, would apply to the 430 before-voters, giving about 154. Seeing 167 means Perez did a little better before the earthquake than the pooled figure suggests.

Whether thirteen voters is a real difference or ordinary noise is not decided by one cell. The statistic will weigh this gap together with the gaps in every other cell.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 580-581 — Example 11.9, Table 11.21

19. When an expected count falls below five

Concept

Examples 11.8 and 11.9 had hundreds of people in every column, so the condition was never in doubt. Small studies are different. Suppose a pilot survey had asked only 40 men and 40 women about their living arrangements.

dormitoryapartmentwith parentsothertotal
men12148640
women141212240
total262620880

The other column holds only 8 students. With equal row totals each group expects half of it, and half of 8 is below five, so the chi-square curve cannot be trusted for this table as it stands.

\[ E_{\text{other}} = \frac{(40)(8)}{80} = 4 < 5 \]

The remedy is the one from section 11.2: combine the small category with a neighbour that makes sense alongside it. Apartment and other are both ways of living off campus and away from home, so merge them, adding the observed counts cell by cell.

\[ \text{apartment or other: } 14 + 6 = 20, \quad 12 + 2 = 14, \qquad E = \frac{(40)(34)}{80} = 17 \]

Now every expected count is at least ten, and the table has three columns, so the degrees of freedom drop from three to two. The merged test gives 2.01 on two degrees of freedom, a p-value of 0.37. Merging always costs a column, and with it the ability to see the categories you merged separately.

\[ \chi^2 = 2.01, \quad df = 3 - 1 = 2, \quad p = 0.37 \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — NOTE: the expected value for each cell needs to be at least five

20. Observed against expected, as mosaics

Picture it

A mosaic plot draws a two-way table as a square. Each column's width is its share of all 550 students; each column is split into a men part and a women part by their share of that column.

Figure (svg): Two mosaic plots for Example 11.8. In each, the four column widths are proportional to the column totals 163, 170, 137 and 80. Each column is split into a cyan men part on top and an orange women part below. In the observed plot the split line moves: men are 44 percent of dormitory, 49 percent of apartment, 36 percent of with parents and 56 percent of other. In the expected plot the split is a straight line at 45.5 percent in every column.

Expected counts make every column split in the same proportion as the row totals, 250 to 300. The observed split line wanders; the statistic measures how far.

In the expected mosaic the split line is perfectly straight. Every category is 45.5 percent men, because 250 out of 550 is 45.5 percent, and under the null being a man tells you nothing about where you live.

\[ \frac{E_{\text{men}, j}}{\text{column}_j} = \frac{250}{550} = 0.455 \quad \text{for every } j \]

In the observed mosaic the split line steps up and down: men are only 36 percent of the with-parents column but 56 percent of the other column. The test statistic is a single number measuring how far the observed split line has wandered from the straight one, cell by cell, judged against the expected counts.

This picture is also the reason the independence arithmetic applies. A straight split line means group and category are unrelated, which is exactly what independence means.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8

21. A two-row table has a mirror built in

Concept

Before computing the statistic, notice a property that makes the work shorter and gives you a check. In each column, the observed counts and the expected counts both add to the same column total.

\[ O_{\text{men}} + O_{\text{women}} = E_{\text{men}} + E_{\text{women}} = \text{column total} \]

Subtract, and the two gaps in each column must cancel. Whatever the men's cell has too many of, the women's cell has exactly that many too few.

\[ O_{\text{men}} - E_{\text{men}} = -(O_{\text{women}} - E_{\text{women}}) \]

For the dormitory column of Example 11.8, the men's gap is 72 minus 74.0909 and the women's gap is 91 minus 88.9091: equal size, opposite signs.

\[ 72 - 74.0909 = -2.0909, \qquad 91 - 88.9091 = 2.0909 \]

So in a two-row table the squared gaps come in identical pairs, and the two terms in a column differ only by their denominators. The group with the smaller expected count, here the men, always contributes the larger term. This is also the deep reason the degrees of freedom are only columns minus one: the second row carries no information the first row did not.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8

22. Example 11.8: the statistic, cell by cell

Worked example

The book reports the statistic from a calculator. Build it here so you can see where it comes from. Use the mirror: one gap per column, squared once, divided by two different expected counts.

Find the men's gaps

Why: observed minus expected, dormitory to other; the women's gaps are their negatives.

\[ O - E: \quad -2.0909, \; 6.7273, \; -13.2727, \; 8.6364 \]

Square each gap

Why: the same square serves both cells of the column.

\[ (O-E)^2: \quad 4.3719, \; 45.2562, \; 176.1653, \; 74.5868 \]

Read the signs before squaring them away. The men are short in dormitories and with parents and over in apartments and other; the women show the mirror pattern. Once squared, that direction is gone from the statistic for good.

Divide by the men's expected counts

Why: 74.0909, 77.2727, 62.2727 and 36.3636.

\[ 0.0590, \; 0.5857, \; 2.8289, \; 2.0511 \]

Divide by the women's expected counts

Why: 88.9091, 92.7273, 74.7273 and 43.6364.

\[ 0.0492, \; 0.4881, \; 2.3574, \; 1.7093 \]

Add the men's four terms

Why: the first row's share of the statistic.

\[ 0.0590 + 0.5857 + 2.8289 + 2.0511 = 5.5247 \]

The men's terms are each larger than the matching women's terms by the factor 300 over 250, which is 1.2. That is the mirror at work: same squared gap, denominators in the ratio of the row totals.

Add the women's four terms

Why: the second row's share.

\[ 0.0492 + 0.4881 + 2.3574 + 1.7093 = 4.6040 \]

Add the two rows

Why: eight cells in all.

\[ \chi^2 = 5.5247 + 4.6040 = 10.1287 \]

That matches the book's 10.1287 to every printed digit. Notice that the eight terms are not equally important: two columns supply almost all of it.

Check the gaps and the mirror

Why: each column's two gaps cancel, so the men's four gaps must add to zero as well, because they come from a row whose expected and observed totals are both 250.

\[ -2.0909 + 6.7273 - 13.2727 + 8.6364 = 0.0001 \approx 0 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — Example 11.8: χ² = 10.1287

23. Where Example 11.8's statistic comes from

Picture it

Draw the eight terms as bars, a column at a time, and the structure of the result appears.

Figure (svg): Horizontal stacked bars, one per living arrangement, each made of the men's term in cyan and the women's term in orange. Dormitory 0.06 plus 0.05, total 0.11. Apartment 0.59 plus 0.49, total 1.07. With parents 2.83 plus 2.36, total 5.19, the longest bar. Other 2.05 plus 1.71, total 3.76. Grand total 10.1287.

With parents and other carry almost nine of the ten units. In each column the men's piece is the larger, because the same squared gap is divided by the men's smaller expected count.

The with-parents column contributes 5.19 and the other column 3.76: together almost nine of the 10.13. The dormitory column, where the percentages were almost equal, adds only 0.11.

Notice too that in every column the men's piece is bigger than the women's. The squared gap is the same in both cells, by the mirror, but the men's expected count is smaller because there are fewer men, and a smaller denominator makes a bigger term.

This picture describes where the statistic came from. It is tempting to read it as a finding, men avoid living with parents, but the test itself licenses no such claim. Hold that thought until Part 4, where the book draws the line.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-580 — Example 11.8

24. Example 11.8: p-value, decision and conclusion

Worked example

The statistic is 10.1287. Finish the test at the 5 percent level the book uses, and end with a sentence about all men and women college students.

Count the degrees of freedom

Why: two populations, so columns minus one.

\[ df = 4 - 1 = 3 \]

Before evaluating anything, compare the statistic with its degrees of freedom. A chi-square on three degrees of freedom has mean 3 and standard deviation the square root of 6, about 2.45, so 10.13 is almost three standard deviations above the centre.

Write the distribution and the probability statement

Why: right-tailed, as every chi-square test of counts is.

\[ p\text{-value} = P(\chi^2_3 > 10.1287) \]

Evaluate

Why: a calculator's chi-square cdf from 10.1287 to a huge value on three degrees of freedom.

\[ P(\chi^2_3 > 10.1287) = 0.0175 \]

Figure (svg): A chi-square curve with 3 degrees of freedom from 0 to 16. A dashed red line at 7.815 marks the 5 percent cutoff and a dashed purple line at 11.345 the 1 percent cutoff. A yellow line marks the statistic 10.13, between the two cutoffs, and the area to its right is shaded blue and labelled p-value 0.0175.

The statistic lands past the 5 percent cutoff but short of the 1 percent one. The decision depends on alpha: reject at 5 percent, do not reject at 1 percent.

Compare with alpha

Why: the p-value is below 0.05.

\[ 0.0175 < 0.05 \Rightarrow \text{reject } H_0 \]

The yellow line in the picture sits in the shaded region beyond the 5 percent cutoff of 7.815, so the picture and the p-value tell the same story: the statistic is larger than chance usually produces when the distributions match.

Conclusion, in the book's words: at a 5 percent level of significance, from the data, there is sufficient evidence to conclude that the distributions of living arrangements for men and women college students are not the same. Notice what it does not say: nothing about who lives where.

The p-value has a closed form on three degrees of freedom, so you can confirm the calculator by hand. It uses the standard normal tail at the square root of the statistic.

Verify the p-value by hand

Why: the df-3 tail is twice the normal tail beyond the square root of x, plus a correction term.

\[ 2(1 - \Phi(3.1826)) + \sqrt{\tfrac{2(10.1287)}{\pi}}\,e^{-5.0644} = 0.0015 + 0.0160 = 0.0175 \;\checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-580 — Example 11.8: p-value 0.0175, reject H₀

25. The same data at the 1 percent level

Prediction

The book assumes 5 percent. Suppose instead the researchers had decided in advance on alpha equal to 0.01. Nothing about the data changes.

Predict first

With the statistic 10.1287 on three degrees of freedom and p-value 0.0175, what is the decision at the 1 percent level?

  • do not reject: 0.0175 is above 0.01
  • reject: the statistic is above 7.815
  • reject: the p-value is small
  • the test cannot be run at 1 percent

Correct: do not reject: 0.0175 is above 0.01

Why: At the 1 percent level the cutoff on three degrees of freedom is 11.345, and 10.1287 falls short of it. Equivalently the p-value 0.0175 is larger than 0.01. The 7.815 cutoff belongs to the 5 percent level.

\[ 10.1287 < 11.345 = \chi^2_{0.01, 3} \qquad \Leftrightarrow \qquad 0.0175 > 0.01 \]

Look back at the curve: the yellow line sits between the two dashed cutoffs. This is what a borderline result looks like, and it is why alpha has to be chosen before the data are seen. Choosing it afterwards, to land on the side you prefer, makes the test meaningless.

The conclusion at 1 percent would read: there is insufficient evidence to conclude that the distributions are not the same. Both sentences describe the same evidence, judged against different standards.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — compare alpha and the p-value

26. Why the independence arithmetic is the right arithmetic

Concept

It is fair to be suspicious. Independence is a statement about two variables on one population; homogeneity is a statement about one variable on two populations. Why should the same numbers test both?

Treat group membership as a variable. Saying men and women have the same distribution of living arrangements says that the chance of each arrangement does not depend on which group a student is in.

\[ P(\text{dorm} \mid \text{man}) = P(\text{dorm} \mid \text{woman}) = P(\text{dorm}) \]

And that is precisely the definition of independence between group and living arrangement from Chapter 3. Equal conditional distributions and independence are the same statement written two ways.

\[ H_0^{\text{homog}}: \text{ the same distribution in each group} \]

\[ \iff \quad H_0^{\text{indep}}: \text{ group and category are independent} \]

So the expected counts, the statistic, the curve and the p-value all coincide. What does not coincide is the design. In a homogeneity study the group sizes are fixed by the researcher, so group membership is not something you measured about randomly chosen people, and the conclusion is worded about populations being alike rather than variables being related.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 578 — the same procedure as the test of independence

27. Degrees of freedom

Section

Part 3

28. Counting the cells that are free

Concept

Degrees of freedom count how many cells you could fill in freely once the totals are known. In a homogeneity table the row totals were fixed by design and the column totals come from the data; given both margins, how much of the table is still up for grabs?

Figure (svg): Two grids of cells. Left: 2 rows by 4 columns; the first three cells of the top row are green and labelled free, the rest red and labelled forced; dashed yellow boxes show fixed row and column totals. Caption: 2 minus 1 times 4 minus 1 equals 3 free cells. Right: 3 rows by 4 columns; the top-left 2 by 3 block of six cells is green and free, the last row and last column red and forced. Caption: 3 minus 1 times 4 minus 1 equals 6 free cells.

Once the margins are fixed, the last cell of each row and the whole last row are forced. With two rows only the first row has any freedom, which is why the book's rule is columns minus one.

Take Example 11.8's two-by-four table. Choose the men's dormitory, apartment and with-parents counts freely. The men's other count is forced, because the row must add to 250. And every women's count is forced, because each column must add to its total.

\[ O_{\text{men, other}} = 250 - (72 + 84 + 49) = 45, \quad O_{\text{women}, j} = \text{col}_j - O_{\text{men}, j} \]

Three free choices, so three degrees of freedom. The second row adds no freedom at all; it is the mirror again.

\[ df = 4 - 1 = 3 \]

The number of students never enters. Fifty-five students or fifty-five thousand, a two-by-four table has three degrees of freedom.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — df = number of columns − 1

29. Columns minus one is a special case

Concept

The book gives degrees of freedom as the number of columns minus one, and that is right for its setting: two populations, one row each. But the test works for any number of populations, and then the rule is the one from the test of independence.

\[ df = (r - 1)(c - 1) \]

\[ r = \text{number of populations}, \qquad c = \text{number of categories} \]

With two populations, r is 2 and the first factor is one, so the general rule collapses to the book's.

\[ df = (2 - 1)(c - 1) = c - 1 \]

Three populations across four categories, say first-years, sophomores and juniors asked the same living-arrangement question, would give six degrees of freedom: two free rows of three free cells each, the right-hand grid in the previous picture.

\[ df = (3 - 1)(4 - 1) = 2 \times 3 = 6 \]

Use the book's shortcut only when you have checked there are exactly two populations. Applying columns minus one to a three-row table would give three degrees of freedom instead of six, read the statistic from a curve centred too far left, and make the evidence look stronger than it is.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — degrees of freedom

30. Slide the number of populations and categories

Tweak it

Move both sliders. The curve is the chi-square density for the table you have set up, and its degrees of freedom are rows minus one times columns minus one.

Parameter explorer

Set two populations and four categories, then add a third population. How far right does the curve move, and what does that do to a statistic of 10?

\[ df = ({r} - 1)({c} - 1) \]

  • r — from 2 to 4: populations (rows)
  • c — from 3 to 6: categories (columns)

With two populations and four categories, three degrees of freedom: the hump peaks near 1 and a statistic of 10 is far out in the tail. Add a third population and the degrees of freedom double to six; the hump moves right and 10 is only modestly unusual.

\[ P(\chi^2_3 > 10) \approx 0.019, \qquad P(\chi^2_6 > 10) \approx 0.125 \]

Every extra row or column adds cells, and every cell adds a non-negative term to the sum, so the curve must slide right to keep up. A statistic only means something beside its degrees of freedom.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — degrees of freedom

31. Degrees of freedom for different designs

Comparison

Fill in the blanks. Each row is a homogeneity study; count the populations and the categories, then apply the product rule.

Comparison matrix

studypopulationscategoriesdf
Example 11.8: men, women; four living arrangements243
Example 11.9: before, after; three candidates232
Try It 11.8: families, singles; five car types254
Try It 11.9: regular, early decision; six schools265
three regions; four favourite sports346
four age groups; three phone brands436

The last two rows give the same answer from a three-by-four and a four-by-three table: the rule is symmetric, so it does not matter which way round you draw the table. What matters is that you subtract one from each dimension.

\[ (3 - 1)(4 - 1) = (4 - 1)(3 - 1) = 6 \]

Notice that no row asks for the sample size. The Ivy League study has almost twenty thousand acceptances and five degrees of freedom; Example 11.9 has a thousand voters and two.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-581 — Examples 11.8 and 11.9, Try Its 11.8 and 11.9

32. Your own: three campuses, and the shortcut that flips the decision

Worked example

The book's examples all have two rows. Here is one with three, to show that the test is unchanged except for the degrees of freedom, and why the columns-minus-one shortcut must not be carried over. Random samples of 100 students at each of three campuses name their usual study place.

libraryhomecafétotal
campus A403525100
campus B304030100
campus C503020100
total12010575300

Expected counts

Why: every row total is 100, so every row expects one third of each column.

\[ E = \frac{(100)(120)}{300} = 40, \quad \frac{(100)(105)}{300} = 35, \quad \frac{(100)(75)}{300} = 25 \]

Campus A's terms

Why: its counts match the expected ones exactly.

\[ 0 + 0 + 0 = 0 \]

Campus B's terms

Why: gaps of minus 10, 5 and 5.

\[ \frac{100}{40} + \frac{25}{35} + \frac{25}{25} = 2.5 + 0.7143 + 1 = 4.2143 \]

Campus C's terms

Why: gaps of 10, minus 5 and minus 5: the same squares.

\[ \frac{100}{40} + \frac{25}{35} + \frac{25}{25} = 4.2143 \]

Add the rows

Why: nine cells in all.

\[ \chi^2 = 0 + 4.2143 + 4.2143 = 8.4286 \]

Degrees of freedom

Why: three populations, three categories.

\[ df = (3 - 1)(3 - 1) = 4 \]

p-value and decision

Why: right tail on four degrees of freedom.

\[ P(\chi^2_4 > 8.4286) = 0.077 > 0.05 \Rightarrow \text{do not reject} \]

Now see what the shortcut would have done. Columns minus one gives two degrees of freedom, and on that curve the same statistic has a p-value of 0.015, a rejection. The decision flips purely because of a miscounted df. At the 5 percent level, the correct conclusion is that there is insufficient evidence that the three campuses differ in where students study.

Check with the four-df closed form

Why: the tail on four degrees of freedom is e to the minus half x, times one plus half x.

\[ e^{-4.2143}(1 + 4.2143) = 0.01478 \times 5.2143 = 0.077 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — df = number of columns − 1, for two populations

33. Trap: counting the cells instead of the free cells

Trap

The trap

For Example 11.8, a first attempt reasons as in goodness of fit, cells minus one:

\[ df = 8 - 1 = 7 \]

\[ P(\chi^2_7 > 10.13) = 0.18 \]

Wrong. Both margins are fixed here, not just the grand total.

The fix

Goodness of fit fixes one total. A two-way table fixes every row total and every column total, so far fewer cells are free.

\[ df = (2 - 1)(4 - 1) = 3 \]

\[ P(\chi^2_3 > 10.13) = 0.0175 \]

The wrong count turns a rejection into a shrug. The other slip, 550 minus one, is worse still.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — df = number of columns − 1

34. Example 11.9: hypotheses and expected counts

Worked example

Both before and after a recent earthquake, surveys asked voters which of three city council candidates they planned to vote for. Has the distribution of voter preferences changed? Test at the 5 percent level.

PerezChungStevenstotal
before167128135430
after214197225636
total3813253601066

Name the populations and write the hypotheses

Why: two populations, the electorate before and the electorate after; one categorical variable.

\[ H_0: \text{ the distribution of preferences was the same before and after} \]

State the alternative

Why: not the same, with no direction.

\[ H_a: \text{ the distribution was not the same before and after} \]

Notice that the hypotheses are about the electorate at two times, not about the 1,066 people surveyed. Those people are only the evidence; the question is whether the whole city's preferences moved.

Expected counts, before row

Why: row total 430 times each column total, over 1,066.

\[ \frac{430 \cdot 381}{1066} = 153.6867, \quad \frac{430 \cdot 325}{1066} = 131.0976 \]

\[ \frac{430 \cdot 360}{1066} = 145.2158 \]

Expected counts, after row

Why: each column total minus the before value.

\[ 381 - 153.6867 = 227.3133, \quad 325 - 131.0976 = 193.9024 \]

\[ 360 - 145.2158 = 214.7842 \]

Using subtraction for the second row is not a shortcut that loses accuracy: it is exact, because each expected column must add to the observed column total. Computing the after row directly would give the same three numbers.

Degrees of freedom

Why: two populations, three candidates.

\[ df = 3 - 1 = 2 \]

Check the condition and the before row's total

Why: every expected count is over 130, far above five, and the before row reproduces 430.

\[ 153.6867 + 131.0976 + 145.2158 = 430.0001 \approx 430 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 580-581 — Example 11.9, Table 11.21

35. Example 11.9: the statistic

Worked example

With the expected counts built, the statistic is three gaps, squared once each, divided by six expected counts. The mirror means you only need the before row's gaps.

Gaps in the before row

Why: observed minus expected for Perez, Chung, Stevens; the after row's gaps are their negatives.

\[ O - E: \quad 13.3133, \; -3.0976, \; -10.2158 \]

Square them

Why: each square serves both cells in its column.

\[ 177.2445, \; 9.5949, \; 104.3617 \]

Divide by the before expected counts

Why: 153.6867, 131.0976, 145.2158.

\[ 1.1533, \; 0.0732, \; 0.7187 \]

Divide by the after expected counts

Why: 227.3133, 193.9024, 214.7842.

\[ 0.7797, \; 0.0495, \; 0.4859 \]

The after terms are smaller than the before terms in every column because there were more after-voters: the same squared gap divided by a larger expected count. The ratio is 636 over 430, about 1.48, in every column.

Add all six terms

Why: the statistic.

\[ \chi^2 = 1.1533 + 0.0732 + 0.7187 + 0.7797 + 0.0495 + 0.4859 = 3.2603 \]

The Perez column supplies 1.93 of the 3.26 and Stevens 1.20; Chung, whose share barely moved, adds almost nothing. That fits the bar chart, where Perez lost about five points and Stevens gained four.

Figure (svg): Grouped bar chart of voter preference as a percentage of each survey. Perez: before 38.8 percent, after 33.6. Chung: before 29.8, after 31.0. Stevens: before 31.4, after 35.4.

Perez dropped about five points and Stevens gained four. Whether that is a real shift or survey noise is exactly what the test decides.

Check against the book and the gaps

Why: the total matches the printed 3.2603, and the before row's gaps add to zero as they must.

\[ 13.3133 - 3.0976 - 10.2158 = -0.0001 \approx 0 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 581 — Example 11.9: χ² = 3.2603

36. Example 11.9: p-value, decision and conclusion

Worked example

The statistic is 3.2603 on two degrees of freedom. On two degrees of freedom the right tail has a simple exact form, so this p-value can be found without any table.

Write the probability statement

Why: right tail, df 2.

\[ p\text{-value} = P(\chi^2_2 > 3.2603) \]

Use the df-2 tail

Why: the chi-square with two degrees of freedom is an exponential with mean 2.

\[ P(\chi^2_2 > x) = e^{-x/2} \]

Substitute

Why: half of 3.2603 is 1.63015.

\[ e^{-1.63015} = 0.1959 \]

This closed form is not something to memorise, but it shows where the calculator's number comes from: on two degrees of freedom the tail area beyond any x is simply e to the minus half of x.

Figure (svg): A chi-square curve with 2 degrees of freedom from 0 to 10, highest at zero and falling. A yellow line marks the statistic 3.26, with the area to its right shaded blue and labelled p-value 0.1959. A dashed red line at 5.991 marks the 5 percent cutoff.

On two degrees of freedom the curve is an exponential decay. About a fifth of it lies beyond 3.26, so a difference this size between two surveys is common even when nothing has changed.

Compare with alpha

Why: the p-value is far above 0.05.

\[ 0.1959 > 0.05 \Rightarrow \text{do not reject } H_0 \]

In the picture the blue region beyond 3.26 is large and the red region beyond the cutoff is small and far to the right. The statistic never reaches the rejection region.

Conclusion, in the book's words: at a 5 percent level of significance, from the data, there is insufficient evidence to conclude that the distribution of voter preferences was not the same before and after the earthquake. The five-point drop for Perez is within what two surveys of this size produce by chance.

Check against the yardstick and the cutoff

Why: the mean of a chi-square on two degrees of freedom is 2, and 3.26 is only modestly above it; it is also short of the 5 percent cutoff of 5.991.

\[ 3.2603 < 5.991 = \chi^2_{0.05, 2} \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 581 — Example 11.9: p-value 0.1959, do not reject

37. Two thousand surveys of an electorate that did not change

Picture it

Is a chi-square curve really the right yardstick for two finite surveys? Check it directly. The computer drew a before survey of 430 voters and an after survey of 636 from one single electorate, with the pooled shares, two thousand times.

Figure (svg): A histogram of 2000 simulated values of the homogeneity statistic. Each comes from a before survey of 430 and an after survey of 636 voters, both drawn from one shared distribution of preferences: 35.7 percent Perez, 30.5 percent Chung, 33.8 percent Stevens. The bars fall from a peak near zero, and the chi-square curve with 2 degrees of freedom runs along their tops. Bars from about 3.26 upward are yellow.

No earthquake effect went into these bars: both surveys came from the same electorate. They still match the chi-square curve with two degrees of freedom, and about a fifth of them reach the real 3.26.

The null hypothesis was true in every one of these simulated pairs, yet the statistic was rarely zero. It averaged 1.93, close to the chi-square mean of 2, and the bars follow the curve with two degrees of freedom.

368 of the 2000 unchanged electorates, about 18 percent, produced a statistic at least as big as the real 3.26. That is the simulated p-value, and it agrees with the 0.1959 from the formula to within the simulation's own wobble.

This is what do not reject means in practice. A difference as large as the earthquake surveys showed turns up in about one pair of surveys in five even when nothing at all has changed, so it cannot count as evidence of change.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 581 — Example 11.9, checked by simulation

38. Trap: a large p-value read as no change

Trap

The trap

A reporter reads Example 11.9's result:

\[ p = 0.1959 > 0.05 \]

and writes: the survey proves the earthquake did not change voters' preferences.

Wrong. Failing to reject is not evidence that the distributions are equal.

The fix

The test can only say the data do not show a difference. A real shift could be too small to detect with these surveys.

The book's own wording is careful: insufficient evidence to conclude the distribution was not the same.

\[ 3 \times \text{the voters: } p = 0.0075 \]

The same five-point shift, in larger surveys, would be significant.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 581 — Example 11.9's conclusion

39. Can clearly different percentages fail to reject?

Counterexample

It is tempting to think that if two groups really look different, the test will say so. Try to break that belief with a concrete table.

Discussion prompt

Group one splits 20, 40 and 40 percent over three categories; group two splits 50, 30 and 20 percent. Run the test with 10 people in each group, then with 100 in each. What happens, and is the small test even allowed?

This is the counterexample to the belief. A large p-value can come from groups that differ a great deal, if the samples are too small to show it. That is exactly why a failure to reject is reported as insufficient evidence, never as sameness.

It also shows the condition doing its job. The ten-per-group table fails the expected-count check, which is a warning that the sample is too small to say much before any p-value is computed.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-581 — the requirement and the wording of a non-rejection

40. Before and after: two samples, not the same people twice

Concept

The book lists before against after as a common use, and Example 11.9 is one. But look at how its data were gathered: one survey of 430 voters before the earthquake and a separate survey of 636 after. Different people, sampled independently.

That independence is a requirement, not a detail. The test treats the two rows as two independent random samples; the pooled expected counts and the chi-square curve both rest on it.

Suppose instead the same 430 voters had been asked twice. Then each person contributes to both rows, a voter's two answers are strongly linked, and the table no longer contains 860 independent observations. The homogeneity test would misjudge the sampling variation, and its p-value would mean nothing.

\[ \text{same people twice} \Rightarrow \text{paired data} \Rightarrow \text{not a test for homogeneity} \]

So before you run a before-and-after comparison, ask whether the after group is a fresh sample. If it is, homogeneity fits. If it is the same people, the natural summary is a table of each person's before answer against their after answer, which needs a method for paired categorical data beyond this course.

The same check applies to east against west or men against women: the two samples must be drawn separately, with nobody in both.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 579-581 — common uses; Example 11.9

41. What a rejection does not say

Section

Part 4

42. The book's warning: not the same, and nothing more

Concept

Right after Example 11.8 the book adds a sentence that is easy to skim past. Notice that the conclusion is only that the distributions are not the same. We cannot use the test for homogeneity to draw any conclusions about how they differ.

Why so strict? Look at what the statistic is. It squares every gap, so the direction of each difference is thrown away, and it adds over every cell, so which cells did the work is thrown away too.

\[ \chi^2 = \sum_{\text{all cells}} \frac{(O - E)^2}{E} \]

Many different patterns of difference give the same statistic. In Example 11.8, a big gap in the with-parents column, or a big gap in the dormitory column, or a moderate gap spread across every column, could all produce 10.13.

And the alternative hypothesis was only not the same. A rejection establishes that, and only that. The claim that women are more likely than men to live with their parents is a different hypothesis, about one category and with a direction, and this test never tested it.

\[ \text{rejecting } D_{\text{men}} = D_{\text{women}} \ne \text{showing } p_{\text{men, parents}} < p_{\text{women, parents}} \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — we cannot use the test for homogeneity to draw conclusions about how they differ

43. Describing the table is not the same as testing it

Picture it

After a rejection it is natural, and useful, to look back at the table and describe where the observed counts depart from the expected ones. Divide each gap by the square root of its expected count, and the gaps become comparable across cells.

\[ \frac{O - E}{\sqrt{E}}: \quad \text{men, with parents: } \frac{49 - 62.27}{\sqrt{62.27}} = -1.68 \]

Figure (svg): Diverging horizontal bars around a vertical zero line, two per living arrangement, cyan for men and orange for women. Dormitory: men minus 0.24, women 0.22. Apartment: men 0.77, women minus 0.70. With parents: men minus 1.68, women 1.54. Other: men 1.43, women minus 1.31.

Squaring these signed gaps gives the terms of the statistic. Unsquared, they show direction: fewer men than expected live with parents, more men than expected are in the other column.

Squaring these signed bars gives exactly the eight terms of the statistic. Unsquared they keep the direction: fewer men than expected live with parents, more women than expected do, and the reverse in the other column.

That is a description of this sample, and it is a fair thing to put in a report as long as it is labelled as one. What you may not write is that the test showed it. The test was run once, on one question, not the same; its p-value does not belong to any individual bar, and none of these bars is beyond two in size.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — the conclusion is only that the distributions are not the same

44. Find the error: a conclusion that says too much

Error analysis

Here is a write-up of Example 11.8. The arithmetic is all correct. Find the part of the conclusion the test does not support, and say what should replace it.

The chain reads p-value below alpha, so reject, so women favour living with parents. Each arrow should be justified by something the test actually computed.

Annotate

On: \( p < 0.05 \Rightarrow \text{reject } H_0 \Rightarrow \text{women favour parents} \)

  • Correct: the p-value 0.0175, the right-tail area beyond 10.1287 on three degrees of freedom, is below the 5 percent level the book uses.
  • Correct decision: the distributions are not the same.
  • The error. The test only shows the distributions differ; it cannot say how. This is a description of the sample, not a tested conclusion.

The correct conclusion stops at the population-level sentence: at the 5 percent level there is sufficient evidence that the distributions of living arrangements for men and women college students are not the same.

If the with-parents comparison is the real research question, it deserves its own test, planned in advance: Chapter 10's two-proportion test on that one category, with a one-sided alternative if the direction was predicted beforehand. Picking the most striking cell after seeing the table and then testing it would overstate the evidence, because you chose it for being extreme.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — Example 11.8's conclusion and the note after it

45. Rank the columns of the car table

Ranking

Try It 11.8 asks whether 100 families and 200 singles have the same distribution of car types. Before computing, rank the five columns by how much each will add to the statistic. Compare the two groups' percentages in each column.

sportsedanhatchbacktruckvan/SUV
family515351728
single456537467

Put in order

Order the columns from the largest contribution to the smallest.

  1. van/SUV: families 28 %, singles 3.5 %
  2. sport: families 5 %, singles 22.5 %
  3. sedan: families 15 %, singles 32.5 %
  4. hatchback: families 35 %, singles 18.5 %
  5. truck: families 17 %, singles 23 %

Why: Column contributions are 34.30 for van or SUV, 12.25 for sport, 7.66 for sedan, 7.56 for hatchback and 1.14 for truck. Vans are a large gap relative to a small pooled share; sedan and hatchback have similar gaps of about sixteen to eighteen points but different pooled shares, so they nearly tie.

The van column dominates because the gap is huge relative to how common vans are overall: 35 of 300 people, so each group's expected count is small and the squared gap is divided by little.

Sedans and hatchbacks are the close call. Their gaps in percentage points are similar, and the column with the larger pooled share, sedans with 80 people against hatchbacks with 72, gets the slightly smaller term per squared gap.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — Try It 11.8, Table 11.20

46. Try It 11.8: families and singles, the expected counts

Worked example

Do families and singles have the same distribution of cars? 100 randomly selected families and 200 randomly selected singles were asked what type of car they drove. Test at the 5 percent level. The book prints no answer here; this is the full run.

Write the hypotheses

Why: two populations, families and singles; one categorical variable with five values.

\[ H_0: \text{ families and singles have the same distribution of cars} \]

The alternative is that the two distributions are not the same. As always it names no category and no direction: a single car type with a different share would be enough to make it true.

Find the margins

Why: column totals over both groups, and the grand total.

\[ 50, \; 80, \; 72, \; 63, \; 35, \qquad n = 300 \]

The margins say 50 of the 300 people drive sport cars and 35 drive vans. Under the null, those pooled shares, one sixth and about one eighth, apply equally to families and to singles.

Expected counts for families

Why: row total 100, so each is a third of its column total.

\[ \frac{100 \cdot 50}{300} = 16.67, \; 26.67, \; 24.00, \; 21.00, \; 11.67 \]

Expected counts for singles

Why: row total 200: the rest of each column.

\[ 33.33, \; 53.33, \; 48.00, \; 42.00, \; 23.33 \]

Because singles are exactly two thirds of the 300 people, every singles expected count is twice the families' count in the same column. That two-to-one ratio will show up again in the terms of the statistic.

Look at the condition carefully. The family sport cell observed only 5, which looks dangerous, but its expected count is 16.67. The smallest expected count anywhere is 11.67, for families with vans, so the test may run.

\[ \min E = 11.67 \ge 5 \]

Check the margins are reproduced

Why: the family row must total 100 and each column its own total.

\[ 16.67 + 26.67 + 24 + 21 + 11.67 = 100.01 \approx 100, \quad 16.67 + 33.33 = 50 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — Try It 11.8

47. Try It 11.8: the statistic and the conclusion

Worked example

Now the gaps, the terms, the tail and the sentence. Work a column at a time, since the two cells of each column share their squared gap.

Family gaps

Why: observed minus expected; the singles' gaps are their negatives.

\[ -11.67, \; -11.67, \; 11.00, \; -4.00, \; 16.33 \]

Square them

Why: one square per column.

\[ 136.11, \; 136.11, \; 121.00, \; 16.00, \; 266.78 \]

The van column's square, 266.78, is the largest by far: families drove vans at eight times the singles' rate. Dividing it by the small family expected count of 11.67 is what makes this one column dominate.

Family terms

Why: divide by 16.67, 26.67, 24, 21 and 11.67.

\[ 8.17, \; 5.10, \; 5.04, \; 0.76, \; 22.87 \]

Singles' terms

Why: the denominators are twice as large, so each term is exactly half.

\[ 4.08, \; 2.55, \; 2.52, \; 0.38, \; 11.43 \]

Add all ten terms

Why: the statistic.

\[ \chi^2 = 41.94 + 20.97 = 62.91 \]

Figure (svg): Grouped bar chart of car type as a percentage of each group. Sport: families 5 percent, singles 22.5. Sedan: 15 and 32.5. Hatchback: 35 and 18.5. Truck: 17 and 23. Van or SUV: 28 and 3.5.

Here the two patterns are visibly different: families lean to hatchbacks and vans, singles to sport cars and sedans. Expect a huge statistic.

Find the p-value

Why: two populations, five car types: df 4, whose tail has a closed form.

\[ P(\chi^2_4 > 62.91) = e^{-31.46}(1 + 31.46) \approx 7 \times 10^{-13} \]

A p-value this small means that if families and singles really chose cars the same way, two samples of these sizes would almost never look this different. It does not mean the difference is large; the bars show that separately.

Reject the null. At the 5 percent level there is sufficient evidence that families and singles do not have the same distribution of car types. The test says no more than that; the bars describe the sample.

Check against the cutoff and the halving

Why: 62.91 is more than six times the 5 percent cutoff of 9.488 on four degrees of freedom, and the singles' row is exactly half the families' row, as a two-to-one split of the samples requires.

\[ 62.91 > 9.488, \quad 41.94 = 2 \times 20.97 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 580 — Try It 11.8

48. When the variable has only two values

Concept

The book says the test is used when the variable has more than two possible response values. Here is why that qualification is there. With only two values, success and failure, each population has a single proportion, and Chapter 10 already has a test for two proportions.

\[ H_0: p_1 = p_2 \qquad z = \frac{\hat p_1 - \hat p_2}{\sqrt{\hat p(1 - \hat p)\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}} \]

The two tests are not rivals. On a table with two rows and two columns, the homogeneity statistic is exactly the square of the pooled two-proportion z, and the two-sided p-values are identical.

\[ \chi^2_1 = z^2 \quad \text{for every two-by-two table} \]

So why prefer the z test when it applies? Because it keeps the sign. It says which proportion is larger, and it allows a one-sided alternative when a direction was predicted in advance. The homogeneity test squares the sign away, which is exactly the limitation the book warns about.

With three or more categories there is no single proportion to compare, and squaring and summing over cells is the natural way to combine them. That is the job the homogeneity test was built for.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — a categorical variable with more than two possible response values

49. Your own: Example 11.9 as Perez against the rest

Worked example

Collapse Example 11.9 to two categories, Perez and anyone else, and run both tests on the same table. If the claim on the last slide is right, they must agree exactly.

Pereznot Pereztotal
before167263430
after214422636

Sample proportions for Perez

Why: each survey's count over its size.

\[ \hat p_1 = \frac{167}{430} = 0.3884, \qquad \hat p_2 = \frac{214}{636} = 0.3365 \]

Pooled proportion

Why: the null says the two are equal, so combine.

\[ \hat p = \frac{381}{1066} = 0.3574 \]

This is the same pooling as the expected counts of the homogeneity test: 381 Perez supporters out of 1,066 voters is the shared share the null hypothesis assumes for both surveys.

Standard error

Why: pooled, as in Chapter 10.

\[ \sqrt{0.3574(0.6426)\left(\tfrac{1}{430} + \tfrac{1}{636}\right)} = 0.02992 \]

The z statistic

Why: difference over its standard error.

\[ z = \frac{0.3884 - 0.3365}{0.02992} = 1.734 \]

Square it

Why: this should be the homogeneity statistic for the collapsed table.

\[ z^2 = 1.734^2 = 3.008 \]

Notice what collapsing has done. The three-candidate test gave 3.26 on two degrees of freedom; this two-category test gives 3.01 on one. Merging Chung and Stevens hid their opposite movements, but the single degree of freedom makes a similar statistic count for more.

Computing the homogeneity statistic on the two-by-two table directly, with row times column over total for each of the four expected counts, gives 3.0082, the same number. Both two-sided p-values are 0.0828: some hint that Perez lost ground, not enough at the 5 percent level.

Check the agreement

Why: the chi-square tail on one degree of freedom beyond z squared is the two-sided normal tail beyond z.

\[ P(\chi^2_1 > 3.008) = 2P(Z > 1.734) = 0.0828 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 580-581 — Example 11.9, collapsed to two categories

50. Significant is not the same as large

Concept

One more thing a rejection does not say: that the difference is big. The homogeneity statistic grows with the sample size even when the percentages stay exactly the same.

Keep Example 11.9's percentages fixed and imagine the surveys had been several times larger. Every observed and expected count scales by the same factor, so every squared gap scales by its square and every term by the factor once.

\[ \frac{(mO - mE)^2}{mE} = m \cdot \frac{(O - E)^2}{E} \quad \Rightarrow \quad \chi^2 \to m \chi^2 \]

Figure (svg): A curve of p-value against a sample-size multiplier from 0.5 to 4.5, for Example 11.9's percentages held fixed. The curve falls from about 0.44 at half size, through 0.1959 at the actual size, below the dashed red 0.05 line at about 1.84 times the size, to about 0.0006 at 4.5 times. Dots mark 1 times, 0.196, and 3 times, 0.0075.

Nothing about the voters' percentages changes along this curve; only the number surveyed. The statistic grows in proportion to the sample size, so the same five-point shift crosses into significance at under twice the size.

The real surveys give a p-value of 0.196. Triple both surveys and the statistic triples to 9.78, with a p-value of 0.0075, a confident rejection of exactly the same shift in voter percentages.

\[ 3 \times 3.2603 = 9.7809, \qquad e^{-9.7809/2} = 0.0075 \]

So a tiny p-value from a huge sample may describe a trivial difference, and a large p-value from a small sample may hide an important one. Report the percentages beside the test, so a reader can judge size as well as significance.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 581 — Example 11.9, rescaled

51. Homogeneity against independence

Section

Part 5

52. Same table, two designs

Concept

A two-way table of counts can come from two quite different studies, and the table alone will not tell you which. What tells you is how the data were collected.

Figure (svg): A two-panel diagram. Left, headed homogeneity: two separate population circles, men and women, each with an arrow to a table; the arrows read draw 250 and draw 300, and the table box says row totals set in advance. Below: the null is that the two distributions are the same. Right, headed independence: one population circle of students with a single arrow reading draw 400 into a table where only the grand total is set in advance. Below: the null is that the two variables are independent.

The tables at the bottom look identical. What differs is upstream: how many samples were drawn, and whether the row totals were chosen by the researcher or fell out of the data.

In a homogeneity study you draw a separate random sample from each population, and you decide the sample sizes in advance. The rows are the populations, and their totals are fixed by you. Example 11.8 chose 250 men and 300 women.

In an independence study you draw one random sample from one population and record two variables on each person. Only the grand total is fixed; both sets of margins come from the data. Example 11.7 drew 400 students and measured both need to succeed and anxiety.

\[ \text{homogeneity: one variable, several samples} \]

\[ \text{independence: two variables, one sample} \]

The arithmetic is identical, so a wrong choice never changes the p-value. It changes the sentence. A homogeneity conclusion talks about populations having the same distribution; an independence conclusion talks about variables being related. Writing the wrong one describes a study that was not done.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.5, p. 582 — comparison of the chi-square tests

53. Three chi-square tests, side by side

Concept

Section 11.5 sums up the three uses of the chi-square statistic for counts. Each answers a different question, and the question is fixed by the design before any arithmetic.

testthe dataH₀expected countsdf
goodness of fitone qualitative variable, one populationthe population fits the given distributionn × claimed proportioncells − 1
independencetwo qualitative variables, one samplethe two variables are independent(row)(column)/n(r − 1)(c − 1)
homogeneityone qualitative variable, two populationsthe two populations follow the same distribution(row)(column)/ncolumns − 1 for two populations

Read down the expected-counts column: the last two tests share a formula, and the first stands apart because only it has a distribution given in advance. Read down the data column: the first and last share one variable, and independence stands apart because only it measures two things on each person.

So each pair of tests shares something, and that is why they are confused. The questions to ask are always the same two. Is a distribution given in advance? Then goodness of fit. If not, was one sample classified two ways, or were several samples taken? That decides independence against homogeneity.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.5, p. 582 — goodness of fit, independence, homogeneity

54. Match each null hypothesis to its test

Matching

Each null hypothesis below comes from one of the three chi-square tests. Match it by the kind of statement it makes, not by its subject.

Match the pairs

  • a. Absences are spread equally over the five weekdays
  • b. Need to succeed and anxiety level are independent
  • c. Families and singles have the same distribution of car types
  • d. Far-western families fit the national streaming-services distribution
  • g1. goodness of fit, uniform claim
  • i. test of independence
  • h. test for homogeneity
  • g2. goodness of fit, published percentages

Why: Equal weekdays is a distribution given in advance, the uniform. Two variables measured on one sample of students is independence. Two separately sampled groups compared with each other is homogeneity. The national streaming figures are published, so that is goodness of fit even though it compares two regions.

The statement that gives each test away is its verb. Fits a given distribution belongs to goodness of fit. Are independent belongs to independence. Have the same distribution, said of two groups, belongs to homogeneity.

When you write your own hypotheses, use the verb that matches your design. Writing that families and singles are independent of car type is not wrong arithmetic, but it describes a study in which family status was measured on a random sample, which is not what was done.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.5, p. 582 — the three pairs of hypotheses

55. Which chi-square test does each study need?

Sorting

Sort each study by design. Ask first whether a distribution is given; if not, ask how many samples were drawn.

Ignore the subject matter and the shape of the table the study would produce. Two of these studies would give tables that look exactly alike; only the sampling plan separates them.

Sort into buckets

Sort each study into the chi-square test it calls for.

goodness of fit
A spinner is spun 150 times and compared with the maker's stated proportions; M&M colours in 400 sweets compared with the company's published colour mix
independence
500 randomly chosen adults are each asked their age group and their favourite news source; One random sample of 300 voters records party and whether they support a policy
homogeneity
Separate random samples of 200 nurses and 200 teachers each name their preferred shift; Random samples of last year's and this year's customers each rate the service on a five-point scale
g
A distribution is stated in advance by the maker or the company, and one sample is compared with it.
i
One random sample, two variables recorded on each person. Neither set of margins was fixed by the researcher.
h
Two separate random samples, one per population, each answering the same single question. The sample sizes were chosen in advance.

The nurses and teachers study is the one to look at twice. It could be laid out as a table of occupation by preferred shift, which looks like independence. But occupation was not measured on a random sample; the researcher chose 200 of each. So it is homogeneity.

The voters study is the mirror image. Party could be the rows of a table that looks just like a homogeneity table, but the 300 voters were one sample and party was recorded, not chosen. That makes it independence.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.5, p. 582 — deciding which test applies

56. Try It 11.9: what to settle before computing

Step zero

Try It 11.9 gives acceptances at six Ivy League schools for two application types, regular and early decision. It asks whether the regular acceptances follow the same distribution across schools as the early acceptances.

BrownColumbiaCornellDartmouthPennYale
regular2,1151,7925,3061,7342,6851,245
early decision5776271,2284441,195761

Discussion prompt

Before any arithmetic: what are the two populations, what is the categorical variable, how many degrees of freedom are there, and is anything about these data unlike a usual random sample?

Settling these first saves you from the two easy slips with a wide table: counting twelve cells and subtracting one, which gives eleven, and treating the result as a survey finding about applicants in general.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 581-582 — Try It 11.9, Table 11.22

57. Try It 11.9: regular against early decision

Worked example

Run the test the book asks for, at the 5 percent level: hypotheses, degrees of freedom, statistic, the graph of the p-value in words, and a conclusion. The book prints no answer here.

Hypotheses

Why: the two application types are the populations.

\[ H_0: \text{ regular and early acceptances have the same distribution over schools} \]

Read the question carefully. The book asks whether the regular acceptances are spread over the schools in the same way as the early-decision acceptances, so school is the categorical variable and application type defines the two groups.

Margins

Why: row totals and the grand total; column totals are each school's sum.

\[ 14877, \; 4832, \qquad n = 19709 \]

One expected count, Cornell regular

Why: row total times Cornell's 6,534, over the grand total.

\[ E = \frac{14877 \cdot 6534}{19709} = 4932.08 \]

With twelve cells, write out just one expected count in full and trust the pattern for the rest. Every regular expected count is 14,877 over 19,709, about 0.7548, times the school's column total; every early-decision count is the remainder.

Cornell's two terms

Why: the regular gap is 373.92, and the early-decision gap its negative.

\[ \frac{373.92^2}{4932.08} = 28.35, \qquad \frac{373.92^2}{1601.92} = 87.28 \]

Sum the column contributions

Why: Brown, Columbia, Cornell, Dartmouth, Penn, Yale.

\[ 13.83 + 2.57 + 115.63 + 20.08 + 82.75 + 195.20 = 430.06 \]

Every column except Columbia contributes more than 13 on its own, already beyond the 5 percent cutoff for the whole test. With almost twenty thousand acceptances, even modest differences in percentage produce enormous terms.

Figure (svg): Grouped bar chart of the share of each application type's acceptances going to each of six schools. Regular, then early decision: Brown 14.2 and 11.9 percent; Columbia 12.0 and 13.0; Cornell 35.7 and 25.4; Dartmouth 11.7 and 9.2; Penn 18.0 and 24.7; Yale 8.4 and 15.7.

Cornell takes over a third of the regular acceptances but only a quarter of the early ones; Penn and Yale lean the other way. With nearly twenty thousand acceptances, gaps this size are enormous evidence.

p-value on five degrees of freedom

Why: the curve's mean is 5; 430 is off any printed table.

\[ P(\chi^2_5 > 430.06) < 0.0001 \]

Reject the null. At the 5 percent level there is sufficient evidence that regular and early-decision acceptances are not distributed the same way across these six schools. The graph of the p-value is a chi-square curve with its hump near 3 and a tail beyond 430 too thin to see.

Check the cutoff and the mirror

Why: the 5 percent cutoff on five degrees of freedom is 11.07, which 430 dwarfs; and Cornell's early expected count plus its regular one gives back the column total.

\[ 430.06 \gg 11.07, \quad 4932.08 + 1601.92 = 6534 \quad \checkmark \]

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 581-582 — Try It 11.9

58. Bridge: did the redesign change what visitors do?

Real world

Homogeneity tests are everywhere outside textbooks. A website shows its old home page to one random group of visitors and a redesigned page to another, and records what each visitor does next.

buyssigns upbrowsesleavestotal
old page4060200200500
new page5090190170500

Discussion prompt

Which chi-square test fits, how many degrees of freedom does it have, and what could a rejection let the company say, and not say?

This is the same discipline as the book's warning, in a setting where it costs money. The tempting headline is the most striking cell. The defensible headline is the one the test actually tested, with the descriptive percentages beside it.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, p. 579 — common uses: before against after

59. The whole procedure, drawn as a flow

Picture it

Every test in this deck followed the same route. Here it is as one diagram, with the condition that can send you back.

Trace Example 11.8 through it as you read: two samples of 250 and 300, expected counts from the margins, a smallest expected count of 36.36, a statistic of 10.13, three degrees of freedom, a p-value of 0.0175, and the sentence not the same.

Figure (svg): A flow diagram. Two separate random samples lead to a two-way table with one row per population. Expected counts are row total times column total over the grand total. A check box asks whether every expected count is at least 5. Then the statistic, the sum over all cells of observed minus expected squared over expected; then degrees of freedom, columns minus one for two populations; then the right-tail p-value; and finally a conclusion that says only same or not the same.

Everything after the expected counts is the test of independence's arithmetic, step for step. Only the first box and the last one, the design and the wording, belong to homogeneity.

The first box is the design: separate random samples from each population. If that box is wrong, every number after it can be right and the conclusion still describes the wrong study.

The middle of the flow is borrowed whole from section 11.3: expected counts from the margins, the condition that each is at least five, the sum of squared gaps over expected counts, and the right-tail p-value. When an expected count is too small, combine categories that make sense together and recount the columns before anything else.

The last box is the wording. Same, or not the same, about the populations, and never how. Everything you learn by looking back at the table afterwards is description, and should be labelled that way.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 578-581 — the steps of every example

60. Putting it together

Section

Part 6

61. Pattern: a test for homogeneity, in order

Pattern

Every example in the section ran through the same steps. Most of them are the independence test's; the first and the last are this section's own.

  1. Check the design. Separate random samples, one per population; one categorical variable; no distribution given in advance.
  2. Write the hypotheses about populations. H₀: the two distributions are the same. Hₐ: they are not the same.
  3. Build expected counts from the margins. E = (row total)(column total)/grand total; rows and columns must add back.
  4. Check every E ≥ 5. The expected counts, not the observed ones.
  5. Compute the statistic. Gap, square, divide by E, add over every cell. In two rows the gaps mirror.
  6. df = columns − 1 for two populations; (r − 1)(c − 1) in general. Never from n.
  7. Right-tail p-value, P(χ² > observed); compare the statistic with df as a sanity check.
  8. Conclude: same, or not the same. In context, about the populations, never saying how they differ.

\[ E = \frac{(\text{row})(\text{column})}{n}, \qquad \chi^2 = \sum \frac{(O - E)^2}{E}, \qquad df = (r - 1)(c - 1) \]

Most wrong answers in this section are right arithmetic attached to the wrong words: a goodness-of-fit test with one sample treated as the truth, hypotheses written about variables for a two-sample design, degrees of freedom counted from cells or people, and a rejection reported as a finding about which group is higher.

62. Check: degrees of freedom

Check

Count the free cells in the table you would actually test.

Picture the table first: one row per college, one column per mode of transport. Then ask which dimension the book's shortcut assumes is two.

Check your understanding

Random samples of students at three colleges each report their main mode of transport: walk, bike, bus or car. A test for homogeneity compares the three colleges. How many degrees of freedom does it have?

  • A. 6 (correct)
  • B. 3
  • C. 11
  • D. 12

Answer: A

Why: Three populations and four categories: rows minus one times columns minus one, which is two times three, or six. The book's columns-minus-one rule is the special case for exactly two populations.

Why B tempts people
That is columns minus one, the book's rule for two populations. With three colleges there are two free rows, not one.
Why C tempts people
That is the twelve cells minus one, the goodness-of-fit count. A two-way table fixes every row and column total, so far fewer cells are free.
Why D tempts people
That counts every cell with nothing subtracted. Once the margins are fixed, the last row and the last column are forced.

The rule to remember is the general one, rows minus one times columns minus one. Columns minus one is what it becomes when there are two rows, and using the shortcut on a bigger table is the commonest slip.

In context: with six degrees of freedom the null curve centres near 6, so a statistic of about 6 would be entirely ordinary for three colleges that travel alike, and you would need roughly 12.6 or more to reject at the 5 percent level.

63. Check: an expected count

Check

Build the count the null hypothesis predicts, from the margins.

Remember where the expected count comes from: the pooled share of this category across both groups, applied to this group's size. The cell's own observed count plays no special part.

Check your understanding

Random samples of 100 first-years and 100 seniors choose their favourite of three dining halls: north, south, east. First-years: 30, 45, 25. Seniors: 50, 35, 15. Under the null hypothesis, how many first-years are expected to choose north?

  • A. 40 (correct)
  • B. 30
  • C. 33.3
  • D. 80

Answer: A

Why: The north column total is 30 plus 50, which is 80, out of 200 students. The first-year row total is 100, so the expected count is 100 times 80 over 200, which is 40. Under the null both groups share the pooled north share of 40 percent.

Why B tempts people
That is the observed count. Expected counts come from the margins, never from the cell being tested.
Why C tempts people
That splits the first-years equally over three halls, a goodness-of-fit uniform claim. The null here names no distribution.
Why D tempts people
That is the whole north column, both groups together. It still has to be shared out in proportion to the row totals.

Finishing the test: every expected count is 40, 40 or 20 in each row, the gaps are minus 10, 5 and 5 for first-years and the mirror for seniors, and the statistic is 8.75 on two degrees of freedom.

\[ \chi^2 = 2\left(\frac{100}{40} + \frac{25}{40} + \frac{25}{20}\right) = 8.75, \qquad p = e^{-4.375} = 0.0126 \]

So at the 5 percent level the two classes do not have the same distribution of dining-hall preferences, and that is all the test says.

64. Check: wording the conclusion

Check

Choose the sentence a careful statistician would write.

Before reading the options, write the conclusion yourself in one sentence. Name the populations, say same or not the same, and stop there. Then find the option that matches your sentence.

Check your understanding

A test for homogeneity compares the distributions of blood type in random samples from two regions. The statistic is 9.4 on three degrees of freedom, with p-value 0.024. Which conclusion is correct at the 5 percent level?

  • A. There is sufficient evidence that the distributions of blood type in the two regions are not the same. (correct)
  • B. Region and blood type are independent.
  • C. The first region has more type O blood than the second.
  • D. There is a 2.4 percent chance that the two regions have the same distribution.

Answer: A

Why: The p-value is below 0.05, so reject the null. The conclusion is worded about two populations, the regions, and says only that their distributions differ, which is the limit the book stresses.

Why B tempts people
That is an independence conclusion, and the wrong direction too: rejecting the null of sameness is evidence of a difference, not of no relationship.
Why C tempts people
The test cannot say how the distributions differ. A claim about one blood type in one direction was never tested.
Why D tempts people
A p-value is computed assuming the null is true. It is not the probability that the null is true.

Each wrong option is a habit worth naming: the wrong test's vocabulary, a conclusion about how the populations differ, and the p-value read as the probability of the null.

A quick check of the decision without software: the 5 percent cutoff on three degrees of freedom is 7.815, and 9.4 is beyond it, so rejection agrees with the p-value.

65. Explain why the arithmetic can be borrowed

Explain it to yourself

This is the one idea in the section that is not arithmetic. Put it in your own words before reading the model answer.

Discussion prompt

In two or three sentences, explain why a test for homogeneity can use exactly the expected counts and statistic of the test of independence, even though it asks a different question.

A strong answer names the link: equal conditional distributions across groups is independence of group and category. A very strong one adds why the wording still differs: in a homogeneity design the group sizes were chosen, so group is not a variable measured on a random sample.

If your answer said the tables look the same, push further. Looking the same is the reason the tests are confused, not the reason the arithmetic is valid.

66. Exit ticket: lunch choices at two schools

Exit ticket

Random samples of 120 students at one school and 180 at another choose between three lunch options: hot meal, salad bar, packed lunch. First school: 50, 40, 30. Second school: 60, 80, 40. Test at the 5 percent level whether the two schools have the same distribution of lunch choices.

Discussion prompt

Write the hypotheses, build the expected counts, compute the statistic, degrees of freedom and p-value, and state the conclusion in context.

The checks to run on your own answer: each expected row adds to its school's total, the gaps in each column cancel, every expected count is at least 28, and 3.82 is below the 5 percent cutoff of 5.991 on two degrees of freedom.

If your degrees of freedom came out as 5 you counted cells; if your conclusion said the second school prefers salads, you described the sample rather than the test.

67. Recap

Recap

A test for homogeneity asks whether two populations, sampled separately, have the same distribution of one categorical variable, without needing to know what that distribution is. Goodness of fit cannot do this, because it needs a distribution given in advance.

ideaformula or ruleread it as
hypothesesH₀: the two distributions are the same; Hₐ: not the sameabout populations, no direction
expected countsE = (row)(column)/nthe pooled distribution applied to each group
conditionevery E ≥ 5expected counts, not observed
statisticχ² = Σ (O − E)²/Ecomputed exactly as the test of independence
degrees of freedomcolumns − 1 for two populationsthe two-row case of (r − 1)(c − 1)
Example 11.8χ² = 10.13, df 3, p = 0.0175living arrangements differ; reject at 5%, not at 1%
Example 11.9χ² = 3.26, df 2, p = 0.1959no evidence preferences changed
the limitreject ⇒ not the samenever how they differ

The habits that matter are checking the design before choosing the test, writing hypotheses about populations, recounting degrees of freedom from rows and columns rather than cells or people, and stopping the conclusion at not the same. Describe the table afterwards if you like, but label it as description.

The Introductory Business Statistics text treats the same test in its own homogeneity section, in business settings, if you want more practice. Section 11.5 sets all three chi-square tests side by side, and section 11.6 turns to a test of a single variance.

OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity §11.4, pp. 578-582 — the whole section

OpenStax Introductory Business Statistics 2e, §11.5 Test for Homogeneity §11.5 Test for Homogeneity — the same test in business contexts

Sources

  1. OpenStax Introductory Statistics 2e, §11.4 Test for Homogeneity — Illowsky & Dean, OpenStax / Rice University, CC BY 4.0, pp. 577-582
  2. OpenStax Introductory Business Statistics 2e, §11.5 Test for Homogeneity — Illowsky & Dean, OpenStax / Rice University, CC BY 4.0

Want this taught 1-on-1? Alexander tutors Statistics — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108