Two-Sample Tests
Learn to compare two groups with hypothesis tests. Master independent t-tests, paired t-tests, and two-proportion tests.
On This Page
Comparing Two Groups
Two-sample tests help answer questions like:
- Is treatment A better than treatment B?
- Do men and women differ in some measurement?
- Did scores improve after an intervention?
| Study Design | Test |
|---|---|
| Two independent groups | Independent t-test |
| Same subjects, two measurements | Paired t-test |
| Two proportions | Two-proportion z-test |
Independent Two-Sample t-Test
Compares means of two separate groups of subjects.
Usually testing H₀: μ₁ - μ₂ = 0, so:
Degrees of Freedom
Welch’s approximation (unequal variances assumed):
Conservative approach: df = min(n₁ - 1, n₂ - 1)
Question: Do two teaching methods produce different test scores?
Group 1 (Method A): n₁ = 25, x̄₁ = 78, s₁ = 8 Group 2 (Method B): n₂ = 30, x̄₂ = 72, s₂ = 10 α = 0.05, two-tailed
Hypotheses:
- H₀: μ₁ = μ₂ (no difference)
- H₁: μ₁ ≠ μ₂ (different)
Standard error:
Test statistic:
df (conservative) = min(24, 29) = 24 Critical t = ±2.064
Decision: Since 2.47 > 2.064, reject H₀
Conclusion: Evidence suggests the methods produce different results.
Pooled vs Unpooled Variance
| Method | When to Use |
|---|---|
| Pooled (equal variances) | When σ₁ = σ₂ can be assumed |
| Unpooled (Welch’s) | When σ₁ ≠ σ₂ or unsure |
df = n₁ + n₂ - 2
Paired t-Test
Use when the same subjects are measured twice or subjects are matched in pairs.
Calculate differences:
df = n - 1 (where n = number of pairs)
Question: Does a training program improve typing speed?
10 people measured before and after training:
| Person | Before | After | Difference (d) |
|---|---|---|---|
| 1 | 45 | 52 | 7 |
| 2 | 38 | 41 | 3 |
| 3 | 55 | 60 | 5 |
| 4 | 42 | 49 | 7 |
| 5 | 50 | 53 | 3 |
| 6 | 35 | 42 | 7 |
| 7 | 48 | 51 | 3 |
| 8 | 41 | 47 | 6 |
| 9 | 52 | 58 | 6 |
| 10 | 44 | 48 | 4 |
Statistics: n = 10, d̄ = 5.1, s_d = 1.73
Hypotheses:
- H₀: μ_d = 0 (no improvement)
- H₁: μ_d > 0 (improvement)
Test statistic:
df = 9, critical t (α = 0.05, one-tailed) = 1.833
Decision: Since 9.32 > 1.833, reject H₀
Conclusion: Strong evidence that training improves typing speed.
Why Paired Tests Are More Powerful
Two-Proportion z-Test
Compares proportions between two independent groups.
Where (pooled proportion)
Question: Is there a difference in cure rates between two drugs?
Drug A: 80 cured out of 100 (p̂₁ = 0.80) Drug B: 65 cured out of 100 (p̂₂ = 0.65) α = 0.05, two-tailed
Hypotheses:
- H₀: p₁ = p₂
- H₁: p₁ ≠ p₂
Pooled proportion:
Standard error:
Test statistic:
Critical values: ±1.96
Decision: Since 2.38 > 1.96, reject H₀
Conclusion: Evidence suggests cure rates differ between drugs.
Independent vs Paired: How to Decide
| Feature | Independent | Paired |
|---|---|---|
| Subjects | Different people in each group | Same people (or matched pairs) |
| Sample sizes | Can be different | Must be equal (n pairs) |
| Design | Random assignment to groups | Before/after, matching |
| Analysis | Compare two group means | Analyze differences |
Independent samples:
- Compare men’s and women’s salaries
- Treatment group vs control group (different people)
Paired samples:
- Weight before and after diet (same people)
- Left hand vs right hand reaction time (same people)
- Ratings of two products by same consumers
Assumptions and Conditions
For Independent t-Test
- Random samples
- Independent groups
- Normal populations OR large n (each group)
- Equal variances (if using pooled test)
For Paired t-Test
- Random sample of pairs
- Paired observations
- Differences are approximately normal OR large n
For Two-Proportion Test
- Independent random samples
- n₁p̂₁ ≥ 10, n₁(1-p̂₁) ≥ 10
- n₂p̂₂ ≥ 10, n₂(1-p̂₂) ≥ 10
Summary
In this lesson, you learned:
- Independent t-test: Compares means of two separate groups
- Paired t-test: Compares means when subjects are measured twice (analyze differences)
- Two-proportion z-test: Compares proportions between two groups
- Paired tests control for individual differences and are often more powerful
- Use Welch’s t-test (unpooled) when variances may differ
- Always check assumptions before conducting tests
Practice Problems
1. Group 1: n = 15, x̄ = 85, s = 7 Group 2: n = 18, x̄ = 80, s = 9 Test if means differ at α = 0.05.
2. 12 patients’ blood pressure before and after medication: d̄ = -8.5 (decrease), s_d = 6.2 Test if medication reduces blood pressure (one-tailed, α = 0.05).
3. Survey: 45 of 150 men and 62 of 180 women support a policy. Test if proportions differ at α = 0.05.
4. A researcher wants to test if a new fertilizer increases crop yield. She has 20 fields, and applies the fertilizer to half of each field. Should she use independent or paired t-test? Why?
Click to see answers
1. Independent t-test
df (conservative) = min(14, 17) = 14 Critical t = ±2.145
Since |1.79| < 2.145, fail to reject H₀ No significant difference between groups.
2. Paired t-test
H₀: μ_d = 0, H₁: μ_d < 0
df = 11, critical t (one-tailed, α = 0.05) = -1.796
Since -4.75 < -1.796, reject H₀ Strong evidence medication reduces blood pressure.
3. Two-proportion z-test
p̂₁ = 45/150 = 0.30, p̂₂ = 62/180 = 0.344 p̂ = (45 + 62)/(150 + 180) = 107/330 = 0.324
Critical z = ±1.96
Since |-0.85| < 1.96, fail to reject H₀ No significant difference in proportions.
4. Paired t-test
Each field serves as its own control. Half gets fertilizer, half doesn’t. The two measurements (treated vs untreated) come from the same field.
Pairing controls for field-to-field variation (soil quality, drainage, etc.), making it easier to detect the fertilizer effect.
Next Steps
Continue with more advanced testing:
- ANOVA - Compare more than two groups
- Chi-Square Tests - Categorical data
- T-Test Calculator - Practice calculations
Was this lesson helpful?
Help us improve by sharing your feedback or spreading the word.