Skip to content

Eta for check group variation - #932

Open
mattansb wants to merge 8 commits into
mainfrom
Eta-for-check_group_variation
Open

Eta for check group variation#932
mattansb wants to merge 8 commits into
mainfrom
Eta-for-check_group_variation

Conversation

@mattansb

@mattansb mattansb commented Aug 5, 2026

Copy link
Copy Markdown
Member

This PR adds an Eta column to the output of check_group_variation() which is a numeric effect size of the grouping variable's predictive association strength: when it is 0 the grouping variable carries no predictive information, when it is 1 the variable is perfectly predicted by the grouping variable.

  • For numeric variables it is the sqrt(icc) - also know as $\eta$ (eta).
  • For non-numeric variables it is a non-symmetric version of Cramer's V.
performance::check_group_variation(
  mlmRev::egsingle,
  by = c("schoolid", "childid"),
  include_by = TRUE
)
#> Check schoolid variation
#> 
#> Variable | Variation |  Design |     r
#> --------------------------------------
#> childid  |      both |  nested |  .430
#> year     |      both |         |  .171
#> grade    |      both |         |  .185
#> math     |      both |         |  .358
#> retained |      both |         |  .203
#> female   |    within | crossed |  .183
#> black    |      both |         |  .824
#> hispanic |      both |         |  .692
#> size     |   between |         | 1.000
#> lowinc   |   between |         | 1.000
#> mobility |   between |         | 1.000
#> 
#> Check childid variation
#> 
#> Variable | Variation | Design |     r
#> -------------------------------------
#> schoolid |   between |        | 1.000
#> year     |      both |        |  .416
#> grade    |      both |        |  .429
#> math     |      both |        |  .713
#> retained |      both |        |  .478
#> female   |   between |        | 1.000
#> black    |   between |        | 1.000
#> hispanic |   between |        | 1.000
#> size     |   between |        | 1.000
#> lowinc   |   between |        | 1.000
#> mobility |   between |        | 1.000

Created on 2026-08-06 with reprex v2.1.1

@mattansb
mattansb requested a review from strengejacke August 5, 2026 20:20
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.57576% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.12%. Comparing base (961ba2e) to head (6ccf55d).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
R/check_group_variation.R 57.57% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #932      +/-   ##
==========================================
+ Coverage   64.07%   64.12%   +0.05%     
==========================================
  Files          94       94              
  Lines        8321     8355      +34     
==========================================
+ Hits         5332     5358      +26     
- Misses       2989     2997       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@strengejacke

Copy link
Copy Markdown
Member

Nice! Do we have a reference for eta?

@DominiqueMakowski

Copy link
Copy Markdown
Member

Nice one indeed, would its usage be more meaningful in the context of exploratory analysis? Or to to help (mixed) model specification?

@mattansb

mattansb commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I've renamed the column to a more generic "r" (see updated example above) - the docs still explain that for numeric variables it is the correlation ratio $\eta$ (with reference).

Nice one indeed, would its usage be more meaningful in the context of exploratory analysis? Or to to help (mixed) model specification?

Ideally one already knows the design of their data and so know which variables are within/between/both, but this is useful for validating your assumptions (which is why it is in {performance})! See examples where I use it in teaching group-mean-centering (datawizard::demean()) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants