12. Inference for Two Independent Means

a. Hypothesis Test
Math 115

Yurk

Where We’ve Been — and Where We’re Going

Topic Variables Statistic Example
6 One binary categorical \hat{p} Payday loans — fraction supporting regulation
10 Two binary categorical \hat{p}_1 - \hat{p}_2 CPR — survival rates by treatment
11 One numerical \bar{x} Cherry Blossom — mean finish time
12 (today) Numerical + binary categorical \bar{x}_1 - \bar{x}_2 Birth weights — by smoking habit
13 Numerical, paired \bar{x}_d Textbook prices — UCLA vs Amazon

Same framework throughout — only the statistic changes row to row.

Birth Weights and Smoking

Do infants born to smokers have different mean birth weights than those born to nonsmokers? Random sample of 981 U.S. births from 2014.

  • Response: birth weight (pounds) — numerical
  • Explanatory: maternal smoking habit (smoker / nonsmoker) — binary

Hypotheses (two-sided). Let \mu_n, \mu_s = mean birth weight for all U.S. babies born to nonsmoking / smoking mothers.

  • H_0: \mu_n - \mu_s = 0 (no difference in mean birth weights)
  • H_A: \mu_n - \mu_s \neq 0 (a difference exists)

EDA: Birth Weights

Group n \bar{x} (lbs) s (lbs)
Nonsmoker 867 7.27 1.23
Smoker 114 6.68 1.6

Observed difference: \bar{x}_n - \bar{x}_s = 7.27 - 6.68 \approx 0.59 lbs. Babies born to nonsmokers weigh a little over half a pound more on average. Real shift, or sampling noise?

A New CLT Result: Difference in Means

When conditions are met, the sampling distribution of \bar{x}_1 - \bar{x}_2 is approximately normal with:

  • Mean: \mu_1 - \mu_2 (the true difference)
  • Standard Error: depends on two sample standard deviations

Another CLT result. Just like \bar{x} in topic 11 and \hat{p}_1 - \hat{p}_2 in topic 10, the difference of two sample means becomes approximately normal under independence + adequate sample sizes.

Same catch as topic 11: we don’t know the population SDs \sigma_1, \sigma_2. We estimate from the sample SDs s_1, s_2 — then use a t-distribution to account for the extra uncertainty.

Pooled SD and SE for the Difference

When the two groups have similar SDs, treat them as sharing a common population SD. Estimate it by pooling the two sample SDs:

s_p = \sqrt{\frac{(n_1 - 1) s_1^2 + (n_2 - 1) s_2^2}{n_1 + n_2 - 2}}

Then the standard error for the difference is:

SE = s_p \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}

And use a t-distribution with df = n_1 + n_2 - 2.

“Pooled” parallel. Same idea as the pooled \hat{p} in topic 10 — combine information from both groups to estimate a common population value.

Technical Conditions: Two Means

Three conditions for inference about \mu_1 - \mu_2 from two independent samples:

Condition Rule
Independence Observations independent within and across groups — typically from random samples (each n < 10\% of population) or random assignment, otherwise justified from study context
Normality Each group: n \geq 30 → sample data may show mild skew, but no extreme outliers. If n < 30, group data should look roughly normal.
Equal variance Group SDs similar (within a factor of \approx 2) — used for the pooled SE

Try it: do all three conditions hold for the Birth Weights sample?

Independence: random sample of 2014 U.S. births (well under 10% of all 2014 U.S. births) ✓. Normality: n_n = 867, n_s = 114 — both well above 30, no extreme outliers in the histograms ✓. Equal variance: s_n \approx 1.23, s_s \approx 1.6 — within a factor of 2 ✓. All three met.

Test Statistic for Two Means

The T-statistic measures how far the observed difference is from the null value, in SE units:

T = \frac{(\bar{x}_1 - \bar{x}_2) - 0}{SE} = \frac{\bar{x}_1 - \bar{x}_2}{s_p \sqrt{1/n_1 + 1/n_2}}

  • \bar{x}_1 - \bar{x}_2: observed difference
  • 0: null value (from H_0: \mu_1 - \mu_2 = 0)
  • Compare to a t-distribution with df = n_1 + n_2 - 2

Same formula structure as Z and the one-mean T — observed minus null over SE. Because we estimate \sigma_1, \sigma_2 from samples, the reference distribution is a t-distribution (with df = n_1 + n_2 - 2 here) — coming up next.

The t-Distribution (Again)

Under H_0, T = (\bar{x}_1 - \bar{x}_2)/SE follows a t-distribution with df = n_1 + n_2 - 2.

  • Bell-shaped and symmetric like the normal
  • Thicker tails (extra uncertainty from estimating \sigma_1, \sigma_2 from samples)
  • Smaller total n → thicker tails
  • As df grows, t approaches the normal

For Birth Weights, df = 979 — the t curve is essentially normal here.

Statistic & Test Statistic

For each scenario, identify the statistic of interest and the test statistic (Z or T).

  1. A campus survey asks 600 students whether they have used a generative AI tool. Is the rate different from 50%? Statistic: \hat{p} (single proportion). Test statistic: Z — normal model (topic 6).

  2. 50 plots are randomly assigned to two fertilizer treatments. Do the mean yields differ? Statistic: \bar{x}_1 - \bar{x}_2 (difference of means). Test statistic: T — t-distribution with df = n_1 + n_2 - 2 (today).

  3. A nutrition study measures sodium in 40 fast-food burgers. Is the mean sodium different from 1200 mg? Statistic: \bar{x} (single mean). Test statistic: T — t-distribution with df = n - 1 (topic 11).

Putting It Together for Birth Weights

