Paired t-test
Two data samples are said to be paired (or matched) if they come from repeated observations of the same subject. Here, we assume that the data populations follow the normal distribution.
Using the paired t-test, we can obtain an interval estimate of the difference of the population means. There must be equal numbers of elements in both sets.
The t.test()
function can be used to perform paired
t-tests by specifying the argument paired = TRUE
.
Barley Yield Example
In the built-in data set named immer
,
the barley yield in years 1931 and 1932 for the same fields is recorded.
Fertilizer treatments were applied in the interim. The study aimed to
determine whether the treatment was effective.
The yield data are presented in the data frame columns
Y1
and Y2
.
Loc Var Y1 Y2
1 UF M 81.0 80.7
2 UF S 105.4 82.3
...
Assuming the data in immer
follows the normal
distribution, we want to find the 95% confidence interval
estimate of the difference between the mean barley yields.
We apply the t.test()
function to compute the difference
in means of the matched samples. As it is a paired test, we set the
paired
argument as TRUE
.
Paired t-test
data: Y1 and Y2
t = 3.324, df = 29, p-value = 0.002413
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
6.121954 25.704713
sample estimates:
mean of the differences
15.91333
Between years 1931 and 1932 in the data set immer
, the
95% confidence interval of the difference in means of
the barley yields is the interval between 6.122 and
25.705.
We conclude that the fertilizer treatments were successful in improving barley yields.