Create beautiful summary tables of ANOVA test results obtained from either Anova() or aov().

The results include ANOVA table, generalized effect size and some assumption checks.

anova_summary(object, effect.size = "ges", detailed = FALSE, observed = NULL)

Arguments

object

an object of returned by either Anova(), or aov().

effect.size

the effect size to compute and to show in the ANOVA results. Allowed values can be either "ges" (generalized eta squared) or "pes" (partial eta squared) or both. Default is "ges".

detailed

If TRUE, returns extra information (sums of squares columns, intercept row, etc.) in the ANOVA table.

observed

Variables that are observed (i.e, measured) as compared to experimentally manipulated. The default effect size reported (generalized eta-squared) requires correct specification of the observed variables.

Value

return an object of class anova_test a data frame containing the ANOVA table for independent measures ANOVA. However, for repeated/mixed measures ANOVA, it is a list containing the following components are returned:

  • ANOVA: a data frame containing ANOVA results

  • Mauchly's Test for Sphericity: If any within-Ss variables with more than 2 levels are present, a data frame containing the results of Mauchly's test for Sphericity. Only reported for effects that have more than 2 levels because sphericity necessarily holds for effects with only 2 levels.

  • Sphericity Corrections: If any within-Ss variables are present, a data frame containing the Greenhouse-Geisser and Huynh-Feldt epsilon values, and corresponding corrected p-values.

The returned object might have an attribute called args if you compute ANOVA using the function anova_test(). The attribute args is a list holding the arguments used to fit the ANOVA model, including: data, dv, within, between, type, model, etc.

The following abbreviations are used in the different results tables:

  • DFn Degrees of Freedom in the numerator (i.e. DF effect).

  • DFd Degrees of Freedom in the denominator (i.e., DF error).

  • SSn Sum of Squares in the numerator (i.e., SS effect).

  • SSd Sum of Squares in the denominator (i.e.,SS error).

  • F F-value.

  • p p-value (probability of the data given the null hypothesis).

  • p<.05 Highlights p-values less than the traditional alpha level of .05.

  • ges Generalized Eta-Squared measure of effect size.

  • GGe Greenhouse-Geisser epsilon.

  • p[GGe] p-value after correction using Greenhouse-Geisser epsilon.

  • p[GGe]<.05 Highlights p-values (after correction using Greenhouse-Geisser epsilon) less than the traditional alpha level of .05.

  • HFe Huynh-Feldt epsilon.

  • p[HFe] p-value after correction using Huynh-Feldt epsilon.

  • p[HFe]<.05 Highlights p-values (after correction using Huynh-Feldt epsilon) less than the traditional alpha level of .05.

  • W Mauchly's W statistic

Author

Alboukadel Kassambara, alboukadel.kassambara@gmail.com

Examples

# Load data
#:::::::::::::::::::::::::::::::::::::::
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)

# Independent measures ANOVA
#:::::::::::::::::::::::::::::::::::::::::
# Compute ANOVA and display the summary
res.anova <- Anova(lm(len ~ dose*supp, data = df))
anova_summary(res.anova)
#>      Effect DFn DFd      F        p p<.05   ges
#> 1      dose   2  54 92.000 4.05e-18     * 0.773
#> 2      supp   1  54 15.572 2.31e-04     * 0.224
#> 3 dose:supp   2  54  4.107 2.20e-02     * 0.132

# Display both SSn and SSd using detailed = TRUE
# Show generalized eta squared using effect.size = "ges"
anova_summary(res.anova, detailed = TRUE, effect.size = "ges")
#>      Effect      SSn     SSd DFn DFd      F        p p<.05   ges
#> 1      dose 2426.434 712.106   2  54 92.000 4.05e-18     * 0.773
#> 2      supp  205.350 712.106   1  54 15.572 2.31e-04     * 0.224
#> 3 dose:supp  108.319 712.106   2  54  4.107 2.20e-02     * 0.132

# Show partial eta squared using effect.size = "pes"
anova_summary(res.anova, detailed = TRUE, effect.size = "pes")
#>      Effect      SSn     SSd DFn DFd      F        p p<.05   pes
#> 1      dose 2426.434 712.106   2  54 92.000 4.05e-18     * 0.773
#> 2      supp  205.350 712.106   1  54 15.572 2.31e-04     * 0.224
#> 3 dose:supp  108.319 712.106   2  54  4.107 2.20e-02     * 0.132

# Repeated measures designs using car::Anova()
#:::::::::::::::::::::::::::::::::::::::::
# Prepare the data
df$id <- as.factor(rep(1:10, 6)) # Add individuals ids
head(df)
#>    len supp dose id
#> 1  4.2   VC  0.5  1
#> 2 11.5   VC  0.5  2
#> 3  7.3   VC  0.5  3
#> 4  5.8   VC  0.5  4
#> 5  6.4   VC  0.5  5
#> 6 10.0   VC  0.5  6

# Easily perform repeated measures ANOVA using the car package
design <- factorial_design(df, dv = len, wid = id, within = c(supp, dose))
res.anova <- Anova(design$model, idata = design$idata, idesign = design$idesign, type = 3)
anova_summary(res.anova)
#> $ANOVA
#>      Effect DFn DFd       F        p p<.05   ges
#> 1      supp   1   9  34.866 2.28e-04     * 0.224
#> 2      dose   2  18 106.470 1.06e-10     * 0.773
#> 3 supp:dose   2  18   2.534 1.07e-01       0.132
#> 
#> $`Mauchly's Test for Sphericity`
#>      Effect     W     p p<.05
#> 1      dose 0.807 0.425      
#> 2 supp:dose 0.934 0.761      
#> 
#> $`Sphericity Corrections`
#>      Effect   GGe      DF[GG]    p[GG] p[GG]<.05   HFe      DF[HF]    p[HF]
#> 1      dose 0.838 1.68, 15.09 2.79e-09         * 1.008 2.02, 18.15 1.06e-10
#> 2 supp:dose 0.938 1.88, 16.88 1.12e-01           1.176 2.35, 21.17 1.07e-01
#>   p[HF]<.05
#> 1         *
#> 2          
#> 

# Repeated measures designs using stats::Aov()
#:::::::::::::::::::::::::::::::::::::::::
res.anova <- aov(len ~ dose*supp + Error(id/(supp*dose)), data = df)
anova_summary(res.anova)
#>      Effect DFn DFd       F        p p<.05   ges
#> 1      supp   1   9  34.866 2.28e-04     * 0.242
#> 2      dose   2  18 106.470 1.06e-10     * 0.791
#> 3 dose:supp   2  18   2.534 1.07e-01       0.144