Learning Outcomes
By the end of this section, students will be able to:
- Explain when and how to use post hoc testingÂ
- Explain the concept of multiple comparisons and be able to correct for it in their analysis
- Apply extensions to the basic ANOVA test and interpret their results
- Explain when and how to use repeated measures statistics
You can download a copy of the slides here:Â B2.4 Repeated Measures and the Paired t-test
B2.5 PRACTICAL: R
For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.
Most statistical software (as a default) always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.
Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.
The paired t test command in R is:
ttest(x, y, paired=TRUE)
Here we write:
mouse<-FoSSA_mouse_data
t.test(mouse$Weight_baseline, mouse$Weight_end, paired=TRUE)
- Question B2.5: Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?
Answer
Answer B2.5:
The output is:
> t.test(mouse$Weight_baseline, mouse$Weight_end, paired=TRUE)
Paired t-test
data: Â mouse$Weight_baseline and mouse$Weight_end
t = 0.069672, df = 59, p-value = 0.9447
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-0.6468068 Â 0.6934734
sample estimates:
mean difference
0.02333333
Our value for t is very small (0.070), which indicates a very small difference between the variables. Looking at the two tailed p-value (which is the default), there is no significant difference in weight between the start and end of the trial (p=0.94). We fail to reject the null hypothesis.
B2.5 PRACTICAL: Stata
For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.
Most statistical software (as a default) always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.
Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.
The paired t test command in Stata is:
ttest var1=var2
Here we write:
ttest Weight_baselin= Weight_end
- Question B2.5: Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?
Answer
The output is:

Our value for t is very small (0.070), which indicates a very small difference between the variables. Looking at the two tailed p-value (the middle value, Ha: mean(diff) !=0; P= 0.945), there is no significant difference in weight between the start and end of the trial. We fail to reject the null hypothesis.
B2.5 PRACTICAL: SPSS
For this test you need a variable that has been measured twice in the same participants, so open the FoSSA Mouse data set.
SPSS always assumes that each row is a participant, so if you have paired measurements you need to make sure you have stored them as separate variables, and they are matched up correctly so each participants ‘before’ and ‘after’ for example are on the same row in your data set.
Here we are going to do a paired t-test between the mouse weights at the start and end of the trial.
Select
Analyze >> Compare Means and Proportions >> Paired-Samples T Test
Move the two variables you are interested in into the spaces for Variable 1 and Variable 2 in Pair 1. In this case Weight_baseline and Weight_end.

You will notice that a second blank ‘pair’ is automatically created when you have completed the first pair. Also, your variables do not disappear from the box on the left hand side as they do in the majority of tests. This is because you can create multiple pairs to test in one go, and you can compare one variable to any number of variables.
Run the test and interpret the output. Is there a significant difference in mouse weight between the beginning and end of the trial?
Answer

Our value for t is very small (0.070), which indicates a very small difference between the variables.
SPSS has offered us a one-sided (one tailed) P value and a two-sided (two tailed) P value. As we didn’t make any predictions about the direction of change we want the two tailed P value.
Therefore P= 0.945 and there is no significant difference in weight between the start and end of the trial. We fail to reject the null hypothesis.
SPSS also automatically gives us an output for correlation between the variables when you run a paired t-test, so you will also see this in your output window.