Skip to contents

A continuous prediction is turned into a map of suitable and unsuitable cells by a threshold, and the rules for choosing it disagree enough to change the mapped range considerably. Instead of one rule, report several together (Hellegers et al. 2025; Yu et al. 2024). For each rule the function gives the threshold and the resulting sensitivity (share of presences predicted suitable), specificity (share of absences or background points predicted unsuitable), TSS and the predicted-suitable share (share of absence/background points at or above the threshold; with background points that represent the study area, the share of the area mapped as suitable).

Usage

thresholds(
  presence,
  background = NULL,
  rules = threshold_rule_names,
  sensitivity = 0.95,
  prevalence = NULL,
  n_classes = 100,
  rescale = TRUE
)

Arguments

presence

Predictions at presence points, or a table from extract_predictions() (a data.frame with obs and one column per model): then background is not needed and every model gets its rows.

background

Predictions at absence or background points.

rules

Rules to compute (default all, see Details).

sensitivity

Sensitivity kept by the fixed_sens rule.

prevalence

Optional prevalence for the prevalence rule.

n_classes

Number of classes of the P/E curve for the mutation_point rule.

rescale

Bring predictions to the 0-1 scale: the scale of each model (0-1, 0-100 or 0-1000) is recognised from its largest value and 0-100 or 0-1000 are divided by 100 or 1000, with a message; see extract_predictions().

Value

A data.frame of class enm_thresholds with model (if several), rule, threshold, sensitivity, specificity, TSS, MCC, F and suitable_share.

Details

Rules (rules):

  • maxSSS: maximum of sensitivity + specificity (Liu et al. 2013, recommended for presence-background data).

  • maxTSS: maximum of TSS = sensitivity + specificity - 1. It is the same criterion as maxSSS and gives the same threshold; both are reported because both names are in use.

  • equal_ss: sensitivity equal to specificity, i.e. the smallest difference between them (DSS in Hellegers et al. 2025; Liu et al. 2005).

  • maxMCC: maximum of Matthews' correlation coefficient, (TP TN - FP FN) / sqrt((TP + FP)(TP + FN)(TN + FP)(TN + FN)).

  • maxF: maximum of the F-measure, 2 TP / (FN + 2 TP + FP).

    MCC and F penalise overprediction (false positives relative to the predicted presences), so they give smaller ranges than TSS or DSS: in 1671 European plants the median range under maxTSS was 1.3, 3.6 and 9.2 times that under DSS, MCC and F (Hellegers et al. 2025). Both depend on the prevalence of the evaluation data, so with background points instead of absences they depend on how many background points there are; use them with true or pseudo-absences.

  • prevalence: the predicted prevalence equals the prevalence. With prevalence = NULL, the observed prevalence of the evaluation data (presences / all points) and the predicted prevalence over all points (Liu et al. 2005); meaningful with true absences. With a given prevalence (e.g. an estimate of the share of the area the species occupies), the threshold at which that share of the absence/background points is predicted suitable.

  • fixed_sens: the highest threshold that keeps the sensitivity at least at sensitivity (default 0.95): the presence prediction at that rank. The default differs from 0.90 because that is p10.

  • p10: the 10th percentile of the presence predictions (threshold_p10(), an interpolated quantile, so the sensitivity can be slightly below 0.90), i.e. about a fixed sensitivity of 0.90. Usually computed on the training presences; here on the presences given.

  • mutation_point: the "mutation point" of Boyce's predicted-to-expected (P/E) curve, found by threshold regression (BTQR, Yu et al. 2024). The range of the predictions is cut into n_classes classes of equal width (100 in most studies Yu et al. review); for each class the P/E ratio is the share of the presences in the class divided by the share of the background (the area) in it, plotted against the mean prediction of the class. A threshold regression without intercept, P/E = delta1 * s up to the threshold and delta2 * s above it, is fitted for every candidate threshold among the class means between their 10th and 90th percentiles (10% trimming), and the one with the smallest residual sum of squares is the threshold. It needs no absences: the background stands for the study area. Yu et al. relate it, through source-sink theory, to the transition to high-quality habitat, so it is usually strict.

