Back to Course

FoSSA: Fundamentals of Statistical Software & Analysis

0% Complete
0/0 Steps
  1. Course Information

    Meet the Teaching Team
  2. Course Dataset 1
  3. Course Dataset 2
  4. MODULE A1: INTRODUCTION TO STATISTICS USING R, STATA, AND SPSS
    A1.1 What is Statistics?
  5. A1.2.1a Introduction to Stata
  6. A1.2.2b: Introduction to R
  7. A1.2.2c: Introduction to SPSS
  8. A1.3: Descriptive Statistics
  9. A1.4: Estimates and Confidence Intervals
  10. A1.5: Hypothesis Testing
  11. A1.6: Transforming Variables
  12. End of Module A1
    1 Quiz
  13. MODULE A2: POWER & SAMPLE SIZE CALCULATIONS
    A2.1 Key Concepts
  14. A2.2 Power calculations for a difference in means
  15. A2.3 Power Calculations for a difference in proportions
  16. A2.4 Sample Size Calculation for RCTs
  17. A2.5 Sample size calculations for cross-sectional studies (or surveys)
  18. A2.6 Sample size calculations for case-control studies
  19. End of Module A2
    1 Quiz
  20. MODULE B1: LINEAR REGRESSION
    B1.1 Correlation and Scatterplots
  21. B1.2 Differences Between Means (ANOVA 1)
  22. B1.3 Univariable Linear Regression
  23. B1.4 Multivariable Linear Regression
  24. B1.5 Model Selection and F-Tests
  25. B1.6 Regression Diagnostics
  26. End of Module B1
    1 Quiz
  27. MODULE B2: MULTIPLE COMPARISONS & REPEATED MEASURES
    B2.1 ANOVA Revisited - Post-Hoc Testing
  28. B2.2 Correcting For Multiple Comparisons
  29. B2.3 Two-way ANOVA
  30. B2.4 Repeated Measures and the Paired T-Test
  31. B2.5 Repeated Measures ANOVA
  32. End of Module B2
    1 Quiz
  33. MODULE B3: NON-PARAMETRIC MEASURES
    B3.1 The Parametric Assumptions
  34. B3.2 Mann-Whitney U Test
  35. B3.3 Kruskal-Wallis Test
  36. B3.4 Wilcoxon Signed Rank Test
  37. B3.5 Friedman Test
  38. B3.6 Spearman's Rank Order Correlation
  39. End of Module B3
    1 Quiz
  40. MODULE C1: BINARY OUTCOME DATA & LOGISTIC REGRESSION
    C1.1 Introduction to Prevalence, Risk, Odds and Rates
  41. C1.2 The Chi-Square Test and the Test For Trend
  42. C1.3 Univariable Logistic Regression
  43. C1.4 Multivariable Logistic Regression
  44. End of Module C1
    1 Quiz
  45. MODULE C2: SURVIVAL DATA
    C2.1 Introduction to Survival Data
  46. C2.2 Kaplan-Meier Survival Function & the Log Rank Test
  47. C2.3 Cox Proportional Hazards Regression
  48. C2.4 Poisson Regression
  49. End of Module C2
    1 Quiz

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

$ANOVA
  Effect DFn DFd        F         p p<.05         ges
2   time   2 118 0.866249 0.4231827       0.005896862

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Mauchly’s Test for Sphericity` Effect W p p<.05 2 time 0.7210093 7.590772e-05 *

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Sphericity Corrections` Effect GGe p[GG] p[GG]<.05 HFe p[HF] p[HF]<.05 2 time 0.7818665 0.4000192 0.7993554 0.4021355

The top table provides the results of a one-way repeated measures ANOVA if the assumption of sphericity is not violated. You want to look at the row for ‘time’, which shows that the p=0.42. We fail to reject the null hypothesis for a difference in weight across time.

The middle table indicates whether the assumption of sphericity is violated. As p<0.05, we reject the null hypothesis of sphericity, and so will use the sphericity corrections table below.

The bottom table which presents three types of corrections. We can see that the results are consistent and that we do not find evidence to reject the null hypothesis.

Controlling for between-subjects factors

 If we want to run this ANOVA again, but control for ‘strain group’, we must first ensure it is a factor. R currently has coded it as an integer value, so we convert to a factor:

> mice$Strain_group=as.factor(mice$Strain_group)

We can then add the between subject factor into the ezANOVA command, using the between argument as below:

> repeat2<-ezANOVA(data=mice,dv=weight,wid=id,within=time, between = Strain_group,type=3)
> repeat2

This produces the following results:

$ANOVA
             Effect DFn DFd         F            p p<.05         ges
2      Strain_group   2  57  4.334436 1.768830e-02     * 0.091243692
3              time   2 114  1.269825 2.848232e-01       0.007513324
4 Strain_group:time   4 114 14.743714 9.747582e-10     * 0.149509880

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

