I am not able to obtain eta squared, only partial eta squared, when I use rstatix::anova_test.
Example from the iris dataset:
First using aov:
aov <- aov(Sepal.Length ~ Sepal.Width + Species, data = iris)
summary(aov)
Df Sum Sq Mean Sq F value Pr(>F)
Sepal.Width 1 1.41 1.41 7.363 0.00746 **
Species 2 72.75 36.38 189.651 < 2e-16 ***
Residuals 146 28.00 0.19
Then using sjstats::eta_sq, if I choose partial = TRUE or FALSE I get a different effect size, as I would expect.
eta_sq(aov, partial = FALSE)
term etasq
1 Sepal.Width 0.014
2 Species 0.712
eta_sq(aov, partial = TRUE)
term partial.etasq
1 Sepal.Width 0.048
2 Species 0.722
However, when I do the same in anova_test, I get the partial eta squared both times regardless of whether the effect size is pes or ges, both times it's the partial eta squared:
aov_pes <- iris %>% anova_test(Sepal.Length ~ Sepal.Width + Species,
detailed = T,
effect.size = "pes")
get_anova_table(aov_pes)
Effect SSn SSd DFn DFd F p p<.05
1 Sepal.Width 10.953 28.004 1 146 57.102 4.19e-12 *
2 Species 72.752 28.004 2 146 189.651 2.56e-41 *
pes
1 0.281
2 0.722
aov_ges <- iris %>% anova_test(Sepal.Length ~ Sepal.Width + Species,
detailed = T,
effect.size = "ges")
get_anova_table(aov_ges)
Effect SSn SSd DFn DFd F p p<.05
1 Sepal.Width 10.953 28.004 1 146 57.102 4.19e-12 *
2 Species 72.752 28.004 2 146 189.651 2.56e-41 *
ges
1 0.281
2 0.722
Does anyone know why this is? Thanks!
Answer
rstatix::anova_testseems to contain a mistake in the calculation! I would be very, very careful with this function.Note that
eta_sqis deprecated, andeffectsize::eta_squaredshould be used.Proper calculation
We have three SS values: 1.412238, 72.752431, and 28.003665. We can calculate the pes and ges:
anova_test
Under the hood,
anova_testcalls two functions for pes and ges calculation:rstatix:::add_partial_eta_squaredrstatix:::add_generalized_eta_squaredThe pes calculation by
anova_testThis indeed calculates the pes as we expect it to.
The ges calculation by
anova_testHere, we run into a problem. This code seems blatantly incorrect. It just divides each sum of square value by itself + the residual sum of squares (28.004). That is the pes, not the ges.
You could contact the maintainer of the package (
maintainer("rstatix")) or create a new issue for therstatixpackage here.