A researcher wanted to assess the effects of Diet and Exercises on weight loss in 12 sedentary males.
The participants were enrolled in four trials: (1) no diet and no exercises; (2) diet only; (3) exercises only; and (4) diet and exercises combined.
Each participant performed all four trials. The order of the trials was counterbalanced and sufficient time was allowed between trials to allow any effects of previous trials to have dissipated (i.e., a "wash out" period).
Each trial lasted nine weeks and the weight loss score was measured at the beginning of each trial (t1), at the midpoint of each trial (t2) and at the end of each trial (t3).
Three-way repeated measures ANOVA can be performed in order to determine whether there is interaction between diet, exercises and time on the weight loss score.
For a worked tutorial on this analysis, see the Datanovia lesson “Repeated Measures ANOVA in R: Compare Means Across Time” (https://www.datanovia.com/learn/biostatistics/anova/repeated-measures-anova-in-r).
data("weightloss")A data frame with 48 rows and 6 columns (stored as a tibble).
participant identifier (1 to 12); each participant performs all four diet/exercises trials.
whether the trial included a diet, "no" or "yes".
whether the trial included exercises, "no" or "yes".
the weight loss score at the beginning of the trial.
the weight loss score at the midpoint of the trial.
the weight loss score at the end of the trial.
The weight loss score is a simulated measure on an arbitrary scale with no real-world units.
A simulated dataset created for teaching three-way repeated measures ANOVA.
Datanovia tutorial: Repeated Measures ANOVA in R: Compare Means Across Time.
data(weightloss)
head(weightloss)
#> # A tibble: 6 × 6
#> id diet exercises t1 t2 t3
#> <fct> <fct> <fct> <dbl> <dbl> <dbl>
#> 1 1 no no 10.4 13.2 11.6
#> 2 2 no no 11.6 10.7 13.2
#> 3 3 no no 11.4 11.1 11.4
#> 4 4 no no 11.1 9.5 11.1
#> 5 5 no no 9.5 9.73 12.3
#> 6 6 no no 9.5 12.7 10.4
# Three-way repeated measures ANOVA (diet x exercises x time), all within
weightloss_long <- reshape(weightloss, varying = c("t1", "t2", "t3"),
v.names = "score", timevar = "time",
idvar = c("id", "diet", "exercises"),
direction = "long")
summary(aov(score ~ diet * exercises * factor(time) +
Error(factor(id)/(diet * exercises * factor(time))),
data = weightloss_long))
#>
#> Error: factor(id)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> Residuals 11 27.1 2.463
#>
#> Error: factor(id):diet
#> Df Sum Sq Mean Sq F value Pr(>F)
#> diet 1 5.111 5.111 6.021 0.032 *
#> Residuals 11 9.337 0.849
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Error: factor(id):exercises
#> Df Sum Sq Mean Sq F value Pr(>F)
#> exercises 1 71.16 71.16 58.93 9.65e-06 ***
#> Residuals 11 13.28 1.21
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Error: factor(id):factor(time)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> factor(time) 2 211.39 105.69 110.9 3.22e-12 ***
#> Residuals 22 20.96 0.95
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Error: factor(id):diet:exercises
#> Df Sum Sq Mean Sq F value Pr(>F)
#> diet:exercises 1 33.40 33.40 75.36 2.98e-06 ***
#> Residuals 11 4.88 0.44
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Error: factor(id):diet:factor(time)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> diet:factor(time) 2 2.42 1.210 0.603 0.556
#> Residuals 22 44.17 2.008
#>
#> Error: factor(id):exercises:factor(time)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> exercises:factor(time) 2 67.43 33.72 20.83 8.41e-06 ***
#> Residuals 22 35.62 1.62
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Error: factor(id):diet:exercises:factor(time)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> diet:exercises:factor(time) 2 30.77 15.39 14.25 0.000107 ***
#> Residuals 22 23.76 1.08
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1