$ANOVA
  Effect DFn DFd        F         p p<.05         ges
2   time   2 118 0.866249 0.4231827       0.005896862

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Mauchly’s Test for Sphericity` Effect W p p<.05 2 time 0.7210093 7.590772e-05 *

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Sphericity Corrections` Effect GGe p[GG] p[GG]<.05 HFe p[HF] p[HF]<.05 2 time 0.7818665 0.4000192 0.7993554 0.4021355

The top table provides the results of a one-way repeated measures ANOVA if the assumption of sphericity is not violated. You want to look at the row for ‘time’, which shows that the p=0.42. We fail to reject the null hypothesis for a difference in weight across time.

The middle table indicates whether the assumption of sphericity is violated. As p<0.05, we reject the null hypothesis of sphericity, and so will use the sphericity corrections table below.

The bottom table which presents three types of corrections. We can see that the results are consistent and that we do not find evidence to reject the null hypothesis.

Controlling for between-subjects factors

 If we want to run this ANOVA again, but control for ‘strain group’, we must first ensure it is a factor. R currently has coded it as an integer value, so we convert to a factor:

> mice$Strain_group=as.factor(mice$Strain_group)

We can then add the between subject factor into the ezANOVA command, using the between argument as below:

> repeat2<-ezANOVA(data=mice,dv=weight,wid=id,within=time, between = Strain_group,type=3)
> repeat2

This produces the following results:

Mauchly’s Test for Sphericity` Effect W p p<.05 3 time 0.873398 0.02259129 * 4 Strain_group:time 0.873398 0.02259129 *

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

$ANOVA
  Effect DFn DFd        F         p p<.05         ges
2   time   2 118 0.866249 0.4231827       0.005896862

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Mauchly’s Test for Sphericity` Effect W p p<.05 2 time 0.7210093 7.590772e-05 *

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.5 Repeated Measures ANOVA.pdf

B2.5 PRACTICAL: R

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end.

You will need to install and load the packages tidyverse, dplyr, and rstatix to perform the necessary commands.

To create a subject ID variable, we can use:

> mice$id <- 1:nrow(mice)

We then reshape our data to long format:

> mice <- mice %>%
>   gather(key = “time”, value = “weight”, Weight_baseline, Weight_mid, Weight_end) %>%
>   convert_as_factor(id, time)

Then, to run the repeated measures ANOVA, we will load the ez package and use the function ezANOVA. The help file contains lots of useful information about where to put the relevant variables. We must specify the data, our dependant variable (dv=weight), our subject OD (wid=id) and the within subject factor (within=time):

> repeat1<-ezANOVA(data=mice,dv=weight,wid=id,within=time,type=3)
> repeat1

This gives the following output:

Sphericity Corrections` Effect GGe p[GG] p[GG]<.05 HFe p[HF] p[HF]<.05 2 time 0.7818665 0.4000192 0.7993554 0.4021355

The top table provides the results of a one-way repeated measures ANOVA if the assumption of sphericity is not violated. You want to look at the row for ‘time’, which shows that the p=0.42. We fail to reject the null hypothesis for a difference in weight across time.

The middle table indicates whether the assumption of sphericity is violated. As p<0.05, we reject the null hypothesis of sphericity, and so will use the sphericity corrections table below.

The bottom table which presents three types of corrections. We can see that the results are consistent and that we do not find evidence to reject the null hypothesis.

Controlling for between-subjects factors

 If we want to run this ANOVA again, but control for ‘strain group’, we must first ensure it is a factor. R currently has coded it as an integer value, so we convert to a factor:

> mice$Strain_group=as.factor(mice$Strain_group)

We can then add the between subject factor into the ezANOVA command, using the between argument as below:

> repeat2<-ezANOVA(data=mice,dv=weight,wid=id,within=time, between = Strain_group,type=3)
> repeat2

This produces the following results:

Sphericity Corrections` Effect GGe p[GG] p[GG]<.05 HFe p[HF] p[HF]<.05 3 time 0.8876249 2.828744e-01 0.9141235 2.834173e-01 4 Strain_group:time 0.8876249 7.067603e-09 * 0.9141235 4.427869e-09 *

  • Question B2.6: Run the repeated measures ANOVA for difference in weights across the three time points, but this time add ‘Strain Group’ as a ‘Between-Subjects Factor. What difference does this make?
Answer

Answer B2.6: When we review values for time:strain group we see that there is now a statistically significant difference, which holds when we correct for the violated sphericity assumption. This means that there is a significant different in weight when corrected for strain group. This is something that requires more investigation, but as these sample sizes are small and we have not considered whether the FoSSA Mouse data set meets all of the assumptions of our general linear model method. We will investigate these relationships in more detail in Module B3.

