@chi has given a verbal description. Here is how it looks in the
R t.test
procedure.
x1 = c(125, 156, 140, 175, 153, 148, 180, 135, 168, 157)
x2 = c(120, 145, 142, 150, 160, 148, 160, 142, 162, 150)
d = x1-x2
summary(d); length(d); sd(d)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-7.0 -1.5 5.5 5.8 10.0 25.0
[1] 10 # number of differences
[1] 10.65416 # standard deviation of 10 differences
stripchart(d, meth="stack", pch=20)
Notice that the t statistic for the t tests below is as follows:
(mean(d) - 0)/(sd(d)/sqrt(10))
[1] 1.721507
First, doing a one-sample test on the differences d
to test
the null hypothesis that the population mean of the paired differences is $0.$ The sample mean of the differences is greater $\bar D = 5.8 > 0,$ but compared with the standard deviation $S_d = 10.65$ we cannot say that $\bar D$ is significantly larger than $0.$ The P-value exceeds $0.05 = 5\%,$
so the null hypothesis is not rejected. [The population difference might be anywhere between $-1.822$ and $13.422.]$
t.test(d)
One Sample t-test
data: d
t = 1.7215, df = 9, p-value = 0.1193
alternative hypothesis:
true mean is not equal to 0
95 percent confidence interval:
-1.821526 13.421526
sample estimates:
mean of x
5.8
Second, if you use the parameter pair=T
for t.test
, then the
program find the differences and does the same thing as above; the
t-statistic, degrees of freedom, and P-value are all the same as before.
t.test(x1, x2, pair=T)
Paired t-test
data: x1 and x2
t = 1.7215, df = 9, p-value = 0.1193
alternative hypothesis:
true difference in means is not equal to 0
95 percent confidence interval:
-1.821526 13.421526
sample estimates:
mean of the differences
5.8
Notes: (1) In both cases the null hypothesis is that the population
of pairs has mean $0$ and the alternative hypothesis is two-sided.
(Additional parameters in t.test
are required if you want to change either.)
(2) Because each pair is for a different individual it is reasonable
to assume that there is a positive correlation between x1
and x2
.
[Because x1
and x2
are not independent samples, it would be incorrect
to do a two-sample t.test.]
cor(x1,x2)
[1] 0.799743
Also, t tests are exact only if the data (differences here) are
from a normal population. With only $n=10$ differences it is difficult to assess normality of the differences. However, there
is no evidence of strong skewness in the stripchart, and there are no extreme outliers. Moreover,
a Shapiro-Wilk test shows that differences are consistent with a normal sample.
shapiro.test(d)
Shapiro-Wilk normality test
data: d
W = 0.93627, p-value = 0.5123