Pooled t • Nonpooled t •Mann-Whitney • Paired t • Paired Wilcoxon
We finished one-mean hypothesis testing (Ch. 9). Now we compare twopopulations.
The fundamental question: Is the mean of Population 1 different from the mean of Population 2? We use two independent samples to find out.
Population 1
e.g., Faculty in private institutions
Sample 1
Compute $\bar{x}_1$
Population 2
e.g., Faculty in public institutions
Sample 2
Compute $\bar{x}_2$
Compare
$\bar{x}_1 - \bar{x}_2$
to make a decision about $\mu_1 - \mu_2$
Suppose $x$ is normally distributed on each of two populations. For independent samples of sizes $n_1$ and $n_2$:
This is the foundation for every two-mean inference procedure. When $H_0: \mu_1 = \mu_2$ is true, then $\mu_1 - \mu_2 = 0$, so the difference $\bar{x}_1 - \bar{x}_2$ is centered at zero. A large observed difference is unlikely by chance alone — that's the basis of our test.
$\bar{x}_1 - \bar{x}_2$ centered at 0
Before choosing a test, identify the sampling design. The entire analysis depends on this.
The two samples are drawn completely separately from each other.Observations in Sample 1 have no natural pairing with observations in Sample 2.
Methods: Pooled t-test,Nonpooled t-test, Mann-Whitney
Each observation in Sample 1 is naturally matched to exactly one observation in Sample 2 — same subject measured twice, or matched pairs.
Methods: Paired t-test, Paired Wilcoxon
Used when we assume both populations have equal standard deviations ($\sigma_1 = \sigma_2$).
Suppose $x$ is normally distributed on each of two populations and population standard deviations are equal. For independent samples of sizes $n_1$ and $n_2$,the variable:
has the $t$-distribution with$df = n_1 + n_2 - 2$
Because we assume $\sigma_1 = \sigma_2$, we pool both sample variances into one combined estimate:
Weighted average of both sample variances — larger sample gets more weight.
| Type | $H_0$ | $H_a$ |
|---|---|---|
| Two-tailed | $\mu_1 = \mu_2$ | $\mu_1 \neq \mu_2$ |
| Left-tailed | $\mu_1 = \mu_2$ | $\mu_1 < \mu_2$ |
| Right-tailed | $\mu_1 = \mu_2$ | $\mu_1 > \mu_2$ |
For confidence level $1 - \alpha$, first find $t_{\alpha/2}$ with $df = n_1 +n_2 - 2$, then:
where $s_p = \sqrt{\dfrac{(n_1-1)s_1^2 +(n_2-1)s_2^2}{n_1+n_2-2}}$
Used when we do not assume equal standard deviations. The standard error uses both sample variances separately.
Suppose $x$ is normally distributed on two populations. For independent samples, the variable:
has approximately a$t$-distribution with $df = \Delta$ (rounded down to nearest integer)
Always round $\Delta$ down (use floor() in R). This keeps the procedure conservative.
In R:floor(delta) gives the correct $df$
Follows the same 6-step logic as the Pooled t-Test, but uses:
For confidence level $1-\alpha$, find $t_{\alpha/2}$ with $df = \Delta$:
If you are reasonably sure the standard deviations are nearly equal, use pooled;otherwise, use nonpooled.
t.test() with var.equal = TRUE performs the pooled test; var.equal = FALSE (the default) performs the nonpooled(Welch) test. Always comment on your choice.A nonparametric alternative for independent samples when normality cannot be assumed. Works on same-shape distributions.
Distributions have the same shape if they are identical except for the location of their centers.
Assumptions: Simple random independent samples from same-shape populations.
Test Statistic $M$: Combine both samples, rank all observations from smallest (1) to largest. Then:
Complement Relation:
| Populations | Shape | Use |
|---|---|---|
| Normal | Same ($\sigma_1 = \sigma_2$) | Pooled t-test |
| Normal | Different | Nonpooled t-test |
| Non-normal | Same shape | Mann-Whitney |
| Not both normal | Different, large $n$ | Nonpooled t-test |
| Not both normal | Different, small $n$ | Consult statistician |
When each observation in one sample is naturally matched to an observation in the other, we work with the paired differences $d = x_1 - x_2$.
Instead of comparing two separate samples, we reduce the problem to aone-sample analysis on the differences:
Then use $\bar{d}$ (mean of differences) and $s_d$ (SD of differences) just like the one-mean tests from Chapter 9.
For paired samples of size $n$, if the paired-difference variable $d$ is normally distributed:
has the $t$-distribution with$df = n - 1$
Assumptions: Simple random paired sample; normal differences or large sample ($n \geq 30$).
For confidence level $1-\alpha$, find $t_{\alpha/2}$ with $df = n-1$:
When paired differences are not normally distributed but aresymmetric, use this nonparametric alternative.
Assumptions: Simple random paired sample; symmetric differences.
Steps:
Use Table V (Wilcoxon) or software for P-values.
| Differences | Use |
|---|---|
| Normal (or large $n$) | Paired t-test |
| Non-normal, symmetric | Paired Wilcoxon |
| Non-normal, asymmetric, large $n$ | Paired t-test (CLT) |
| Non-normal, asymmetric, small $n$ | Consult statistician |
Use when assuming equal population standard deviations(var.equal = TRUE).
# --- METHOD A: Raw Data ---
x1 <- c(...) # Sample 1 observations
x2 <- c(...) # Sample 2 observations
# Pooled t-test (var.equal = TRUE assumes sigma1 = sigma2)
result <- t.test(x1, x2, var.equal = TRUE, conf.level = 0.95,
alternative = "two.sided") # or "less" / "greater"
result
# --- METHOD B: Summary Statistics ---
n1 <- ? ; xbar1 <- ? ; s1 <- ?
n2 <- ? ; xbar2 <- ? ; s2 <- ?
# Pooled SD
sp <- sqrt(((n1-1)*s1^2 + (n2-1)*s2^2) / (n1+n2-2))
# Test statistic
t_stat <- (xbar1 - xbar2) / (sp * sqrt(1/n1 + 1/n2))
df <- n1 + n2 - 2
# P-values (choose one based on Ha)
p_two <- 2 * (1 - pt(abs(t_stat), df)) # Ha: mu1 != mu2
p_left <- pt(t_stat, df) # Ha: mu1 < mu2
p_right <- 1 - pt(t_stat, df) # Ha: mu1 > mu2
# 95% Confidence Interval for mu1 - mu2
t_crit <- qt(0.975, df)
ci_low <- (xbar1 - xbar2) - t_crit * sp * sqrt(1/n1 + 1/n2)
ci_high <- (xbar1 - xbar2) + t_crit * sp * sqrt(1/n1 + 1/n2)
c(ci_low, ci_high)Default in R. Do not assume equal SDs — uses Welch's $\Delta$ degrees of freedom.
# --- METHOD A: Raw Data ---
x1 <- c(...) # Sample 1
x2 <- c(...) # Sample 2
# Nonpooled t-test (var.equal = FALSE is the R default = Welch test)
result <- t.test(x1, x2, var.equal = FALSE, conf.level = 0.95,
alternative = "two.sided") # or "less" / "greater"
result
# --- METHOD B: Summary Statistics ---
n1 <- ? ; xbar1 <- ? ; s1 <- ?
n2 <- ? ; xbar2 <- ? ; s2 <- ?
# Welch degrees of freedom (Delta) — round DOWN
delta <- ((s1^2/n1 + s2^2/n2)^2) /
((s1^2/n1)^2/(n1-1) + (s2^2/n2)^2/(n2-1))
df <- floor(delta)
# Test statistic
t_stat <- (xbar1 - xbar2) / sqrt(s1^2/n1 + s2^2/n2)
# P-values
p_two <- 2 * (1 - pt(abs(t_stat), df))
p_left <- pt(t_stat, df)
p_right <- 1 - pt(t_stat, df)
# 95% CI
t_crit <- qt(0.975, df)
margin <- t_crit * sqrt(s1^2/n1 + s2^2/n2)
c((xbar1 - xbar2) - margin, (xbar1 - xbar2) + margin)Use paired = TRUE when each row in x1 is matched to the corresponding row in x2.
# --- METHOD A: Raw Paired Data ---
x1 <- c(...) # Before (or Group 1), ordered by subject
x2 <- c(...) # After (or Group 2), same order
result <- t.test(x1, x2, paired = TRUE, conf.level = 0.95,
alternative = "two.sided") # or "less" / "greater"
result
# --- METHOD B: Work With Differences Directly ---
d <- x1 - x2 # Paired differences
dbar <- mean(d)
sd_d <- sd(d)
n <- length(d)
df <- n - 1
# Test statistic
t_stat <- dbar / (sd_d / sqrt(n))
# P-values (choose based on Ha)
p_two <- 2 * (1 - pt(abs(t_stat), df)) # Ha: mu1 != mu2
p_left <- pt(t_stat, df) # Ha: mu1 < mu2
p_right <- 1 - pt(t_stat, df) # Ha: mu1 > mu2
# 95% Confidence Interval for mu1 - mu2
t_crit <- qt(0.975, df)
ci_low <- dbar - t_crit * sd_d / sqrt(n)
ci_high <- dbar + t_crit * sd_d / sqrt(n)
c(ci_low, ci_high)Every two-mean procedure at a glance — assumptions, test statistic, and degrees of freedom.
| Procedure | Key Assumptions | Test Statistic | df |
|---|---|---|---|
| Pooled t-test Proc. 10.1 | Independent, Normal/Large, $\sigma_1 = \sigma_2$ | $t = \dfrac{\bar{x}_1 - \bar{x}_2}{s_p \sqrt{1/n_1 + 1/n_2}}$ | $n_1 + n_2 - 2$ |
| Nonpooled t Proc. 10.3 | Independent, Normal/Large, $\sigma_1, \sigma_2$ unrestricted | $t = \dfrac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}$ | $\Delta$ (Welch) |
| Mann-Whitney Proc. 10.5 | Independent, Same-shape distributions | $M = \text{sum of ranks (Sample 1)}$ | — |
| Paired t-test Proc. 10.6 | Paired, Normal differences or large $n$ | $t = \dfrac{\bar{d}}{s_d / \sqrt{n}}$ | $n - 1$ |
| Paired Wilcoxon Proc. 10.8 | Paired, Symmetric differences | $W = \text{sum of positive ranks}$ | — |
t.test(x1, x2) uses Welch (nonpooled). Add var.equal=TRUE for pooled, paired=TRUE for paired.