# Effect Size Statistics for Anova Tables

This vignettes demontrates those functions of the sjstats-package that deal with Anova tables. These functions report different effect size measures, which are useful beyond significance tests (p-values), because they estimate the magnitude of effects, independent from sample size. sjstats provides following functions:

• eta_sq()
• omega_sq()
• cohens_f()
• anova_stats()

Befor we start, we fit a simple model:

library(sjstats)
data(efc)

# fit linear model
fit <- aov(
c12hour ~ as.factor(e42dep) + as.factor(c172code) + c160age,
data = efc
)

All functions accept objects of class aov or anova, so you can also use model fits from the car package, which allows fitting Anova’s with different types of sum of squares. Other objects, like lm, will be coerced to anova internally.

The following functions return the effect size statistic as named numeric vector, using the model’s term names.

## Eta Squared

The eta squared is the proportion of the total variability in the dependent variable that is accounted for by the variation in the independent variable. It is the ratio of the sum of squares for each group level to the total sum of squares. It can be interpreted as percentage of variance accounted for by a variable.

For variables with 1 degree of freedeom (in the numerator), the square root of eta squared is equal to the correlation coefficient r. For variables with more than 1 degree of freedom, eta squared equals R2. This makes eta squared easily interpretable. Furthermore, these effect sizes can easily be converted into effect size measures that can be, for instance, further processed in meta-analyses.

Eta squared can be computed simply with:

eta_sq(fit)
#>   as.factor(e42dep) as.factor(c172code)             c160age
#>         0.266114185         0.005399167         0.048441046

## Partial Eta Squared

The partial eta squared value is the ratio of the sum of squares for each group level to the sum of squares for each group level plus the residual sum of squares. It is more difficult to interpret, because its value strongly depends on the variability of the residuals. Partial eta squared values should be reported with caution, and Levine and Hullett (2002) recommend reporting eta or omega squared rather than partial eta squared.

Use the partial-argument to compute partial eta squared values:

eta_sq(fit, partial = TRUE)
#>   as.factor(e42dep) as.factor(c172code)             c160age
#>         0.281257128         0.007876882         0.066495448

## Omega Squared

While eta squared estimates tend to be biased in certain situations, e.g. when the sample size is small or the independent variables have many group levels, omega squared estimates are corrected for this bias.

Omega squared can be simply computed with:

omega_sq(fit)
#>   as.factor(e42dep) as.factor(c172code)             c160age
#>         0.263453157         0.003765292         0.047586841

## Cohen’s F

Finally, cohens_f() computes Cohen’s F effect size for all independent variables in the model:

cohens_f(fit)
#>   as.factor(e42dep) as.factor(c172code)             c160age
#>          0.62555427          0.08910342          0.26689334

# Complete Statistical Table Output

The anova_stats() function takes a model input and computes a comprehensive summary, including the above effect size measures, returned as tidy data frame (as tibble, to be exact):

anova_stats(fit)
#> # A tibble: 4 x 11
#>   term                    df   sumsq meansq statistic p.value    etasq partial.etasq  omegasq cohens.f  power
#>   <chr>                <dbl>   <dbl>  <dbl>     <dbl>   <dbl>    <dbl>         <dbl>    <dbl>    <dbl>  <dbl>
#> 1 as.factor(e42dep)     3.00  577756 192585    109     0       0.266         0.281    0.263     0.626   1.00
#> 2 as.factor(c172code)   2.00   11722   5861      3.31  0.0370  0.00500       0.00800  0.00400   0.0890  0.630
#> 3 c160age               1.00  105170 105170     59.4   0       0.0480        0.0660   0.0480    0.267   1.00
#> 4 Residuals           834    1476436   1770     NA    NA      NA            NA       NA        NA      NA

Like the other functions, the input may also be an object of class anova, so you can also use model fits from the car package, which allows fitting Anova’s with different types of sum of squares:

anova_stats(car::Anova(fit, type = 3))
#> # A tibble: 5 x 11
#>   term                  sumsq meansq     df statistic p.value    etasq partial.etasq  omegasq cohens.f  power
#>   <chr>                 <dbl>  <dbl>  <dbl>     <dbl>   <dbl>    <dbl>         <dbl>    <dbl>    <dbl>  <dbl>
#> 1 (Intercept)           26851  26851   1.00     15.2    0      0.0130        0.0180   0.0120    0.135   0.973
#> 2 as.factor(e42dep)    426462 142154   3.00     80.3    0      0.209         0.224    0.206     0.537   1.00
#> 3 as.factor(c172code)    7352   3676   2.00      2.08   0.126  0.00400       0.00500  0.00200   0.0710  0.429
#> 4 c160age              105170 105170   1.00     59.4    0      0.0510        0.0660   0.0510    0.267   1.00
#> 5 Residuals           1476436   1770 834        NA     NA     NA            NA       NA        NA      NA