varImp: Variable Importance

Description Usage Arguments Details Value Author(s) Examples

View source: R/varImp.R

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

1
varImp(model, permut = 10)

Arguments

model

SDMmodel or SDMmodelCV object.

permut

integer. Number of permutations, default is 10.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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)
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

SDMtune documentation built on July 17, 2021, 9:06 a.m.