Back to Course

FoSSA Français

0% Complete
0/0 Steps
  1. Information sur le cours

    Rencontrez l'équipe enseignante
  2. Jeu de données du cours 1
  3. Jeu de données du cours 2
  4. MODULE A1: INTRODUCTION AUX STATISTIQUES AVEC R ET STATA
    A1.1 Qu'est-ce que les Statistiques?
  5. A1.2.1a Introduction à Stata
  6. A1.2.2b: Introduction à R
  7. A1.2.2c: Introduction to SPSS
  8. A1.3: Statistiques Descriptives
  9. A1.4: Estimations et Intervalles de Confiance
  10. A1.5: Tests d'Hypothèses
  11. A1.6: Transformation de Variables
  12. Fin du Module A1
    1 Quiz
  13. MODULE A2: CALCULS DE PUISSANCE STATISTIQUE & DE TAILLE D’ÉCHANTILLON
    A2.1 Concepts Clés
  14. A2.2 Calculs de puissance pour une différence de moyennes
  15. A2.3 Calculs de puissance pour une différence de proportions
  16. A2.4 Calcul de taille d’échantillon pour les essais randomisés (RCTs)
  17. A2.5 Calculs de taille d’échantillon pour les études transversales (ou sondages)
  18. A2.6 Calcul de taille d'échantillon pour un devis cas-contrôle
  19. Fin du Module A2
    1 Quiz
  20. MODULE B1: RÉGRESSION LINÉAIRE
    B1.1 Corrélation et Nuages de Points (scatterplots)
  21. B1.2 Différences Entre Moyennes (ANOVA à un facteur)
  22. B1.3 Régression Linéaire Univariée
  23. B1.4 Régression Linéaire Multivariée
  24. B1.5 Sélection de Modèles et Tests F
  25. B1.6 Diagnostics de Régression
  26. Fin du Module B1
    1 Quiz
  27. MODULE B2: COMPARAISONS MULTIPLES & MESURES RÉPÉTÉES
    B2.1 ANOVA Approfondie— Tests Post-Hoc
  28. B2.2 Correction pour Comparaisons Multiples
  29. B2.3 ANOVA à deux facteurs (Two-way ANOVA)
  30. B2.4 Mesures Répétées et Test T Apparié
  31. B2.5 ANOVA pour Mesures Répétées
  32. Fin du Module B2
    1 Quiz
  33. MODULE B3: MÉTHODES NON-PARAMETRIC
    B3.1 Hypothèses des Tests Paramétriques
  34. B3.2 Test U de Mann-Whitney
  35. B3.3 Test de Kruskal-Wallis
  36. B3.4 Test des rangs signés de Wilcoxon
  37. B3.5 Test de Friedman
  38. B3.6 Corrélation des Rangs de Spearman
  39. Fin du Module B3
    1 Quiz
  40. MODULE C1: DONNÉES BINAIRES & RÉGRESSION LOGISTIQUE
    C1.1 Introduction à la prévalence, au Risque, aux Cotes (Odds) et aux Taux
  41. C1.2 Le Test du Chi Carré & le Test de Tendance
  42. C1.3 Régression Logistique Univariée
  43. C1.4 Régression Logistique Multivariée
  44. Fin du Module C1
    1 Quiz
  45. MODULE C2: DONNÉES DE SURVIE
    C2.1 Introduction aux Données de Survie
  46. C2.2 Fonction de Survie de Kaplan-Meier & Test du Log-Rank
  47. C2.3 Régression de Cox à Risque Proportionnel
  48. C2.4 Régression de Poisson
  49. Fin du Module C2
    1 Quiz
Lesson 31 of 49
In Progress

B2.5 ANOVA pour Mesures Répétées

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.

👋 Before you go, leave an anonymous rating & feedback

Average rating 4.9 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

Please share any positive or negative feedback you may have.

Feedback is completely anonymous

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Questions or comments?x