12. Inference for Two Independent Means
b. Confidence Interval
Math 115
From Testing to Estimation
The hypothesis test answers “Is there a difference?”
But we also want to know “How big is the difference?”
Solution: a confidence interval for \(\mu_1 - \mu_2\) using the t-distribution.
Same machinery as 12a — same conditions, same \(s_p\) , same \(SE = s_p\sqrt{1/n_1 + 1/n_2}\) , same \(df = n_1 + n_2 - 2\) . New piece: a t critical value \(t^*\) replaces the test statistic.
In twelve A the hypothesis test answered the yes-or-no question of whether the two population means differ. For birth weights, we rejected the null at p less than zero point zero zero zero one — so the mean birth weights of nonsmokers’ and smokers’ babies are different. Today we ask the second half: by how much? The machinery is identical to twelve A — same conditions, same pooled standard deviation s sub p, same standard error formula, same degrees of freedom of n sub one plus n sub two minus two. The only new piece is the t critical value t-star, which sets the width of the confidence interval, replacing the test statistic from twelve A.
Recap: Birth Weights and Smoking
Do infants born to smokers have different mean birth weights than nonsmokers? Random sample of 981 U.S. births from 2014.
Hypotheses (two-sided) , with \(\mu_n, \mu_s\) = mean birth weight for nonsmokers / smokers:
\(H_0: \mu_n - \mu_s = 0\) vs \(H_A: \mu_n - \mu_s \neq 0\)
The data:
Nonsmoker
867
7.27
1.23
Smoker
114
6.68
1.6
From 12a: \(T \approx 4.65\) , p-value \(< 0.0001\) → rejected \(H_0\) . The population means differ . Today: by how much?
Quick recap of the birth weights example. A random sample of nine hundred eighty-one U.S. births from twenty-fourteen compared birth weights for babies born to nonsmokers and to smokers. The hypotheses are two-sided: null says the two population mean birth weights are equal, alternative says they differ. The data: eight hundred sixty-seven nonsmoker births with sample mean seven point two seven pounds and standard deviation one point two three; one hundred fourteen smoker births with sample mean six point six eight pounds and standard deviation one point six. The twelve A hypothesis test gave T about four point six five with a p-value below zero point zero zero zero one, so we rejected the null and concluded the population means differ. Today we ask the second half: by how much?
Conditions for the CI
Same three conditions as the hypothesis test in 12a:
Independence: random sample of 2014 U.S. births ✓
Normality: \(n_n = 867\) and \(n_s = 114\) — both well above 30, no extreme outliers in the 12a histograms ✓
Equal variance: \(s_n \approx 1.23\) vs. \(s_s \approx 1.6\) — close ✓
All conditions met. No new check; we can build the interval.
These are the same three conditions we verified for the hypothesis test, so there’s no new work here. The data come from a random sample of twenty-fourteen U.S. births, which gives us independence. Both group sizes sit well above thirty, and the histograms from twelve A showed no extreme outliers, so the Central Limit Theorem covers normality. The two sample standard deviations are close enough that the equal-variance condition holds as well. With all three met, we can build the interval using the pooled t-distribution.
Pooled SD and SE for Birth Weights
Samples (from 12a): \(n_n = 867\) , \(s_n = 1.23\) ; \(n_s = 114\) , \(s_s = 1.6\) ; \(\bar{x}_n - \bar{x}_s \approx 0.59\) lbs.
The CI uses the same \(s_p\) and \(SE\) as the 12a test — worth rebuilding once in the CI setting.
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}\]
(Degrees of freedom: \(df = n_n + n_s - 2 = 979\) .)
Before we form the interval, let’s rebuild the two ingredients that go into it — the same pooled standard deviation and standard error we computed for the hypothesis test in twelve A. It’s worth walking through them once more in the confidence-interval setting. The pooled standard deviation combines the two sample standard deviations, weighted by their group sizes: eight hundred sixty-six times one point two three squared, plus one hundred thirteen times one point six squared, all divided by nine hundred seventy-nine, and then we take the square root, which comes to about one point two eight pounds. The standard error is that pooled standard deviation times the square root of one over eight hundred sixty-seven plus one over one hundred fourteen, which works out to about zero point one three pounds. The degrees of freedom is nine hundred seventy-nine, the total sample size minus two.
Computing the 95% CI for Birth Weights
From the previous slide: \(\bar{x}_n - \bar{x}_s \approx 0.59\) lbs, \(SE \approx 0.128\) lbs, \(df = 979\) .
t critical value: \(t^*_{979} \approx 1.962\) (95% confidence; very close to \(z^* = 1.96\) since \(df\) is large).
Margin of error: \(ME = t^* \times SE \approx 1.962 \times 0.128 \approx 0.25\) lbs.
95% CI: \((\bar{x}_n - \bar{x}_s) \pm ME = 0.59 \pm 0.25 \approx (0.34, 0.84)\) lbs.
Now pull the pieces together for birth weights. We have the observed difference of about zero point five nine pounds, the pooled standard error of about zero point one three pounds, and degrees of freedom of nine hundred seventy-nine. For ninety-five percent confidence at this many degrees of freedom, the t critical value t-star is about one point nine six — essentially equal to the z-star value of one point nine six, since the degrees of freedom are so large. The margin of error is t-star times the standard error, one point nine six times zero point one three, which is about zero point two five pounds. The ninety-five percent confidence interval is the observed difference plus or minus that margin of error, zero point five nine plus or minus zero point two five, giving a range from about zero point three four pounds up to about zero point eight four pounds.
Interpreting the CI
95% CI: \((0.34, 0.84)\) pounds.
Interpretation: We are 95% confident that the true mean birth weight for U.S. babies born to nonsmokers is between 0.34 and 0.84 pounds higher than for U.S. babies born to smokers.
Does the CI include 0? No — zero sits well below the entire interval.
This agrees with the hypothesis test in 12a : rejected \(H_0\) ↔︎ zero is outside the CI.
Scope: random sample of 2014 U.S. births → the interval generalizes to all 2014 U.S. births. Observational → the gap isn’t necessarily caused by smoking (prenatal care, nutrition, age may contribute).
The ninety-five percent confidence interval runs from about zero point three four pounds up to about zero point eight four pounds. Interpretation — we’re ninety-five percent confident that the true mean birth weight for U.S. babies born to nonsmokers is somewhere between zero point three four and zero point eight four pounds higher than for babies born to smokers. The interval excludes zero — zero sits well below the entire interval — which agrees with the twelve A hypothesis test, where we rejected the null. On scope, the same reasoning as twelve A applies. Because the data come from a random sample of twenty-fourteen U.S. births, the interval generalizes to all U.S. births that year. But the data are observational, so we can’t say smoking itself causes the gap — factors that travel with smoking, like prenatal care, nutrition, or maternal age, could contribute.
Mario Kart — CI Setup
By how much do stock-photo and no-stock auctions differ in mean price? Same Mario Kart data as 12a.
Stock (yes)
105
48.50
9.47
No stock (no)
36
44.33
7.25
Recall (from 12a): observed difference \(\bar{x}_y - \bar{x}_n = \$4.17\) ; \(df = 139\) ; hypothesis test gave \(T \approx 2.41\) , p-value \(\approx 0.017\) → rejected \(H_0\) .
Are the conditions for the CI met? Same conditions as 12a — independence (auctions are separate listings), normality (\(n\) ’s both above 30, and the 12a histograms showed no extreme outliers), equal variance (SDs within a factor of two). All conditions met ✓ .
Now for your turn on the Mario Kart example from twelve A. Same data — auctions for Mario Kart Wii, comparing prices for listings with a stock photo versus without. In twelve A the hypothesis test gave T about two point four one with a p-value of about zero point zero one seven, so we rejected the null. Today we estimate by how much the mean prices differ. As always, we check the conditions before computing the interval, so we start there. Advance when you are ready to see the answer. The conditions for the confidence interval are the same ones we checked for the hypothesis test in twelve A. The auctions are separate listings from different sellers, so they’re reasonably independent. Both group sizes are above thirty, and the histograms from twelve A showed no extreme outliers, so normality is covered. The two sample standard deviations, nine dollars forty-seven and seven dollars twenty-five, are within a factor of two of each other, so the equal-variance condition is reasonable. All three conditions hold.
Mario Kart — Pooled SD and SE
Recall: stock: \(n_y = 105\) , \(s_y = 9.47\) ; no stock: \(n_n = 36\) , \(s_n = 7.25\) ; \(df = n_y + n_n - 2 = 139\) .
The CI uses the same \(s_p\) and \(SE\) as the 12a test — rebuild them:
Compute the pooled SD \(s_p\) . \(s_p = \sqrt{\dfrac{(105-1)\,9.47^2 + (36-1)\,7.25^2}{139}} \approx 8.96\)
Compute the standard error \(SE\) . \(SE = s_p\sqrt{\tfrac{1}{n_y} + \tfrac{1}{n_n}} = 8.96\sqrt{\tfrac{1}{105} + \tfrac{1}{36}} \approx 1.73\)
Before computing the interval, rebuild the pooled standard deviation and the standard error — the same two quantities you found for the hypothesis test in twelve A. Try each step yourself, and advance when you are ready to see the answers. The pooled standard deviation is the square root of one hundred four times nine point four seven squared, plus thirty-five times seven point two five squared, all divided by one hundred thirty-nine, which comes to about eight dollars ninety-six. The standard error is the pooled standard deviation times the square root of one over one hundred five plus one over thirty-six, and eight dollars ninety-six times that root gives about one dollar seventy-three.
Mario Kart — CI & Conclusion
Recall: \(\bar{x}_y - \bar{x}_n = \$4.17\) , \(SE \approx 1.73\) , \(df = 139\) . Use \(t^*_{139} \approx 1.977\) for 95% confidence.
Compute the margin of error and 95% CI for \(\mu_y - \mu_n\) . \(ME = 1.977 \times 1.73 \approx 3.42\) ; 95% CI = \(4.17 \pm 3.42 \approx (0.75, 7.59)\) dollars.
Interpret the interval and check consistency with the 12a hypothesis test. We’re 95% confident the true mean price for stock-photo auctions is between about $0.75 and $7.59 higher than for no-stock auctions. The CI excludes 0 — consistent with rejecting \(H_0\) in 12a. The interval is fairly wide (more than $6 wide) and the lower bound is close to zero, so the practical size of the gap is somewhat uncertain.
State the scope of inference . Scope: these are eBay Mario Kart Wii auctions from one specific window — not a random sample of any wider population — so the interval is most defensible for similar listings. Observational (sellers chose how to photograph), so we can’t claim the stock photo causes higher prices.
With conditions met and the pieces from twelve A in hand, build the ninety-five percent confidence interval and interpret it. Work through the three steps yourself, and advance when you are ready to see each answer. The t critical value for ninety-five percent confidence with df one hundred thirty-nine is about one point nine eight. Margin of error is t-star times SE — one point nine eight times one dollar seventy-three, about three dollars forty-two. The ninety-five percent confidence interval is the observed difference of four dollars seventeen plus or minus three dollars forty-two, giving an interval from about seventy-five cents up to about seven dollars fifty-nine. We’re ninety-five percent confident that the true mean price for stock-photo auctions is between about seventy-five cents and seven dollars fifty-nine higher than for no-stock auctions. The interval excludes zero, consistent with rejecting the null in twelve A. But notice — it’s a fairly wide interval, more than six dollars wide, and the lower bound sits close to zero. So while we’re confident there’s some difference, the practical size of that difference is somewhat uncertain — it could be as small as about seventy-five cents per auction, or as large as several dollars. Finally, the scope of inference. These are eBay auctions from one particular window, not a random sample of any broader population, so the interval is most defensible for similar listings rather than for auctions everywhere. And because the sellers chose how to photograph their listings, the data are observational — so even though stock-photo listings sold for more, we can’t conclude the stock photo itself caused the higher price.
Factors Affecting Tests and CIs
H-tests — larger \(|T|\) → smaller p-value
\(T = \dfrac{\bar{x}_1 - \bar{x}_2}{SE}\)
Larger effect size \(|\bar{x}_1 - \bar{x}_2|\) → larger \(|T|\)
Larger sample sizes \(n_1, n_2\) → smaller SE → larger \(|T|\)
Smaller variability \(s_1, s_2\) → smaller SE → larger \(|T|\)
CIs — narrower = more precise
\((\bar{x}_1 - \bar{x}_2) \pm t^* \times SE\)
Larger sample sizes \(n_1, n_2\) → smaller SE and smaller \(t^*\) → narrower CI
Smaller variability \(s_1, s_2\) → smaller SE → narrower CI
Lower confidence level → smaller \(t^*\) → narrower CI
Stepping back, let’s pull together the factors that move our two inference quantities for a difference in means. For the hypothesis test, the strength of evidence — how large T is, and how small the p-value — depends on three things. The first is effect size: a bigger observed difference between the two sample means pushes T further from zero. The second is sample size: larger groups shrink the standard error, and a smaller standard error inflates T. The third is variability: smaller within-group standard deviations also shrink the pooled standard error and inflate T. For the confidence interval, those same factors act through the standard error, plus one more. Larger groups shrink the standard error and also nudge t-star down, since more degrees of freedom move t-star toward z-star, and both effects narrow the interval. Less within-group variability shrinks the standard error and narrows the interval. The confidence level is the factor unique to the interval: a lower level uses a smaller t-star and gives a narrower interval. Two your-turns are coming up next, first on the strength of the evidence and then on the width of the interval.
Strength of Evidence — Predict
Birth Weights recap: \(n_n = 867\) , \(n_s = 114\) , \(\bar{x}_n - \bar{x}_s \approx 0.59\) , \(s_n \approx 1.23\) , \(s_s \approx 1.6\) → \(T \approx 4.65\) , p-value \(< 0.0001\) .
For each variant (others held constant), does the evidence become stronger or weaker ?
The smoker sample had been 400 mothers instead of 114 (same group means and SDs). Stronger. Larger \(n_s\) → smaller SE → larger \(|T|\) . The “bottleneck” group is the small one, so growing it helps the most.
The observed difference had been only 0.20 lbs instead of 0.59 (same \(n\) s, same SDs). Weaker. Smaller effect size \(|\bar{x}_n - \bar{x}_s|\) → smaller \(|T|\) directly.
Both group SDs had been twice as large (same \(n\) s, same observed difference). Weaker. Larger SDs → larger \(s_p\) → larger SE → smaller \(|T|\) .
Birth Weights prediction practice on strength of evidence. The original study had eight hundred sixty-seven nonsmokers and one hundred fourteen smokers, observed difference about zero point five nine pounds, sample SDs around one point two three and one point six — giving a T of about four point six five and a p-value below zero point zero zero zero one. For each variant of the study, predict whether the evidence becomes stronger or weaker. Pause and think before advancing. Growing the smoker sample from one hundred fourteen up to four hundred mothers shrinks the standard error — the smoker group is the smaller of the two, so it’s the bottleneck for SE. Smaller SE means larger T, so the evidence becomes stronger. A smaller observed difference of zero point two pounds, instead of zero point five nine, shrinks the numerator of T directly — so the evidence becomes weaker. Doubling both group standard deviations doubles the pooled SD and so doubles the standard error, which cuts T roughly in half — so the evidence becomes weaker.
CI Width — Predict
Birth Weights recap: 95% CI = \((0.34,\ 0.84)\) lbs — width about 0.5 lbs.
For each variant (others held constant), does the CI become narrower or wider ?
The smoker sample had been 400 mothers instead of 114 (same group means and SDs). Narrower. Larger \(n_s\) → smaller SE and slightly smaller \(t^*\) → narrower CI.
They build a 99% CI instead of 95%. Wider. Higher confidence → larger \(t^*\) → wider CI. (More confidence costs precision.)
Both group SDs had been twice as large (same \(n\) s, same observed difference). Wider. Larger SDs → larger \(s_p\) → larger SE → wider CI.
Same kind of practice for confidence interval width on Birth Weights. The original ninety-five percent confidence interval ran from about zero point three four pounds to about zero point eight four pounds — about half a pound wide. For each variant, predict whether the interval narrows or widens. Growing the smoker sample to four hundred shrinks SE — same reason as the test version — and slightly shrinks t-star because df grows. Both effects pull the interval narrower. Switching from ninety-five to ninety-nine percent confidence requires a bigger t-star, so the interval gets wider. That’s the cost of more confidence. Doubling both group standard deviations doubles the pooled SD, which doubles SE — and that widens the interval.
Two Means and Two Proportions: Same Logic
Statistic
\(\hat{p}_1 - \hat{p}_2\)
\(\bar{x}_1 - \bar{x}_2\)
H-test SE
\(\sqrt{\hat{p}_{pool}(1-\hat{p}_{pool})(1/n_1 + 1/n_2)}\)
\(s_p \sqrt{1/n_1 + 1/n_2}\)
CI SE
\(\sqrt{\hat{p}_1(1-\hat{p}_1)/n_1 + \hat{p}_2(1-\hat{p}_2)/n_2}\)
\(s_p \sqrt{1/n_1 + 1/n_2}\)
Reference distribution
normal (\(z\) )
t (\(df = n_1 + n_2 - 2\) )
CI
\((\hat{p}_1 - \hat{p}_2) \pm z^* \cdot SE\)
\((\bar{x}_1 - \bar{x}_2) \pm t^* \cdot SE\)
Same skeleton — only the statistic, SE, and reference distribution change.
Step back and put two-proportion inference from topic ten next to two-mean inference from today. The statistic of interest changes — difference of two p-hats versus difference of two x-bars. The standard error formulas look different, but each captures sampling variability of its statistic; for proportions the H-test pools p-hats under the null and the CI uses separate p-hats, while for means we use the pooled standard deviation in both. The reference distribution shifts from the normal — z — for proportions, to a t-distribution with degrees of freedom n one plus n two minus two for means. The confidence interval has the same point-estimate-plus-or-minus-multiplier-times-SE shape. Same skeleton, same logic — only the statistic, the SE formula, and the reference distribution change.
Looking Ahead
We’ve now done inference for one proportion , two proportions , one mean , and two independent means — all with the same framework.
Next time: paired means — comparing two measurements on the same subjects (before/after, twin pairs, matched designs). The trick: reduce to one mean by taking the difference within each pair.
We’ve now run the full inference toolkit on one proportion, two proportions, one mean, and two independent means — all with the same framework: point estimate plus or minus a multiplier times SE for a confidence interval, and observed minus null over SE for a test. Next time we tackle a different study design — paired means, where we have two measurements on the same subjects. The trick is to reduce the paired data to a single mean by taking the difference within each pair, and then we’re back to one-mean inference from topic eleven.
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.