Giter VIP home page Giter VIP logo

Comments (6)

DominiqueMakowski avatar DominiqueMakowski commented on June 21, 2024 1

Fair enough, then at least deprecate first by warning "please replace TRUE by the list of variables you wish to account for"

from correlation.

mattansb avatar mattansb commented on June 21, 2024

Looking at the code, it seems like when multilevel = TRUE each variable is adjusted by ALL other variables, not just the grouping factor 😲!

from correlation.

DominiqueMakowski avatar DominiqueMakowski commented on June 21, 2024

We really need to move towards a more explicit approach where people should input the vector of variables they want to adjust for as @bwiernik was mentioning, it's probably just adding an ifelse statement somewhere where multilevel=TRUE queries the list of variables and then passes them to the adjustment.

We can preserve back-compatibility with when TRUE, we do the same as we do now but we throw a message like "adjusting for all variables: x, y, z"

from correlation.

mattansb avatar mattansb commented on June 21, 2024

I don't think we should reserve backwards compatibility - I think it should be treated as a bug / unintended behavior.

from correlation.

mattansb avatar mattansb commented on June 21, 2024

This should be applied to partial= as well.

from correlation.

strengejacke avatar strengejacke commented on June 21, 2024

Yeah, adjustment varies by number of predictors:

data("mtcars")
mtcars$gear <- factor(mtcars$gear)

datawizard::data_adjust(mtcars[c("mpg", "gear")], multilevel = TRUE) |> head()
#>         mpg gear
#> 1 -3.156152    4
#> 2 -3.156152    4
#> 3 -1.356152    4
#> 4  4.939590    3
#> 5  2.239590    3
#> 6  1.639590    3
datawizard::data_adjust(mtcars[c("mpg", "wt", "gear")], multilevel = TRUE) |> head()
#>          mpg          wt gear
#> 1 -3.0439878 -0.45459927    4
#> 2 -1.7575107 -0.19959927    4
#> 3 -2.7574903 -0.51481964    4
#> 4  1.7587607  0.07354550    3
#> 5  0.1938875 -0.06112396    3
#> 6 -0.3052123 -0.12105050    3
datawizard::data_adjust(mtcars[c("mpg", "wt", "drat", "gear")], multilevel = TRUE) |> head()
#>          mpg          wt        drat gear
#> 1 -2.9517840 -0.41184993 -0.10742447    4
#> 2 -1.7261365 -0.15684993 -0.06914768    4
#> 3 -2.5462245 -0.52011589 -0.21349382    4
#> 4  2.0462615 -0.05887657 -0.20395587    3
#> 5  0.3612184 -0.12350301 -0.08362549    3
#> 6  0.2278300 -0.33214543 -0.46694411    3

Created on 2023-05-29 with reprex v2.0.2

Should we change following code:

    if (isTRUE(partial)) {
      data[[x]] <- datawizard::adjust(data[names(data) != y], multilevel = multilevel, bayesian = partial_bayesian)[[x]]
      data[[y]] <- datawizard::adjust(data[names(data) != x], multilevel = multilevel, bayesian = partial_bayesian)[[y]]
    }

so that it only takes x and factors? Like

adjust_vars <- c(x, names(data[vapply(data, is.factor, TRUE)]))
data[[x]] <- datawizard::adjust(data[adjust_vars], multilevel = multilevel, bayesian = partial_bayesian)[[x]]
adjust_vars <- c(y, names(data[vapply(data, is.factor, TRUE)]))
data[[y]] <- datawizard::adjust(data[adjust_vars], multilevel = multilevel, bayesian = partial_bayesian)[[y]]

from correlation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.