Statistics & Probability · Grade 12 and undergraduate
Comparing Two Groups: Two-Sample z and t Procedures
Quick answer
Many questions compare two groups: a new drug against the old one, or one class against another. For two proportions, the difference p̂₁ − p̂₂ has standard error √(p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂), and a test of no difference uses the pooled proportion. For two means, the difference x̄₁ − x̄₂ has standard error √(s₁²/n₁ + s₂²/n₂) and follows a t distribution. In both cases the variances add, because the two samples vary independently.
What you'll learn
- Build a confidence interval for a difference of two proportions
- Test whether two proportions differ, using the pooled proportion
- Build an interval and run a test for a difference of two means
- Explain why the variances of the two estimates add
The difference between two estimates
To compare two groups, estimate each one and look at the difference. Because the two samples are independent, the variance of the difference is the sum of the two variances, as in combining random variables:
| Comparing | Estimate | Standard error |
|---|---|---|
| two proportions | ||
| two means |
Intervals are estimate critical value standard error, with for proportions and for means.
Testing two proportions. Under , both samples estimate one common . Combine them into the pooled proportion and use
Testing two means. Use . By hand, take the degrees of freedom as the smaller of and ; software uses a slightly larger value from Welch’s formula.
Why variances add, even for a difference
Each estimate wobbles from sample to sample. When one estimate comes out high and the other low, the difference is pushed further from the truth, not closer. Independent errors never cancel on average, so subtracting two estimates adds their variances. The standard deviations do not add; the variances do, and the square root comes last.
Worked examples
Common mistakes
Practice problems
-
In one group of agree; in another, of . Find the pooled proportion.
Answer
Full solution
.
-
For Exercise 1, test against .
Answer
, p-value ; reject at .
Full solution
The standard error is , and .
-
For Exercise 1, find a confidence interval for .
Answer
About
Full solution
The standard error is , and .
-
Two groups of have means and , with and . Find the two-sample t statistic.
Answer
Full solution
The standard error is , and .
-
For Exercise 4, using df, is the difference significant at (two-sided)?
Answer
Yes
Full solution
The p-value is about .
With df, for , and .
-
Two independent estimates have standard errors and . What is the standard error of their difference?
Answer
Full solution
, not and not .
-
In Example 3, find a confidence interval for with df ().
Answer
About
Full solution
.
-
A student computes the standard error in Example 3 as . What went wrong?
Answer
Standard errors were added instead of variances.
Full solution
The correct value is . Adding the standard errors overstates the uncertainty.
Frequently asked questions
How do you test whether two proportions differ?
Use z = (p̂₁ − p̂₂)/√(p̂(1 − p̂)(1/n₁ + 1/n₂)), where p̂ is the pooled proportion of successes in both samples combined.
What is the standard error of a difference of two means?
√(s₁²/n₁ + s₂²/n₂). The squared standard errors of the two means add.
How many degrees of freedom does a two-sample t-test have?
Software uses a formula (Welch's) that gives a value between the smaller of n₁ − 1 and n₂ − 1 and n₁ + n₂ − 2. By hand, using the smaller of n₁ − 1 and n₂ − 1 is a safe, slightly cautious choice.
Why pool for the test but not the interval?
The test assumes the null hypothesis p₁ = p₂, so both samples estimate the same p. The interval makes no such assumption.
When should I use a paired test instead?
When the two measurements come in natural pairs, such as the same person before and after. Two-sample procedures are for independent groups.
Standards alignment
This lesson covers the following Common Core State Standards for Mathematics.
- CCSS.MATH.CONTENT.HSS.IC.B.5Making Inferences and Justifying ConclusionsUse data from a randomized experiment to compare two treatments; use simulations to decide if differences between parameters are significant.