thresholds: Thresholds

View source: R/thresholds.R

thresholdsR Documentation

Thresholds

Description

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.

Usage

thresholds(model, type = NULL, test = NULL)

Arguments

model

SDMmodel object.

type

character. The output type used for "Maxent" and "Maxnet" methods, possible values are "cloglog" and "logistic".

test

SWD testing locations, if not provided it returns the training and test thresholds.

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.

Value

data.frame with the thresholds.

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")

# Get the cloglog thresholds
thresholds(model,
           type = "cloglog")

# Get the logistic thresholds passing the test dataset
thresholds(model,
           type = "logistic",
           test = test)

SDMtune documentation built on July 9, 2023, 6:03 p.m.