Paired samples
Section of Hypothesis tests, part of Statistical inference · Also in Testing examples
Paired samples
| Type | Section |
| Taught in | Hypothesis tests · Testing examples |
| Part | Statistical inference · Data analysis |
In Hypothesis tests
From Hypothesis tests
Did the weighing above show that a student’s weight increases between first and third year? It did not, because different students were weighed. A better design weighs the same ten students twice.
| Student | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| First year | 71.6 | 69.7 | 50.0 | 56.9 | 60.9 | 77.5 | 53.9 | 49.6 | 32.3 | 61.3 |
| Third year | 83.4 | 77.7 | 57.9 | 67.0 | 69.2 | 87.4 | 63.7 | 59.0 | 39.7 | 71.1 |
| Difference | 11.8 | 8.0 | 7.9 | 10.1 | 8.3 | 9.9 | 9.8 | 9.4 | 7.4 | 9.8 |
The two columns are not independent samples: a heavy first-year is a heavy third-year. A two-sample t test would be wrong. Instead, let D_i be the difference for student i, and model D_1,\ldots,D_{10} as a normal random sample with mean \mu_D. Testing H_0:\mu_D=0 against \mu_D>0 is a one-sample t test on the differences.
The differences have mean 9.24 and standard deviation 1.33, so t=9.24/(1.33/\sqrt{10})=21.9 on 9 degrees of freedom, with p-value about 2\times10^{-9}. The evidence that weight increases is overwhelming. Treating the columns as independent samples gives t=1.54 instead, because the large spread between students swamps the small, consistent change within each one. Pairing is the right analysis when the two measurements share a unit, a subject or a block. The dependence it removes is a covariance: \operatorname{Var}(X-Y)=\operatorname{Var} X+\operatorname{Var} Y-2\operatorname{Cov}(X,Y).
In Testing examples
From Testing examples
Example 1 (Two labs on the same patients) Two labs measure the same quantity on the same 15 patients.
lab1 <- c(22, 18, 28, 26, 13, 8, 21, 26, 27, 29, 25, 24, 22, 28, 15)
lab2 <- c(25, 21, 31, 27, 11, 10, 25, 26, 29, 28, 26, 23, 22, 25, 17)Question. Do the labs differ on average?
Solution. The two columns are not independent: a patient with a low value gets it from both labs, as patient 6 does with 8 and 10. So analyse the differences D_i=X_i-Y_i as one sample, D_i\sim\operatorname{N}(\delta,\sigma^2), and test H_0:\delta=0 against \delta\neq0:
t.test(lab1, lab2, paired = TRUE)
# t = -1.7618, df = 14, p-value = 0.0999The mean difference is -0.93 with standard deviation 2.05, so t=-0.93/(2.05/\sqrt{15})=-1.76 and p=0.10. There is weak evidence, at most, that lab 2 reads higher. Ignoring the pairing and running a two-sample test gives t=-0.42 and p=0.68: the large differences between patients swamp the small, consistent difference between labs. Pairing removes the patient effect.
Used in
- Taught in Hypothesis tests · Testing examples
- Also used in Testing examples
- All 6 questions on Hypothesis tests
See also
Null and alternative hypotheses · Critical region · p-value · Type I and type II errors · Neyman–Pearson approach · Power function · One-sample t test · Two-sample t test