The data provide the anxiety score, measured at three time points, of three groups of individuals practicing physical exercises at different levels (grp1: basal, grp2: moderate and grp3: high)

Two-way mixed ANOVA can be used to evaluate if there is interaction between group and time in explaining the anxiety score.

It is the data set used in the Datanovia tutorial “Mixed ANOVA in R: One Between- and One Within-Subjects Factor” (https://www.datanovia.com/learn/biostatistics/anova/mixed-anova-in-r).

data("anxiety")

Format

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

id

participant identifier (1 to 45).

group

the physical exercise level, "grp1" (basal), "grp2" (moderate) or "grp3" (high); a between-subjects factor.

t1

the anxiety score at the first time point.

t2

the anxiety score at the second time point.

t3

the anxiety score at the third time point.

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

Source

A simulated dataset created for teaching two-way mixed ANOVA.

Examples

data(anxiety)
head(anxiety)
#> # A tibble: 6 × 5
#>   id    group    t1    t2    t3
#>   <fct> <fct> <dbl> <dbl> <dbl>
#> 1 1     grp1   14.1  14.4  14.1
#> 2 2     grp1   14.5  14.6  14.3
#> 3 3     grp1   15.7  15.2  14.9
#> 4 4     grp1   16    15.5  15.3
#> 5 5     grp1   16.5  15.8  15.7
#> 6 6     grp1   16.9  16.5  16.2

# Two-way mixed ANOVA: group (between) x time (within)
anxiety_long <- reshape(anxiety, varying = c("t1", "t2", "t3"),
                        v.names = "score", timevar = "time",
                        direction = "long")
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
#> Warning: number of items to replace is not a multiple of replacement length
summary(aov(score ~ group * factor(time) + Error(factor(id)/factor(time)),
            data = anxiety_long))
#> Warning: Error() model is singular
#> 
#> Error: factor(id)
#>              Df Sum Sq Mean Sq F value   Pr(>F)    
#> group         2   1.21   0.607   0.318 0.729139    
#> factor(time)  1  28.84  28.843  15.135 0.000379 ***
#> Residuals    39  74.32   1.906                     
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Error: factor(id):factor(time)
#>              Df Sum Sq Mean Sq
#> factor(time)  2   0.06    0.03