Sensitivity and specificity are computed with prediction >= threshold as suitable. Ties among candidate thresholds are resolved towards the lowest threshold reaching the optimum.

Limits. With background points, specificity and TSS count unrecorded presences as errors, and the predicted-suitable share equals the mapped area only when the background represents the area evenly.

References

Hellegers, M., van Hinsberg, A., Lenoir, J., Dengler, J., Huijbregts, M.A.J., Schipper, A.M. (2025) Multiple threshold-selection methods are needed to binarise species distribution model predictions. Diversity and Distributions 31, e70019. doi:10.1111/ddi.70019

Yu, B., Dai, W., Li, S., Wu, Z., Wang, J. (2024) A new threshold selection method for species distribution models with presence-only data: extracting the mutation point of the P/E curve by threshold regression. Ecology and Evolution 14, e11208. doi:10.1002/ece3.11208

Liu, C., Berry, P.M., Dawson, T.P., Pearson, R.G. (2005) Selecting thresholds of occurrence in the prediction of species distributions. Ecography 28, 385-393.

Liu, C., White, M., Newell, G. (2013) Selecting thresholds for the prediction of species occurrence with presence-only data. Journal of Biogeography 40, 778-789.

Examples

set.seed(1)
pres <- rbeta(200, 5, 2)          # predictions at presences
bg <- rbeta(2000, 2, 4)           # predictions at background points
th <- thresholds(pres, bg)
th
#> Thresholds of the prediction under 9 rules
#> 
#>            rule threshold sensitivity specificity   TSS   MCC     F
#>          maxSSS     0.552       0.860       0.860 0.720 0.512 0.528
#>          maxTSS     0.552       0.860       0.860 0.720 0.512 0.528
#>        equal_ss     0.552       0.860       0.860 0.720 0.512 0.528
#>          maxMCC     0.711       0.605       0.974 0.579 0.618 0.649
#>            maxF     0.706       0.615       0.972 0.587 0.617 0.649
#>      prevalence     0.690       0.635       0.964 0.599 0.599 0.635
#>      fixed_sens     0.425       0.950       0.711 0.660 0.398 0.392
#>             p10     0.501       0.900       0.800 0.700 0.457 0.462
#>  mutation_point     0.706       0.615       0.972 0.587 0.617 0.649
#>  suitable_share
#>           0.140
#>           0.140
#>           0.140
#>           0.026
#>           0.028
#>           0.036
#>           0.290
#>           0.200
#>           0.028
#> 
#> IN SHORT
#> - The area mapped as suitable ranges from 3% of the background (maxMCC,
#>     threshold 0.711) to 29% (fixed_sens, threshold 0.425), 11.1 times as
#>     much. The choice of rule changes the mapped range considerably: report
#>     several rules, or the cells suitable under all of them
#>     (threshold_agreement()).
#>   suitable_share = share of the absence/background points at or above the
#>   threshold (with background that represents the study area, the share of the
#>   area mapped as suitable). maxSSS and maxTSS are the same criterion; p10 is
#>   about a fixed sensitivity of 0.90; MCC and F depend on the number of
#>   absence/background points.
#> 
#> A preENM sensitivity analysis: how much the result depends on the threshold
#> rule. The others are listed in ?sensitivity_analyses.
plot_thresholds(th)


