View source: R/thresholdWeighted.r
thresholdWeighted | R Documentation |
This function is similar to the threshold
function in the dismo package, which calculates thresholds to create binary predictions from continuous values. However, unlike that function, it allows the user to specify weights for presences and absence/background predictions. The output will thus be the threshold that best matches the specified criterion taking into account the relative weights of the input values.
thresholdWeighted( pres, contrast, presWeight = rep(1, length(pres)), contrastWeight = rep(1, length(contrast)), at = c("msss", "mdss", "minPres", "orss", "sedi", "prevalence", "sensitivity"), sensitivity = 0.9, thresholds = seq(0, 1, by = 0.01), delta = 0.001, na.rm = FALSE, bg = NULL, bgWeight = NULL, ... )
pres |
Numeric vector. Predicted values at test presences. |
contrast |
Numeric vector. Predicted values at background/absence sites. |
presWeight |
Numeric vector same length as |
contrastWeight |
Numeric vector same length as |
at |
Character or character vector, name(s) of threshold(s) to calculate. The default is to calculate them all.
|
sensitivity |
Value of specificity to match (used only if |
thresholds |
Numeric vector. Thresholds at which to calculate the sum of sensitivity and specificity. The default evaluates all values from 0 to 1 in steps of 0.01. |
delta |
Positive numeric >0 in the range [0, 1] and usually very small. This value is used only if calculating the SEDI threshold when any true positive rate or false negative rate is 0 or the false negative rate is 1. Since SEDI uses log(x) and log(1 - x), values of 0 and 1 will produce |
na.rm |
Logical. If |
bg |
Same as |
bgWeight |
Same as |
... |
Other arguments (unused). |
Named numeric vector.
Fielding, A.H. and J.F. Bell. 1997. A review of methods for the assessment of prediction errors in conservation presence/absence models. Environmental Conservation 24:38-49.
Wunderlich, R.F., Lin, P-Y., Anthony, J., and Petway, J.R. 2019. Two alternative evaluation metrics to replace the true skill statistic in the assessment of species distribution models. Nature Conservation 35:97-116.
threshold
, evaluate
set.seed(123) # set of bad and good predictions at presences bad <- runif(100)^2 good <- runif(100)^0.1 hist(good, breaks=seq(0, 1, by=0.1), border='green', main='Presences') hist(bad, breaks=seq(0, 1, by=0.1), border='red', add=TRUE) pres <- c(bad, good) contrast <- runif(1000) thresholdWeighted(pres, contrast) # upweight bad predictions presWeight <- c(rep(1, 100), rep(0.1, 100)) thresholdWeighted(pres, contrast, presWeight=presWeight) # upweight good predictions presWeight <- c(rep(0.1, 100), rep(1, 100)) thresholdWeighted(pres, contrast, presWeight=presWeight)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.