Data are the self esteem score of 12 individuals enrolled in 2 successive short-term trials (4 weeks) - control (placebo) and special diet trials.

The self esteem score was recorded at three time points: at the beginning (t1), midway (t2) and at the end (t3) of the trials.

The same 12 participants are enrolled in the two different trials with enough time between trials.

Two-way repeated measures ANOVA can be performed in order to determine whether there is interaction between time and treatment on the self esteem 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("selfesteem2")

Format

A data frame with 24 rows and 5 columns (stored as a tibble).

id

participant identifier (1 to 12); each participant takes part in both trials.

treatment

the trial, "ctr" (control/placebo) or "Diet".

t1

the self esteem score at the beginning of the trial.

t2

the self esteem score midway through the trial.

t3

the self esteem score at the end of the trial.

The self esteem score is a simulated measure on an arbitrary scale with no real-world units.

Source

A simulated dataset created for teaching two-way repeated measures ANOVA.

See also

selfesteem, the one-way companion data set. Datanovia tutorial: Repeated Measures ANOVA in R: Compare Means Across Time.

Examples

data(selfesteem2)
head(selfesteem2)
#> # A tibble: 6 × 5
#>   id    treatment    t1    t2    t3
#>   <fct> <fct>     <dbl> <dbl> <dbl>
#> 1 1     ctr          83    77    69
#> 2 2     ctr          97    95    88
#> 3 3     ctr          93    92    89
#> 4 4     ctr          92    92    89
#> 5 5     ctr          77    73    68
#> 6 6     ctr          72    65    63

# Two-way repeated measures ANOVA (treatment x time), both within-subjects
selfesteem2_long <- reshape(selfesteem2, varying = c("t1", "t2", "t3"),
                            v.names = "score", timevar = "time",
                            idvar = c("id", "treatment"), direction = "long")
summary(aov(score ~ treatment * factor(time) +
              Error(factor(id)/(treatment * factor(time))),
            data = selfesteem2_long))
#> 
#> Error: factor(id)
#>           Df Sum Sq Mean Sq F value Pr(>F)
#> Residuals 11   4641   421.9               
#> 
#> Error: factor(id):treatment
#>           Df Sum Sq Mean Sq F value Pr(>F)   
#> treatment  1  316.7   316.7   15.54 0.0023 **
#> Residuals 11  224.2    20.4                  
#> ---
#> 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  258.7  129.35   27.37 1.08e-06 ***
#> Residuals    22  104.0    4.73                     
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Error: factor(id):treatment:factor(time)
#>                        Df Sum Sq Mean Sq F value   Pr(>F)    
#> treatment:factor(time)  2 266.36  133.18   30.42 4.63e-07 ***
#> Residuals              22  96.31    4.38                     
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1