Learn R Programming

sdm (version 1.2-55)

threshold: Identifying/extracting the best threshold to convert probabilities to Presence/Absences

Description

To transform the values of predicted probability of occurrence (habitat suitability) to presence-absences, a threshold is needed. To identify the best threshold, several (15+) optimisation criteria are supported by the package which is calculated for each model in the sdmModels object. To extract the best threshold from each model (given its modelID specified in the id argument), these functions can be used. It is also possible to specify id = "ensemble" to identify the best threshold for the ensemble of models.

Usage

threshold(x,id,opt,species,...)
getThreshold(x,id,opt,species,...)

Value

a numeric value

Arguments

x

an sdmModels object (output of the sdmData function)

id

can be either a numeric vector specifying the modelIDs corresponding to SDMs in x, or a single character "ensemble" to ask the function to find the best threshold for the ensemble of models

opt

specifies the optimisation criterion based on which a threshold is identified; default is opt=2 (see evaluates for more details)

species

default=NULL; if the models for multiple species are available in x, species specifies the name of species or a single number specifies which species from the available species should be considered

...

if id = "ensemble", additional arguments are passed to the ensemble function; for example, setting list can be provided for the ensemble function!

Details

Both the threshold and getThreshold functions are the same

References

Naimi, B., Araujo, M.B. (2016) sdm: a reproducible and extensible R platform for species distribution modelling, Ecography, 39:368-375, DOI: 10.1111/ecog.01881

Examples

Run this code
if (FALSE) {

# let's first fit a set of models and generate prediction and ensemble maps:

# get the path to the species data
file <- system.file("external/sp1.shp", package="sdm") 

sp <- vect(file) # read the species records

path <- system.file("external", package="sdm") # path to the folder contains the data

lst <- list.files(path=path,pattern='asc$',full.names = T) # list of predictor filenames

preds <- rast(lst) # making a SpatRaster object (predictors)

d <- sdmData(formula=Occurrence~., train=sp, predictors=preds)

d

# fit two models:
m <- sdm(Occurrence~.,data=d,methods=c('glmp','brt'),replication='boot',n=1)

m 

threshold(m,id=1,opt=1) # get threshold for the first model 

threshold(m,id=1:2,opt=1) # get thresholds for the first and second models

threshold(m,id=1:2,opt=2) # get thresholds for the first and second models

threshold(m,id="ensemble",opt=2) # get threshold based on the ensemble of models

}

Run the code above in your browser using DataLab