Skip to content

Navigation Menu

Sign in
Sign up

Working on caret based models #446

Unanswered
asheetal asked this question in Theoretical contemplations
May 4, 2022 · 3 comments · 2 replies
Discussion options

repeat of question
I want to use model agnostic caret objects to extract effect size. Wondering how to go about that.

You must be logged in to vote

Replies: 3 comments 2 replies

Comment options

Can you give more information, perhaps an example of what you are looking for?

Non-parametric models (like xgboot) don't really lend themselves to predictor specific effect sizes. There are variable importance measures you might want to look at:
https://topepo.github.io/caret/variable-importance.html

You must be logged in to vote
0 replies
Comment options

yes variable importance is part of the solution. However conceptually if one could consider R-square of 100% to be a model that perfectly explains the dependent variable, then an R-square of 10% means 90% is unexplained effect. So hoping for a way to get model agnostic effect distribution of predictors

You must be logged in to vote
0 replies
Comment options

You can get model-wise diagnostics.

But predictor-wise is much harder, and in any case would not be model agnostic.

As an example, here is a simple linear model - we can compare the unique contribution of each predictor by leaving it out and seeing the change in R square. And yet...

m <- lm(mpg ~ cyl + am + hp,
 data = mtcars)
m_drop_cyl <- update(m, formula. = . ~ . - cyl)
m_drop_am <- update(m, formula. = . ~ . - am)
m_drop_hp <- update(m, formula. = . ~ . - hp)
R2_total <- performance::r2(m)[[1]]

The difference should be the unique contribution of each model

R2_delta_cyl <- R2_total - performance::r2(m_drop_cyl)[[1]]
R2_delta_am <- R2_total - performance::r2(m_drop_am)[[1]]
R2_delta_hp <- R2_total - performance::r2(m_drop_hp)[[1]]
c(R2_total = R2_total,
 Sum_unique_R2 = R2_delta_cyl + R2_delta_am + R2_delta_hp)
#> R2_total.R2 Sum_unique_R2.R2 
#> 0.8041352 0.1306490

Created on 2022年05月04日 by the reprex package (v2.0.1)

In more complex models this becomes even more prominent - e.g., in tree based models or KNN, predictors interact in complex ways...

You must be logged in to vote
2 replies
Comment options

This above works only for linear models that is already a non-issue mathematically. Curious to see effect sizes in let's say xgboost or SVM.

Comment options

My point was that it doesn't work even in linear models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #445 on May 04, 2022 17:33.

AltStyle によって変換されたページ (->オリジナル) /