Comments (6)
Fair enough, then at least deprecate first by warning "please replace TRUE by the list of variables you wish to account for"
from correlation.
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.
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.
I don't think we should reserve backwards compatibility - I think it should be treated as a bug / unintended behavior.
from correlation.
This should be applied to partial=
as well.
from correlation.
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)
- Return the number of outliers for Shepherd's pi correlation
- GGM color scheme HOT 4
- Bayesian correlations not working with the latest version of `{parameters}` HOT 12
- plot method documentation missing some parameters
- subset of variables in correlation matrix
- Extend man page HOT 2
- No warnings about ties in data
- Error in Multilevel Correlation HOT 1
- Some tests are failing for R < 4.0
- CRAN check failures HOT 3
- Create GitHub release corresponding to CRAN release
- Changing aesthetics of the correlation plot HOT 2
- Costumizing priors HOT 1
- Suggestion of new function: `cormatrix_to_excel()` HOT 4
- Factors don't always work as intended
- Multilevel rank correlation HOT 1
- refactoring the `correlation` package HOT 6
- Package version doesn't follow easystats' versioning conventions HOT 1
- Bayesian partial correlations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from correlation.