Skip to Main Content

MASH : Maths and Stats Help

Paired Samples t-Test

Introduction

A Paired-Samples t-Test compares the means between two related groups, such as comparing the difference between pre-intervention and post-intervention test results.

It is considered a parametric test and is only suitable for parametric data. To check if your data is parametric, please check out the dedicated guide: Parametric or Not Guide (PDF)

If your data is non-parametric you should consider using a Wilcoxon Test.

 

Test procedure

Formula method

This is used for when the data is structured using a grouping variable. A grouping variable is a categorical variable indicating which scores belong to different groups.

Data:

Spreadsheet showing two variables on two columns: Class and English_score. There are 16 rows for each columns, each row being 1 observation.

The first argument entered in the t.test() function is a formula that takes the following structure:

dependent variable ~ independent variable

The second argument is the data frame.

The third argument needs to be “paired = TRUE”. The t.test() function runs an independent-samples t-test by default, this is why we need to specify the option in order for it to run a paired-samples t-test.

t.test(test_score ~ test_time, before_after1, paired = TRUE)
## 
##  Paired t-test
## 
## data:  test_score by test_time
## t = -2.5965, df = 19, p-value = 0.01772
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -7.7662346 -0.8337654
## sample estimates:
## mean difference 
##            -4.3

 

Variables method

This method is used when your data is structured into two separate variables. Both of your variables should be numeric.

Data:

Spreadsheet showing two variables on two columns: Group 1 and Group 2. There are 8 rows for each column.

Put both of your variables in the t.test() function in any order. The first variables will be subtracted from the second one in order to calculate the mean difference. If you have your variables stored in a data frame, use the following structure to indicate the variable: data_frame$variable_name

The third argument needs to be “paired = TRUE”. The t.test() function runs an independent-samples t-test by default, this is why we need to specify the option in order for it to run a paired-samples t-test.

t.test(before_after2$before, before_after2$after, paired = TRUE)
## 
##  Paired t-test
## 
## data:  before_after2$before and before_after2$after
## t = -2.5965, df = 19, p-value = 0.01772
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -7.7662346 -0.8337654
## sample estimates:
## mean difference 
##            -4.3

 

Results

R will generate largely the same output for both formula and variables methods.

 

Descriptive Statistics by group

The results show the mean difference between the two conditions, but no means and standard deviations for each condition. As they are are commonly reported, please check our guide on descriptive statistics.

Paired Samples Test

This table shows the specific test results including the t-statistic (t), the degrees of freedom (df) the two-tailed significance or p-value (Two-Sided p), and the 95% Confidence Interval (95% Confidence Interval of the Difference).

Homogeneity of variances?

As both variables are measurements coming from the same sample at different times (repeated measures), we assume that the variances are equal by default. 

 

Reporting the Results in APA Formatting

Students’ test results were compared before and after the intervention. On average, students performed better (M = 73.30, SD = 11.91) after the intervention than before (= 69.00, SD = 6.64). A Paired-Samples t-Test indicated this difference, d̄ = 4.30, 95%CI [0.83, 7.77] was statistically significant, (19) = 2.60, = .018.