varImportance: Get variable importance

View source: R/response.R

varImportanceR Documentation

Get variable importance

Description

Get variable importance. The importance is expressed as the deterioration of the evaluation statistic. The statistic is computed n times for model predictions after randomizing a predictor variable and subtracting the statistic for the non-randomized data. The larger the difference, the more important the variable is.

Usage

varImportance(model, y, x, n=10, stat, value="relative", ...)

Arguments

model

a model object

y

the response variable used to fit the model. If missing, it is attempted to extract it from model. If that fails, it is computed from x. In the latter case the model would be assumed to have no error

x

data.frame with the predictor variables used to fit the model. If missing, it is attemted to extract it from model

n

positive integer. Number of simulations

stat

character. For models with a continuous response variable this can be one of "RMSE" (the default), "AUC", or "cor". See RMSE or pa_evaluate. For models with a categorical response variable this can be one of "overall" (overall accuracy, the default) or "kappa", see cm_evaluate

value

character specifying how to express the output. One of , "relative" (), "difference" (), "absolute" (no adjustments)

...

model specific additional arguments passed to predict

Value

named numeric vector

Examples


set.seed(1)
d <- data.frame(y=1:10, x1=runif(10), x2=runif(10))
m <- lm(y~., data=d)

varImportance(m, d[,1], d[,2:3])

predicts documentation built on Oct. 7, 2024, 9:06 a.m.