Two-sample t test

Definition taught in Hypothesis tests, part of Statistical inference

Two-sample t test

Type Definition
Taught in Hypothesis tests
Part Statistical inference
Properties 1
Worked examples 1

For two independent normal samples with a common variance, the two-sample t statistic for H_0:\mu_1-\mu_2=\delta_0 is

T=\frac{\overline X_1-\overline X_2-\delta_0}{s_p\sqrt{1/n_1+1/n_2}},

with s_p^2 the pooled variance. Under H_0, T has the t_{n_1+n_2-2} distribution. The rejection regions are those of the one-sample test with n_1+n_2-2 degrees of freedom.

Properties

Two-sample t pivot

Main article: Two-sample t pivot

For two independent normal samples with a common variance,

T=\frac{(\overline X_1-\overline X_2)-(\mu_1-\mu_2)}{s_p\sqrt{1/n_1+1/n_2}}

has a t distribution with n_1+n_2-2 degrees of freedom.

Examples

Alice’s caffeine test

Worked example from Testing examples

The heart-rate changes in Alice’s caffeine experiment were 17, 22, 21, 16, 6, −2, 27, 15, 16, 20 for the caffeinated group and 4, 10, 7, −9, 5, 4, 5, 7, 6, 12 for decaf.

Question. Is there evidence that caffeine increases the heart rate?

Solution. Model the two groups as independent normal samples with means \mu_1 (caffeinated) and \mu_2 (decaf), and test H_0:\mu_1=\mu_2 against H_1:\mu_1>\mu_2.

caf   <- c(17, 22, 21, 16, 6, -2, 27, 15, 16, 20)
decaf <- c(4, 10, 7, -9, 5, 4, 5, 7, 6, 12)
t.test(caf, decaf, alternative = "greater")
# t = 3.3752, df = 15.74, p-value = 0.001966
t.test(caf, decaf, alternative = "greater", var.equal = TRUE)$p.value   # 0.001686

The difference in means is 10.7 beats per minute. R’s default is the Welch test, with 15.7 effective degrees of freedom and p-value 0.002; the pooled two-sample t test gives p=0.0017. Either way, a difference this large would be very unlikely without an effect of caffeine. Because the drink was assigned at random, the evidence is evidence that caffeine raises the heart rate, for people like Alice’s friends. The two-sided 95% Welch interval for the effect is (4.0,\ 17.4) beats per minute: an effect is clear, its size is not pinned down.

Used in

See also

Critical region · Null and alternative hypotheses · p-value · Type I and type II errors · Neyman–Pearson approach · Power function · One-sample t test · F test for equal variances

Glossary and index