varImp {SDMtune} | R Documentation |
Variable Importance
Description
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.
Usage
varImp(model, permut = 10, progress = TRUE)
Arguments
model |
SDMmodel or SDMmodelCV object. |
permut |
integer. Number of permutations. |
progress |
logical. If |
Details
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.
Value
data.frame with the ordered permutation importance.
Author(s)
Sergio Vignali
Examples
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
pattern = "grd",
full.names = TRUE)
predictors <- terra::rast(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)
vi
# 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)
vi