Paired t-Test in R: How to Perform, Interpret, and Report Results with Examples
The paired t-test is one of the most commonly used statistical tests for comparing two related measurements. It determines whether the mean difference between paired observations is statistically significant.
This test is widely applied in clinical trials, manufacturing, education, finance, agriculture, psychology, and quality improvement studies where the same subjects or experimental units are measured twice.
In this tutorial, you’ll learn when to use a paired t-test, its assumptions, mathematical formulation, practical applications, and how to perform it in R with a real example.
What Is a Paired t-Test?
A paired t-test (also called a dependent samples t-test or matched pairs t-test) compares two sets of observations that are naturally paired.
Rather than comparing two independent groups, the paired t-test evaluates the difference within each pair.
Examples include:
- Before and after treatment
- Weight before and after a diet program
- Blood pressure before and after medication
- Machine performance before and after maintenance
- Student scores before and after training
- Customer satisfaction before and after a service improvement
The goal is to determine whether the average difference between paired observations is significantly different from zero.
When Should You Use a Paired t-Test?
Use a paired t-test when:
- The same subjects are measured twice.
- Observations are naturally paired.
- The response variable is continuous.
- Differences between paired observations are approximately normally distributed.
Typical scenarios include:
- Clinical studies
- Manufacturing process improvements
- Educational interventions
- Agricultural experiments
- Psychological studies
- Sports performance analysis
Paired vs Independent t-Test
| Feature | Paired t-Test | Independent t-Test |
|---|---|---|
| Samples | Related | Independent |
| Subjects | Same individuals measured twice | Different groups |
| Example | Before vs After | Male vs Female |
| Dependency | Yes | No |
Mathematical Formulation
Suppose we have two measurements:
- X1: Before treatment
- X2: After treatment
The paired difference isdi=X1i−X2i
The test evaluates the mean of these differences.
Test Statistic
The paired t-statistic ist=sd/ndˉ
where:
- dˉ = mean of the paired differences
- sd = standard deviation of the paired differences
- n = number of pairs
The test statistic follows a t-distribution with:df=n−1
Hypotheses
Null Hypothesis (H₀)
μd=0
There is no mean difference between paired observations.
Alternative Hypothesis (H₁)
For a two-sided test:μd=0
The mean difference is not zero.
One-sided alternatives may also be used when there is a directional hypothesis.
Example Dataset
Suppose we measure the diameter of manufactured components before and after calibration.
Before (X1)
2.265
2.267
2.264
2.267
2.268
2.263
2.264
2.258
After (X2)
2.270
2.268
2.269
2.273
2.270
2.270
2.268
2.268Manual Calculation
Differences:d=X1−X2
Summary statistics:
- Mean difference = −0.005
- Standard deviation = 0.0028
- Sample size = 8
The calculated t-statistic is approximately:t=−5.05
Degrees of freedom:df=8−1=7
Using a significance level of 5%, the critical t-value is approximately:±2.365
Since∣t∣=5.05>2.365
we reject the null hypothesis.
Conclusion: The pre- and post-measurements differ significantly.
Note: In modern statistical practice, decisions are typically based on the p-value rather than comparing the test statistic with a critical value.
Assumptions of the Paired t-Test
Before applying the paired t-test, verify these assumptions:
- The observations are paired.
- Pairs are independent of one another.
- The response variable is continuous.
- The differences between pairs are approximately normally distributed.
- There are no extreme outliers among the paired differences.
Checking Normality in R
Since the paired t-test assumes normality of the differences, not the original variables, you can use the Shapiro–Wilk test:
X1 <- c(2.265,2.267,2.264,2.267,2.268,2.263,2.264,2.258)
X2 <- c(2.270,2.268,2.269,2.273,2.270,2.270,2.268,2.268)
difference <- X1 - X2
shapiro.test(difference)If the p-value is greater than 0.05, the normality assumption is generally considered reasonable.
Performing a Paired t-Test in R
Create the two vectors:
X1 <- c(
2.265,2.267,2.264,2.267,
2.268,2.263,2.264,2.258
)
X2 <- c(
2.270,2.268,2.269,2.273,
2.270,2.270,2.268,2.268
)Run the paired t-test:
t.test(
X1,
X2,
paired = TRUE,
alternative = "two.sided"
)Sample Output
Paired t-test
data: X1 and X2
t = -5.00
df = 7
p-value = 0.001565
alternative hypothesis:
true difference in means is not equal to 0
95 percent confidence interval:
-0.007364624 -0.002635376
sample estimates:
mean difference = -0.005Interpreting the Results
Test Statistic
t = -5.00The negative sign indicates that the average value of X1 is lower than X2.
Degrees of Freedom
df = 7Degrees of freedom equal the number of pairs minus one.
P-value
0.001565Since
0.001565 < 0.05there is strong evidence against the null hypothesis.
Confidence Interval
(-0.00736, -0.00264)Because the confidence interval does not include zero, it supports the conclusion that a statistically significant difference exists between the paired measurements.
Reporting the Results
A concise report might read:
A paired t-test was conducted to compare measurements before and after calibration. The analysis showed a statistically significant difference between the two measurements, t(7) = -5.00, p = 0.0016. The mean paired difference was -0.005 (95% CI: -0.00736 to -0.00264).
When the Assumptions Are Violated
If the paired differences are not approximately normally distributed, especially with small sample sizes, consider using the Wilcoxon signed-rank test, a non-parametric alternative:
wilcox.test(
X1,
X2,
paired = TRUE
)Practical Applications
Paired t-tests are widely used in:
- Clinical trials
- Pharmaceutical research
- Medical diagnostics
- Manufacturing quality improvement
- Educational assessments
- Agricultural experiments
- Financial performance analysis
- Marketing effectiveness studies
- Sports science
- Environmental monitoring
Common Mistakes
Avoid these common errors:
- Using a paired t-test for independent groups.
- Checking normality of the original variables instead of the paired differences.
- Ignoring extreme outliers.
- Treating repeated measurements as independent observations.
- Reporting only the p-value without the mean difference and confidence interval.
Conclusion
The paired t-test is an essential statistical method for comparing two related measurements. By focusing on the differences within each pair, it accounts for individual variability and provides a more powerful analysis than an independent samples t-test when observations are naturally matched.
R makes paired t-test analysis straightforward with the t.test() function. After verifying the assumptions, a single line of code provides the test statistic, p-value, confidence interval, and estimated mean difference. When the assumptions are not met, the Wilcoxon signed-rank test offers a robust non-parametric alternative.
Mastering the paired t-test enables analysts and researchers to evaluate interventions, monitor process improvements, and make evidence-based decisions across a wide range of scientific and business applications.

