1

It says here that one can get one or the other or both. I have been able to get each one separately but not both together even when I set effect.size = c("ges", "pes"). Instead, I only get "pes". I have the same problem when I use my own data and when I use the hangover dataset from the {WRS2} package. For the hangover data, my code is:

anova_test(data = hangover, dv = symptoms, wid = id, between = group, within = time, effect.size = c("ges", "pes"))

I would be very grateful for your help!

curious
  • 23
  • 5
  • Oh no, where did zephryl's comment go? They said that it seems to be a mistake in the doc or the code, because the code only allows one effect size as output despite what the doc says. Getting both is not possible with this code. – curious Nov 30 '22 at 14:29
  • not to worry, I just moved it to a full answer below. – zephryl Nov 30 '22 at 14:30

2 Answers2

1

This seems to be an error in either the docs or the code. The docs do say you can specify both, but the relevant code uses if / else to return just one or the other:

add_anova_effect_size <- function(res.anova.summary, effect.size = "ges",  observed = NULL){
  ss.exists <- "SSn" %in% colnames(res.anova.summary$ANOVA)
  if(!ss.exists){
    return(res.anova.summary)
  }
  if("pes" %in% effect.size){
    res.anova.summary <- res.anova.summary %>%
      add_partial_eta_squared()
  }
  else {
    res.anova.summary <- res.anova.summary %>%
      add_generalized_eta_squared(observed)
  }
  res.anova.summary
}

But also, as discussed here and mentioned by @Phenomniverse, rstatix currently calculates ges incorrectly.

zephryl
  • 14,633
  • 3
  • 11
  • 30
  • Regarding ges: ezANOVA gives the same result for ges. – curious Nov 30 '22 at 16:18
  • ezANOVA is from the ez library, and I'm using the hangover data from the WSR2 package again: ezANOVA(data = hangover, dv = symptoms, wid = id, between = group, within = time, type = 3) – curious Nov 30 '22 at 16:43
  • But I am not sure how much I can trust ezANOVA either and would love to double-check this manually. If anyone knows how to do this using the standard ANOVA output and the formula given in Bakeman (2005) I would be very grateful for an explanation. Bakeman (2005): https://link.springer.com/content/pdf/10.3758/BF03192707.pdf?pdf=button – curious Nov 30 '22 at 17:30
  • With dplyr, you can do `anova_test(iris, Sepal.Length ~ Sepal.Width * Species, detailed = T, effect.size = "ges") %>% as_tibble() %>% mutate(pes_calc = SSn / (SSn + first(SSd)), ges_calc = SSn / (sum(SSn) + first(SSd)))`. For me this gives the same pes as rstatix but different ges. – zephryl Nov 30 '22 at 20:22
  • Whether it should be sum(SSn) or just SSn depends on which factors where manipulated and which were just measured, right? (See Bakeman link above) – curious Dec 01 '22 at 16:14
  • And if that's true, I'm wondering how the function is supposed to know which factors were manipulated and which ones were measured. – curious Dec 01 '22 at 16:17
  • Yes, I think you're right. The code I gave would only give `ges` for all measured factors (which == plain old eta squared). `anova_test()` has an `observed` argument to indicate variables were measured rather than manipulated. Not clear from the documentation what it defaults to. – zephryl Dec 01 '22 at 16:49
  • You may want to post a new question dealing with this. Either here on SO if it's more focused on how rstatix computes things and whether it's correct, or on Cross Validated if it's more focused just on how to compute the different eta squared measures in general. – zephryl Dec 01 '22 at 16:51
  • Again thanks so much! I will think about this some more and might make a new post. – curious Dec 02 '22 at 14:13
0

You can get both using effect.size = "both".

However, you may want to be aware of this issue raised on the github page for this package regarding how effect.size is calculated:

https://github.com/kassambara/rstatix/issues/132

Phenomniverse
  • 309
  • 1
  • 8
  • 1
    Have you tested this? `anova_test(mtcars, mpg ~ cyl, effect.size = "both")` yields only `ges`, not `pes`. – zephryl Nov 30 '22 at 14:07
  • From the github issue, it seems there is a problem in the calculation in anova_test. I'm not sure if it's been fixed. – Phenomniverse Nov 30 '22 at 14:10
  • Right, but I’m saying that ‘You can get both using effect.size = "both"’ is incorrect. – zephryl Nov 30 '22 at 14:13
  • Hi, thanks for the answer! Unfortunately it is like zephryl says: "both" only gives ges and not pes. – curious Nov 30 '22 at 14:16
  • You are correct. I just took that from what was reported in the github issue. I did initially try to find the relevant code, but you have succeeded where I did not. – Phenomniverse Nov 30 '22 at 14:16
  • I am aware of the issue raised on github. It seems to have been fixed, or at least the results for ges and pes are not the same anymore. – curious Nov 30 '22 at 14:20
  • @curious what does the output from the anova_test function look like? – Phenomniverse Nov 30 '22 at 14:24
  • @curious, I wouldn’t assume it’s fixed, as the relevant code hasn’t been updated for 3 years per github. Maybe confirm using a ges function from another package or calculating by hand. – zephryl Nov 30 '22 at 14:28
  • 1
    @zephryl Yes you're right, I'm definitely going to check. – curious Nov 30 '22 at 14:48