Skip to content

Negative values returned by rank_eta_squared() for small group differences #217

@rogerioboff1

Description

@rogerioboff1

Suggestion for rank_eta_squared() function (possible bug with negative values)

Description

Dear developers, I would like to make a suggestion regarding the rank_eta_squared function (this suggestion might also apply to other functions, although I haven't tested them yet).

The function returns negative values when the difference between groups is very small. However, this should not happen, since the effect size is expected to range between 0 and 1. This issue also impacts the magnitude classification, as shown in the example below: the function returns a negative estimate classified as "large".

Reproducible Example

set.seed(2025)
data <- data.frame(
  group = sample(letters[1:4], 20, replace = TRUE),
  y = rnorm(20)
)

# rstatix 
rstatix::kruskal_effsize(y ~ group, data = data)
# A tibble: 1 x 5
#  .y.       n effsize method  magnitude
#* <chr> <int>   <dbl> <chr>   <ord>    
#1 y        20  -0.184 eta2[H] large

# effectsize 
effectsize::rank_eta_squared(y ~ group, data = data)
#Eta2 (rank) |       95% CI
#--------------------------
#0.00        | [0.00, 1.00

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions