Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalized eta2 and Omega2 #42

Open
mattansb opened this issue Mar 25, 2020 · 16 comments
Open

Generalized eta2 and Omega2 #42

mattansb opened this issue Mar 25, 2020 · 16 comments
Assignees
Labels
enhancement 🔥 New feature or request help wanted 🔍 Extra attention is needed low priority 😴

Comments

@mattansb
Copy link
Member

(Originally part of #5 )

https://doi.org/10.1037/1082-989X.8.4.434

@IndrajeetPatil IndrajeetPatil added the enhancement 🔥 New feature or request label Mar 28, 2020
@IndrajeetPatil
Copy link
Member

Maybe of relevance here:
There seems to be an implementation of generalized eta2 in ez (but doesn't have CIs):

https://github.com/mike-lawrence/ez/blob/a7bc677ea35d4cea821fda78958f360c5935144e/R/ezANOVA.R#L57-L72

@IndrajeetPatil
Copy link
Member

And there is implementation of generalized omega^2 (and their CIs!) here:
https://github.com/doomlab/MOTE/blob/master/R/omega.gen.SS.rm.R

(And detailed post explaining it: https://www.aggieerin.com/shiny-server/tests/gosrmss.html)

@mattansb
Copy link
Member Author

mattansb commented Oct 5, 2020

This is the afex code that does this (EtaSq from DescTools doesn't account for observed vars):

if (!is.null(observed) & length(observed) > 0) {
  obs <- rep(FALSE, nrow(tmp2))
  for (i in observed) {
    if (!any(grepl(paste0("\\b", i, "\\b"), rownames(tmp2)))) 
      stop(paste0("Observed variable not in data: ", 
                  i))
    obs <- obs | grepl(paste0("\\b", i, "\\b"), 
                       rownames(tmp2))
  }
  obs_SSn1 <- sum(tmp2$SS * obs)
  obs_SSn2 <- tmp2$SS * obs
}
else {
  obs_SSn1 <- 0
  obs_SSn2 <- 0
}
es_df$ges <- tmp2$SS/(tmp2$SS + sum(unique(tmp2[, "Error SS"])) + 
                        obs_SSn1 - obs_SSn2)

Need to see how to implement this here.

@mattansb
Copy link
Member Author

mattansb commented Oct 5, 2020

And there is implementation of generalized omega^2 (and their CIs!) here:

I think this calculation of CIs is somewhat off - the degrees of freedom (den) cannot be the same as those for the partial eta square, they would have to be smaller.
Need to look further into this...

@mattansb
Copy link
Member Author

mattansb commented Oct 9, 2020

Eta2G works
(slight differences with afex are due to the different method afex uses for computing SSs)

(Still need to add Omega2G)

library(effectsize)

options(contrasts = c('contr.sum', 'contr.poly'))


data(obk.long, package = "afex")
m_afex <- afex::aov_car(value ~ treatment * gender + Error(id),
                        data = obk.long, observed = "gender")

m_aov <- aov(value ~ treatment * gender + Error(id),
             data = m_afex$data$long)


afex::nice(m_afex, es = "ges")
#> Anova Table (Type 3 tests)
#> 
#> Response: value
#>             Effect    df  MSE      F  ges p.value
#> 1        treatment 2, 10 1.52 3.94 + .289    .055
#> 2           gender 1, 10 1.52 3.66 + .189    .085
#> 3 treatment:gender 2, 10 1.52   2.86 .295    .104
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

eta_squared(m_aov, generalized = "gender")
#> Group |        Parameter | Eta2 (generalized) |       90% CI
#> ------------------------------------------------------------
#> id    |        treatment |               0.31 | [0.00, 0.58]
#> id    |           gender |               0.14 | [0.00, 0.47]
#> id    | treatment:gender |               0.31 | [0.00, 0.58]

Created on 2020-10-09 by the reprex package (v0.3.0)

mattansb added a commit that referenced this issue Oct 9, 2020
@IndrajeetPatil

This comment has been minimized.

@mattansb

This comment has been minimized.

@IndrajeetPatil

This comment has been minimized.

@mattansb
Copy link
Member Author

@IndrajeetPatil It is my dream that people use Epsilon squared instead of Omega squared because (1) Epsilon is actually less biased! (2) Calculating Omega is a pain in the a**...

@IndrajeetPatil
Copy link
Member

Ah, I see.

My understanding about this is mostly based on Lakens' review of effect sizes:
https://www.frontiersin.org/articles/10.3389/fpsyg.2013.00863/full

image

@mattansb
Copy link
Member Author

mattansb commented Oct 13, 2020

Same - but even Lakens is perfect ;)

From: https://doi.org/10.1177/2515245919855053

(Note that adjusted eta is equal to epsilon)

image

@IndrajeetPatil
Copy link
Member

Thanks 👍

I will check it out. I am planning to default to generalized omega-squared in my packages, but maybe I should rethink that.

@mattansb
Copy link
Member Author

I will eventually get to Omega2G (and maybe will try to extrapolate to Epsilon2G? We'll see...)

@DominiqueMakowski
Copy link
Member

I also had the same idea about omega > epsilon based on the same source but indeed this is rather compelling evidence

@strengejacke
Copy link
Member

Can't unsee... We must add the petit_deux suffix to all columns.

@mattansb mattansb reopened this Oct 18, 2020
@mattansb mattansb removed the WIP 👷‍♂️ work in progress label Oct 28, 2020
@mattansb mattansb added this to the CRAN 0.4.5 milestone Dec 6, 2020
@mattansb mattansb self-assigned this Jan 6, 2021
@mattansb mattansb removed this from the CRAN 0.4.5 milestone Jan 7, 2021
@mattansb mattansb added low priority 😴 help wanted 🔍 Extra attention is needed labels Jan 7, 2021
@mattansb
Copy link
Member Author

mattansb commented Jan 7, 2021

I'm putting this on ice. Implementing Omega2G is f*^% hard...

@mattansb mattansb added this to the CRAN 0.5 milestone Apr 1, 2021
@mattansb mattansb removed this from the CRAN 0.5 milestone Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🔥 New feature or request help wanted 🔍 Extra attention is needed low priority 😴
Projects
None yet
Development

No branches or pull requests

4 participants