Hypotheses (two-sided): H_0: \mu_n - \mu_s = 0 vs H_A: \mu_n - \mu_s \neq 0

Samples

  • Nonsmokers: n_n = 867, \bar{x}_n = 7.27, s_n = 1.23
  • Smokers: n_s = 114, \bar{x}_s = 6.68, s_s = 1.6
  • Observed difference: \bar{x}_n - \bar{x}_s \approx 0.59 lbs

Conditions met (random sample; both group sizes ≥ 30; similar SDs). Coming up: compute s_p → SE → T → p-value → conclude.

Computing T for Birth Weights

Pooled SD

s_p = \sqrt{\frac{(867 - 1)(1.23)^2 + (114 - 1)(1.6)^2}{867 + 114 - 2}} \approx 1.28

Standard error

SE = 1.28 \times \sqrt{\frac{1}{867} + \frac{1}{114}} \approx 0.128 \text{ lbs}

Try it: plug into T = \dfrac{\bar{x}_n - \bar{x}_s}{SE}.

T = \dfrac{\bar{x}_n - \bar{x}_s}{SE} \approx 4.65 — observed difference sits about 4.6 SEs from zero.

Calculating the P-value

Two-sided p-value = 2 × (smaller-tail area) ≈ < 0.0001 — the observed difference sits far out in the tail.

Conclusion for Birth Weights

Results: T \approx 4.65 (df = 979), p-value < 0.0001 — well below 0.05 → reject H_0.

Conclusion: Convincing evidence that mean birth weight differs between U.S. babies born to nonsmoking vs. smoking mothers.

In plain terms: nonsmokers’ babies averaged about 0.59 pounds heavier in the sample; a gap this large is extremely unlikely if the population means were equal.

Scope: random sample of 2014 U.S. births → conclusion generalizes to all 2014 U.S. births. Observational data → cannot conclude that smoking causes lower birth weight (third-variable explanations like prenatal care, nutrition, alcohol use, age remain possible).

Mario Kart Auctions

You’ve been collecting copies of Mario Kart for the Nintendo Wii and decide to sell them on eBay. Should you bother photographing each disc yourself, or just use a stock photo of the box? Does using a stock photo affect the selling price?

Data (Diez et al., OpenIntro):

Photo n \bar{x} ($) s ($)
Stock (yes) 105 48.50 9.47
No stock (no) 36 44.33 7.25

  1. State H_0 and H_A for \mu_y - \mu_n (two-sided). H_0: \mu_y - \mu_n = 0    H_A: \mu_y - \mu_n \neq 0.

  2. What’s the observed difference? 48.50 - 44.33 = \$4.17 — stock-photo auctions averaged about four dollars more in the sample.

EDA: Mario Kart

Take a moment with the shapes and spreads of each group — you’ll use what you see on the next slide.

Mario Kart — Conditions

Recall: stock (yes): n_y = 105, \bar{x}_y = 48.50, s_y = 9.47. No stock: n_n = 36, \bar{x}_n = 44.33, s_n = 7.25.

  1. Check independence, normality, and equal variance. Independence: auctions are separate listings, reasonably independent ✓. Normality: both group sizes \geq 30, so CLT applies; histograms showed no extreme outliers ✓. Equal variance: s_y \approx 9.47 vs. s_n \approx 7.25 — within a factor of two, consistent with the similar spreads in the histograms ✓. Conditions met.

Mario Kart — Compute T

Recall: stock (yes): n_y = 105, \bar{x}_y = 48.50, s_y = 9.47. No stock: n_n = 36, \bar{x}_n = 44.33, s_n = 7.25. Observed diff \bar{x}_y - \bar{x}_n = \$4.17; conditions met.

  1. Compute the degrees of freedom. df = n_y + n_n - 2 = 105 + 36 - 2 = 139

  2. Compute the pooled SD s_p. s_p = \sqrt{\dfrac{104 \cdot 9.47^2 + 35 \cdot 7.25^2}{139}} \approx 8.96

  3. Compute the standard error SE. SE = s_p \sqrt{\tfrac{1}{n_y} + \tfrac{1}{n_n}} = 8.96 \times \sqrt{\tfrac{1}{105} + \tfrac{1}{36}} \approx 1.73

  4. Compute T. T = \dfrac{\bar{x}_y - \bar{x}_n}{SE} = \dfrac{4.17}{1.73} \approx 2.41

Mario Kart — Conclusion

Recall: T \approx 2.41, df = 139. Observed diff \bar{x}_y - \bar{x}_n = \$4.17 (stock-photo higher); hypotheses two-sided.

  1. Two-sided p-value \approx 0.017. State your conclusion at \alpha = 0.05, including scope of inference. p-value < 0.05 → reject H_0. Convincing evidence that stock-photo and no-stock auctions have different mean prices (and stock-photo auctions sell for more on average). Scope: sample of eBay Mario Kart Wii auctions from a specific window — not a random sample of any wider population — so the conclusion is most defensible for similar listings. Observational (sellers chose how to photograph), so we can’t claim using a stock photo causes higher prices — it may reflect product condition, bundling, or listing style.

Looking Ahead

We’ve tested “Are the two means different?” using the t-distribution with df = n_1 + n_2 - 2.

Next time: a confidence interval for \mu_1 - \mu_2 — “By how much do the two means differ?” — using the same machinery.

References

  • Introduction to Modern Statistics (2e) textbook by Mine Çetinkaya-Rundel and Johanna Hardin
  • Sections 20.3, 20.4
  • Diez, D. M., Çetinkaya-Rundel, M., & Barr, C. D. OpenIntro Statistics — Mario Kart auction data.