Compute three threshold values: minimum training presence, equal training sensitivity and specificity and maximum training sensitivity plus specificity together with fractional predicted area and the omission rate. If a test dataset is provided it returns also the equal test sensitivity and specificity and maximum test sensitivity plus specificity thresholds and the p-values of the one-tailed binomial exact test.
Details
The equal training sensitivity and specificity minimizes the difference between sensitivity and specificity. The one-tailed binomial test checks that test points are predicted no better than by a random prediction with the same fractional predicted area.
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")
#> ℹ Extracting predictor information for presence locations
#> ✔ Extracting predictor information for presence locations [20ms]
#>
#> ℹ Extracting predictor information for absence/background locations
#> ✔ Extracting predictor information for absence/background locations [46ms]
#>
# 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")
# Get the cloglog thresholds
thresholds(model,
type = "cloglog")
#> Threshold Cloglog value
#> 1 Minimum training presence 0.1162067
#> 2 Equal training sensitivity and specificity 0.4704779
#> 3 Maximum training sensitivity plus specificity 0.2846842
#> Fractional predicted area Training omission rate
#> 1 0.5136 0.000000
#> 2 0.2376 0.237500
#> 3 0.3578 0.040625
# Get the logistic thresholds passing the test dataset
thresholds(model,
type = "logistic",
test = test)
#> Threshold Logistic value
#> 1 Minimum training presence 0.1099497
#> 2 Equal training sensitivity and specificity 0.3886710
#> 3 Maximum training sensitivity plus specificity 0.2509538
#> 4 Equal test sensitivity and specificity 0.3835992
#> 5 Maximum test sensitivity plus specificity 0.2928592
#> Fractional predicted area Training omission rate Test omission rate P-values
#> 1 0.5136 0.000000 0.0001968504 0
#> 2 0.2376 0.237500 0.0039370079 0
#> 3 0.3578 0.040625 0.0005905512 0
#> 4 0.2414 0.228125 0.0037401575 0
#> 5 0.3230 0.100000 0.0007874016 0