# all models of an extract_predictions() table
sim <- simulate_enm_data(seed = 1)
tab <- extract_predictions(sim$models, sim$presence, sim$absence)
thresholds(tab, rules = c("maxSSS", "p10", "mutation_point"))
#> Thresholds of the prediction under 3 rules
#> 
#>         model           rule threshold sensitivity specificity    TSS    MCC
#>     Maxent_LQ         maxSSS     0.581        0.93       0.920  0.850  0.809
#>     Maxent_LQ            p10     0.652        0.90       0.937  0.837  0.814
#>     Maxent_LQ mutation_point     0.777        0.86       0.967  0.827  0.838
#>  Maxent_H_rm4         maxSSS     0.577        0.91       0.947  0.857  0.838
#>  Maxent_H_rm4            p10     0.590        0.90       0.953  0.853  0.842
#>  Maxent_H_rm4 mutation_point     0.576        0.91       0.947  0.857  0.838
#>           GLM         maxSSS     0.786        0.97       0.913  0.883  0.829
#>           GLM            p10     0.879        0.90       0.973  0.873  0.879
#>           GLM mutation_point     0.849        0.92       0.940  0.860  0.834
#>  RandomForest         maxSSS     0.404        0.92       0.957  0.877  0.863
#>  RandomForest            p10     0.416        0.90       0.960  0.860  0.854
#>  RandomForest mutation_point     0.396        0.92       0.953  0.873  0.857
#>       BIOCLIM         maxSSS     0.937        0.85       0.737  0.587  0.517
#>       BIOCLIM            p10     0.902        0.90       0.640  0.540  0.468
#>       BIOCLIM mutation_point     0.924        0.88       0.700  0.580  0.505
#>        Random         maxSSS     0.174        0.88       0.153  0.033  0.041
#>        Random            p10     0.118        0.90       0.103  0.003  0.005
#>        Random mutation_point     0.373        0.56       0.330 -0.110 -0.099
#>           GBM         maxSSS     0.648        0.89       0.930  0.820  0.795
#>           GBM            p10     0.608        0.90       0.910  0.810  0.771
#>           GBM mutation_point     0.729        0.79       0.960  0.750  0.775
#>      F suitable_share
#>  0.857          0.080
#>  0.861          0.063
#>  0.878          0.033
#>  0.879          0.053
#>  0.882          0.047
#>  0.879          0.053
#>  0.870          0.087
#>  0.909          0.027
#>  0.876          0.060
#>  0.898          0.043
#>  0.891          0.040
#>  0.893          0.047
#>  0.644          0.263
#>  0.604          0.360
#>  0.633          0.300
#>  0.398          0.847
#>  0.392          0.897
#>  0.314          0.670
#>  0.848          0.070
#>  0.829          0.090
#>  0.827          0.040
#> 
#> IN SHORT
#> - Maxent_LQ: the area mapped as suitable ranges from 3% of the background
#>     (mutation_point, threshold 0.777) to 8% (maxSSS, threshold 0.581), 2.4
#>     times as much. The choice of rule changes the mapped range considerably:
#>     report several rules, or the cells suitable under all of them
#>     (threshold_agreement()).
#> - Maxent_H_rm4: the area mapped as suitable ranges from 5% of the background
#>     (p10, threshold 0.59) to 5% (maxSSS, threshold 0.577), 1.1 times as much.
#>     The rules largely agree on the mapped range.
#> - GLM: the area mapped as suitable ranges from 3% of the background (p10,
#>     threshold 0.879) to 9% (maxSSS, threshold 0.786), 3.3 times as much. The
#>     choice of rule changes the mapped range considerably: report several
#>     rules, or the cells suitable under all of them (threshold_agreement()).
#> - RandomForest: the area mapped as suitable ranges from 4% of the background
#>     (p10, threshold 0.416) to 5% (mutation_point, threshold 0.396), 1.2 times
#>     as much. The rules largely agree on the mapped range.
#> - BIOCLIM: the area mapped as suitable ranges from 26% of the background
#>     (maxSSS, threshold 0.937) to 36% (p10, threshold 0.902), 1.4 times as
#>     much. The rules largely agree on the mapped range.
#> - Random: the area mapped as suitable ranges from 67% of the background
#>     (mutation_point, threshold 0.373) to 90% (p10, threshold 0.118), 1.3
#>     times as much. The rules largely agree on the mapped range.
#> - GBM: the area mapped as suitable ranges from 4% of the background
#>     (mutation_point, threshold 0.729) to 9% (p10, threshold 0.608), 2.2 times
#>     as much. The choice of rule changes the mapped range considerably: report
#>     several rules, or the cells suitable under all of them
#>     (threshold_agreement()).
#>   suitable_share = share of the absence/background points at or above the
#>   threshold (with background that represents the study area, the share of the
#>   area mapped as suitable). maxSSS and maxTSS are the same criterion; p10 is
#>   about a fixed sensitivity of 0.90; MCC and F depend on the number of
#>   absence/background points.
#> 
#> A preENM sensitivity analysis: how much the result depends on the threshold
#> rule. The others are listed in ?sensitivity_analyses.