B2.6 PRACTICAL: Stata

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

To do this test in Stata, you need to reshape your data so that it is in ‘long’ format, rather than ‘wide’ format (as it currently is). Long format means that all the Weight variables are in one column, with a second column specifying which time they were measured at (beginning, middle or end). We need an ID variable to reshape our data, and we need to make sure the Weight variables have a standardised name with a number at the end. Considering all of this, run the following commands:

 gen id=_n

 keep Strain_group Weight_baseline Weight_mid Weight_end id

 rename Weight_baseline weight1

 rename Weight_mid weight2

 rename Weight_end weight3

 reshape long weight, i(id) j(time)

 br

These commands reshape your data so that all the weight measurements are in one column, and they make a new column called ‘time’ which indicates if the weight measurements were taken at the beginning (1), middle (2) or end (3).

Now you are ready to run the repeated measures ANOVA, which has this set up:

anova outcome_var ID_var independent_var, repeated(independent_var)

To test for a difference in mouse weights we therefore type:

anova weight id time, repeated(time)

‘Weight’ is the dependent variable and the independent variable (i.e. within-subjects factor) is ‘time’ with three time points (1,2,3). By default, Stata assumes the independent variable in the anova command is categorical so you do not need to enter the prefix ‘i.’ before time.

The output is:

The top table provides the results of a one-way repeated measures ANOVA if the assumption of sphericity is not violated. You want to look at the row for ‘time’, which shows that the p=0.42. We fail to reject the null hypothesis for a difference in weight across time.

Alternatively, if you think the assumption of sphericity may be violated, you can look at the second table which presents three types of corrections. We can see that the results are consistent and that we do not find evidence to reject the null hypothesis.

Controlling for between-subjects factors

 If we want to run this ANOVA again, but control for ‘strain group’, we need to install a user-written command. Type:

findit wsanova

And then click on the ‘sg103’ package in a blue hyperlink to install.

To re-run the anova we did above we would type:

wsanova weight time, id(id) epsilon

Now, we want to control for strain group, which is a between-subjects factor. So the command is:

wsanova weight time, id(id) between( Strain_group) epsilon

  • Question B2.6: Run the repeated measures ANOVA for difference in weights across the three time points, but this time add ‘Strain Group’ as a ‘Between-Subjects Factor. What difference does this make?
Answer

Answer B2.6: When we review values for time*strain group we see that there is now a statistically significant difference. This means that there is a significant different in weight when corrected for strain group. This is something that requires more investigation, but as these sample sizes are small and we have not considered whether the FoSSA Mouse data set meets all of the assumptions of our general linear model method. We will investigate these relationships in more detail in Module B3.

B2.5 PRACTICAL: SPSS

We can also use the ANOVA structure to test for differences between paired or repeated groups. We are going to use the repeated measures ANOVA to compare the mouse weights taken at the beginning, middle, and end of the trial in the FoSSA Mouse data set.

Select

Analyze >> General Linear Model >> Repeated Measures

The first box which pops up asks you to define the within-subject factor name. Call this ‘Weight’. Input ‘3’ for number of levels, then press ‘Add’ and then ‘Define’.

You will then see a repeated measures box where you can input the three variables for weight.

As with the Univariate GLM you can also add between subjects factors and covariates to expand this model. You can also use the options on the right hand side to add interactions into the model, conduct post-hoc tests, display parameter estimates, and save your residuals.

To run post hoc testing from the GLM framework for repeated measures you need to select EM Means from the right hand side (as opposed to Post Hoc). Move the variables you wish to run post hoc testing for into the ‘Display Means for’ box and then tick ‘Compare main effects’. There is a drop-down menu for confidence interval adjustment. Leave this as the default which is LSD(none).

Run the repeated measures ANOVA for difference in weights across the three time points, with an LSD post hoc test.

Once you have done this, go back and add ‘Strain Group’ as a ‘Between-Subjects Factor. What difference does this make?

Answer

The first thing to check is the test of sphericity (explained in the video).

As this is significant (P<0.001) we cannot assume sphericity, so we use the ‘Wilks Lambda’ statistics to get our F and P values for this relationship.

If the sphericity test is negative (P≥0.05), then we can use the sphericity assumed values instead. SPSS outputs these in a different table.

The Pairwise Comparisons table tells us the differences between groups. Unfortunately, this is one test that does not pull through the variable labels that we have assigned, so you need to have your coding values to hand to interpret it.

When we review Wilks Lambda values for weight combined with strain group we see that there is now a statistically significant difference. This means that there is a significant different in weight when corrected for strain group. This is something that requires more investigation, but as these sample sizes are small and we have not considered whether the FoSSA Mouse data set meets all of the assumptions of our general linear model method we will investigate these relationships in more detail in Module B3.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Questions or comments?x