Compute eta-squared and partial eta-squared for all terms in an ANOVA model.
See the Datanovia tutorial One-Way ANOVA in R for a worked walkthrough.
Arguments
- model
an object of class
aovoranova.- ci
confidence level for a confidence interval on the effect size. If a number between 0 and 1 (e.g.
0.95), the function returns a tibble with one row per model term and the columnsEffect,effsize,conf.lowandconf.highinstead of the bare named vector. The interval is computed in base R by inverting the noncentral F distribution (Steiger, 2004), and matcheseffectsize::eta_squared(ci = , alternative = "two.sided")—partial = FALSEforeta_squared()andpartial = TRUEforpartial_eta_squared()— to about four decimals for the non-partial bounds of a small pseudo-F (that function's inversion uses a looser tolerance), and more closely everywhere else. Default isNULL(no interval; the bare named vector is returned, unchanged).
Value
a named numeric vector of effect sizes, one per model term; or, when
ci is a confidence level, a tibble with the columns Effect,
effsize, conf.low and conf.high.
References
Steiger, J. H. (2004). Beyond the F test: Effect size confidence intervals and tests of close fit in the analysis of variance and contrast analysis. Psychological Methods, 9, 164-182.
See also
The Datanovia tutorial: One-Way ANOVA in R.
Examples
# Data preparation
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Compute ANOVA
res.aov <- aov(len ~ supp*dose, data = df)
summary(res.aov)
#> Df Sum Sq Mean Sq F value Pr(>F)
#> supp 1 205.4 205.4 15.572 0.000231 ***
#> dose 2 2426.4 1213.2 92.000 < 2e-16 ***
#> supp:dose 2 108.3 54.2 4.107 0.021860 *
#> Residuals 54 712.1 13.2
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Effect size
eta_squared(res.aov)
#> supp dose supp:dose
#> 0.05948365 0.70286419 0.03137672
partial_eta_squared(res.aov)
#> supp dose supp:dose
#> 0.2238254 0.7731092 0.1320279
# Effect size with confidence interval
eta_squared(res.aov, ci = 0.95)
#> # A tibble: 3 × 4
#> Effect effsize conf.low conf.high
#> <chr> <dbl> <dbl> <dbl>
#> 1 supp 0.0595 0 0.214
#> 2 dose 0.703 0.562 0.787
#> 3 supp:dose 0.0314 0 0.146
partial_eta_squared(res.aov, ci = 0.95)
#> # A tibble: 3 × 4
#> Effect effsize conf.low conf.high
#> <chr> <dbl> <dbl> <dbl>
#> 1 supp 0.224 0.0586 0.402
#> 2 dose 0.773 0.662 0.838
#> 3 supp:dose 0.132 0.00147 0.295
