Skip to content

Expand check_heterogeneity_bias()'s output #810

@mattansb

Description

@mattansb

Currently, the check_heterogeneity_bias() marks variables if they have any within-group variance.
This is not so clear from the documentation (the working is confusing?):

check_heterogeneity_bias() checks if model predictors or variables may cause a heterogeneity bias, i.e. if variables have a within- and/or between-effect (Bell and Jones, 2015).

Anyway, I wonder if we can/should expand this function (or have another, more general one) to detect exactly how data is structured relative to the grouping variable(s), to state which variable(s) vary within-/between-groups or possibly both:

dat <- data.frame(
  id = rep(letters, each = 2),
  between = rep(rnorm(26), each = 2),
  within = rep(rnorm(2), times = 26),
  both = rnorm(52)
)

dat |> 
  performance::check_heterogeneity_bias(
    select = c("between", "within", "both"), 
    by = "id"
  )
#> Possible heterogeneity bias due to following predictors: within, both

Metadata

Metadata

Assignees

Labels

Enhancement 💥Implemented features can be improved or revised

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions