1
$\begingroup$

I'm using two numerical predictors to find an outcome, when using varImp (from the carret package) one of the predictors has 100 importance and the other 0.

How should I interpret this?

$\endgroup$

1 Answer 1

1
$\begingroup$

You can check out the caret website for how the variable importance is calculated for different models.

100 is the variable with the most importance and 0 the one with the least. By default varImp from caret scales it to have min at 0, max at 100. For example:

library(caret)
mdl_glm = train(mpg ~.,data=mtcars,
trControl=trainControl(method="cv",number=3),method="glm")

If we set scale=FALSE, we see the variable importance, in this case it's the absolute t-statistic:

VI = varImp(mdl_glm,scale=FALSE)
VI
glm variable importance

     Overall
wt    1.9612
am    1.2254
qsec  1.1234
hp    0.9868
disp  0.7468
drat  0.4813
gear  0.4389
carb  0.2406
vs    0.1510
cyl   0.1066

And if we scale it to the maximim:

scaledVI = (VI$importance-min(VI$importance))/(max(VI$importance)-min(VI$importance))
100*scaledVI[order(-scaledVI[,1]),drop=FALSE,]
        Overall
wt   100.000000
am    60.325396
qsec  54.825933
hp    47.461739
disp  34.516160
drat  20.202448
gear  17.916750
carb   7.224752
vs     2.391537
cyl    0.000000

It's the same as:

varImp(mdl_glm)
glm variable importance

     Overall
wt   100.000
am    60.325
qsec  54.826
hp    47.462
disp  34.516
drat  20.202
gear  17.917
carb   7.225
vs     2.392
cyl    0.000
$\endgroup$
2
  • $\begingroup$ Thank you very much for the very elaborate answer, It's exactly what I was looking for! $\endgroup$
    – bolleke
    Commented May 15, 2020 at 8:20
  • $\begingroup$ you're welcome :) glad it's useful $\endgroup$
    – StupidWolf
    Commented May 15, 2020 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.