Skip to content

Expand check_heterogeneity_bias()'s output #812

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

strengejacke
Copy link
Member

Fixes #810

@mattansb
Copy link
Member

mattansb commented May 7, 2025

Okay, I like this a lot:

library(performance)

mlmRev::egsingle |> 
  check_group_variation(select = c("lowinc", "female", "math"),
                        by = c("schoolid", "childid"))
#> Check group variation
#> 
#> group    | variable |    type
#> -----------------------------
#> schoolid |   lowinc | between
#> schoolid |   female |  within
#> schoolid |     math |    both
#> childid  |   lowinc | between
#> childid  |   female | between
#> childid  |     math |    both


mlmRev::egsingle |> 
  check_group_variation(select = c("lowinc", "female", "math"),
                        by = c("schoolid", "childid"), 
                        
                        include_by = TRUE)
#> Check group variation
#> 
#> group    | variable |    type
#> -----------------------------
#> schoolid |  childid |  nested
#> schoolid |   lowinc | between
#> schoolid |   female |  within
#> schoolid |     math |    both
#> childid  | schoolid | between
#> childid  |   lowinc | between
#> childid  |   female | between
#> childid  |     math |    both



dat <- data.frame(
  id = rep(letters, each = 2),
  
  constant = "a",
  
  between_num = rep(rnorm(26), each = 2),
  within_num = rep(rnorm(2), times = 26),
  both_num = rnorm(52),
  
  between_fac = rep(LETTERS, each = 2),
  within_fac = rep(LETTERS[1:2], times = 26),
  both_fac = sample(LETTERS[1:5], size = 52, replace = TRUE)
)


dat |> 
  check_group_variation(by = "id")
#> Check id variation
#> 
#> variable    |    type
#> ---------------------
#> constant    |        
#> between_num | between
#> within_num  |  within
#> both_num    |    both
#> between_fac | between
#> within_fac  |  within
#> both_fac    |    both

Created on 2025-05-07 with reprex v2.1.1

I re-wrote a lot of the docs, to explain what is going on.

  • @strengejacke How do I make the printing method split by group?
  • Can this function replace (supersede) check_heterogeneity_bias()? If so, some of the docs from there can make their way into 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.

Expand check_heterogeneity_bias()'s output
2 participants