Describe the bug
Hi there, the calculation of eta^2 for afex-ANOVAs is incorrect, when the name of one is part of the name of another factor. I have found this to be the case for the Anova.mlm- and the downstream afex_aov-methods, but I haven't explored this any further.
To Reproduce
Adapting the code from #389, here the relevant factor names are Block and XBlock (it does not happen, when the names are B and XB):
library(Superpower)
library(afex)
library(effectsize)
set.seed(2123)
# create data set:
aov.3way.design <- ANOVA_design(design = "2b*2w*2w",
n=20,
mu=0.025*c(-1,-1,-1,-1,1,1,1,1) + 0.05*c(-1,-1,1,1,-1,-1,1,1) + 0.05*c(-1,1,-1,1,-1,1,-1,1) + 0.05*c(-1,1,1,-1,-1,1,1,-1) + 0.05*c(-1,1,1,-1,1,-1,-1,1) + 0.05*c(-1,1,-1,1,1,-1,1,-1) + 0.05*c(-1,-1,1,1,1,-1,-1,1),
sd=0.15,
r=0.6,
plot=FALSE,
labelnames=c("XBlock","a1","a2","Block","aa1","aa2","C","c1","c2"))
aov.exact.01b <- ANOVA_exact(aov.3way.design,verbose=F)
dat1b <- aov.exact.01b$dataframe
dat1b$y <- dat1b$y+rnorm(n=dim(dat1b)[1],0,0.01)
# list partial eta_squared:
aov.01b <- aov_ez(id = "subject", dv = "y", between = "XBlock", within = c("Block", "C"), data = dat1b, anova_table = list(es = "pes"))
tibble::tibble(
term = afex::nice(aov.01b)$Effect
, afex = aov.01b$anova_table$pes
, effectsize_anova_table = effectsize::eta_squared(aov.01b$anova_table, partial = TRUE)$Eta2_partial
, effectsize_Anova = effectsize::eta_squared(aov.01b, partial = TRUE)$Eta2_partial
# , effectsize_Anova = effectsize::eta_squared(aov.01b$Anova, partial = TRUE)$Eta2_partial
, diff = afex - effectsize_Anova
) |>
as.data.frame()
Contrasts set to contr.sum for the following variables: XBlock
term afex effectsize_anova_table effectsize_Anova diff
1 XBlock 0.03913943 0.03913943 0.03913943 0.0000000
2 Block 0.73454670 0.73454670 0.27141502 0.4631317
3 XBlock:Block 0.25383454 0.25383454 0.04379157 0.2100430
4 C 0.52271737 0.52271737 0.22548586 0.2972315
5 XBlock:C 0.52792092 0.52792092 0.71366114 -0.1857402
6 Block:C 0.21826257 0.21826257 0.52271737 -0.3044548
7 XBlock:Block:C 0.70503499 0.70503499 0.52792092 0.1771141
Similar divergences occur, for generalized eta^2.
Expected behavior
I would expect the effect sizes to match between all approaches.
Specifiations (please complete the following information):
R Version 4.5.1
effectsize Version 1.0.2
Describe the bug
Hi there, the calculation of eta^2 for
afex-ANOVAs is incorrect, when the name of one is part of the name of another factor. I have found this to be the case for theAnova.mlm- and the downstreamafex_aov-methods, but I haven't explored this any further.To Reproduce
Adapting the code from #389, here the relevant factor names are
BlockandXBlock(it does not happen, when the names areBandXB):Similar divergences occur, for generalized eta^2.
Expected behavior
I would expect the effect sizes to match between all approaches.
Specifiations (please complete the following information):
RVersion 4.5.1effectsizeVersion 1.0.2