View source: R/occurrence.threshold.R
occurrence.threshold | R Documentation |
A statistical sensitivity test for occurrence probability thresholds
occurrence.threshold(
x,
class,
p = seq(0.1, 0.9, 0.05),
type = c("delta.ss", "sum.ss", "kappa", "youden", "logloss")
)
x |
A classification randomForest model object |
class |
What class to test, quoted |
p |
Vector of probability thresholds |
type |
What statistic to use in evaluation ("delta.ss", "sum.ss", "kappa", "youden", "logloss") |
Available threshold evaluation statistics:
kappa - [The Kappa statistic is maximized]
sum.ss - [The sum of sensitivity and specificity is maximized]
delta.ss - [The absolute value of the difference between sensitivity and specificity is minimized]
youden - [Youden’s J index (sensitivity + specificity) - 1]
logloss - [Optimizes on Log Loss]
An "occurrence.threshold" class object containing a "thresholds" vector, object with evaluation statistic and probability thresholds as names, the probability threshold "prob.threshold" and the test statistic
Jeffrey S. Evans <jeffrey_evans<at>tnc.org>
Jimenez-Valverde, A., & J.M. Lobo (2007). Threshold criteria for conversion of probability of species presence to either-or presence-absence. Acta Oecologica 31(3):361-369
Liu, C., P.M. Berry, T.P. Dawson, R.G. Pearson (2005). Selecting thresholds of occurrence in the prediction of species distributions. Ecography 28:385-393.
Youden, W.J. (1950). Index for rating diagnostic tests. Cancer. 3:2-35.
library(randomForest)
data(imports85)
imp85 <- imports85[,-2]
imp85 <- imp85[complete.cases(imp85), ]
imp85[] <- lapply(imp85, function(x) if (is.factor(x)) x[, drop=TRUE] else x)
y <- ifelse( imp85$numOfDoors != "four", "0", "1")
( rf.mdl <- randomForest(y = as.factor(y), x = imp85[,-5]) )
( delta.ss <- occurrence.threshold(rf.mdl, class = "1", , type = "delta.ss") )
( sum.ss <- occurrence.threshold(rf.mdl, class = "1", type = "sum.ss") )
( kappa.ss <- occurrence.threshold(rf.mdl, class = "1", type = "kappa") )
( logloss.ss <- occurrence.threshold(rf.mdl, class = "1", type = "logloss") )
( youden.ss <- occurrence.threshold(rf.mdl, class = "1", type = "youden") )
opar <- par
par(mfrow=c(2,2))
plot(sum.ss)
plot(delta.ss)
plot(kappa.ss)
plot(logloss.ss)
par <- opar
#### using ranger
library(ranger)
( rf.mdl <- ranger(y = as.factor(y), x = imp85[,-5], probability = TRUE) )
( kappa.ss <- occurrence.threshold(rf.mdl, class = "1", type = "kappa") )
( youden.ss <- occurrence.threshold(rf.mdl, class = "1", type = "youden") )
plot(kappa.ss)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.