varImp {SDMtune}R Documentation

Variable Importance


The function randomly permutes one variable at time (using training and absence/background datasets) and computes the decrease in training AUC. The result is normalized to percentages. Same implementation of MaxEnt java software but with the additional possibility of running several permutations to obtain a better estimate of the permutation importance. In case of more than one permutation (default is 10) the average of the decrease in training AUC is computed.


varImp(model, permut = 10)



SDMmodel or SDMmodelCV object.


integer. Number of permutations, default is 10.


Note that it could return values slightly different from MaxEnt Java software due to a different random permutation.

For SDMmodelCV objects the function returns the average and the standard deviation of the permutation importances of the single models.


data.frame with the ordered permutation importance.


Sergio Vignali


# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
                    pattern = "grd", full.names = TRUE)
predictors <- raster::stack(files)

# Prepare presence and background locations
p_coords <- virtualSp$presence
bg_coords <- virtualSp$background

# Create SWD object
data <- prepareSWD(species = "Virtual species", p = p_coords, a = bg_coords,
                   env = predictors, categorical = "biome")

# Split presence locations in training (80%) and testing (20%) datasets
datasets <- trainValTest(data, test = 0.2, only_presence = TRUE)
train <- datasets[[1]]
test <- datasets[[2]]

# Train a model
model <- train(method = "Maxnet", data = train, fc = "l")

# Compute variable importance
vi <- varImp(model, permut = 5)

# Same example but using cross validation instead of training and testing
# datasets
# Create 4 random folds splitting only the presence locations
folds = randomFolds(data, k = 4, only_presence = TRUE)
model <- train(method = "Maxnet", data = data, fc = "l", folds = folds)
# Compute variable importance
vi <- varImp(model, permut = 5)

[Package SDMtune version 1.1.5 Index]