View source: R/tjursR2Weighted.r
tjursR2Weighted | R Documentation |
This function calculates Tjur's R2 metric of model discrimination accuracy. Unweighted R2 is simply the difference between the mean predicted value at presence sites and the mean predicted value at absence/background sites. The weighted version allows for differing weights between presences and between absences/contrast values (i.e., the difference between the weighted mean of predictions at presences and weighted mean predictions at absences/contrast locations).
tjursR2Weighted( pres, contrast, presWeight = rep(1, length(pres)), contrastWeight = rep(1, length(contrast)), na.rm = FALSE, bg = NULL, bgWeight = NULL, ... )
pres |
Predictions at presence sites. |
contrast |
Predictions at absence/background sites. |
presWeight |
Weights of presence cases. The default is to assign each presence case a weight of 1. |
contrastWeight |
Weights of absence/background cases. The default is to assign each case a weight of 1. |
na.rm |
Logical. If |
bg |
Same as |
bgWeight |
Same as |
... |
Other arguments (unused). |
Numeric value.
Tjur, T. 2009. Coefficients of determination in logistic regression models—A new proposal: The coefficient of discrimination. The American Statistician 63:366–372. doi: 10.1198/tast.2009.08210.
tjursR2Weighted
, fpb
, contBoyce
, evaluate
pres <- seq(0.5, 1, by=0.1) contrast <- seq(0, 1, by=0.01) # unweighted tjursR2Weighted(pres, contrast) # weighted (weight presences with low predictions more) presWeight <- c(1, 1, 1, 0.5, 0.5, 0.5) tjursR2Weighted(pres, contrast, presWeight=presWeight) # weighted (weight presences with high predictions more) presWeight <- c(0.5, 0.5, 0.5, 1, 1, 1) tjursR2Weighted(pres, contrast, presWeight=presWeight) # weight presences and absences contrastWeight <- sqrt(contrast) tjursR2Weighted(pres, contrast, presWeight=presWeight, contrastWeight=contrastWeight)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.