This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
tjursR2Weighted.Rd
65 lines (54 loc) · 2.51 KB
/
tjursR2Weighted.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tjursR2Weighted.r
\name{tjursR2Weighted}
\alias{tjursR2Weighted}
\title{Weighted Tjur's R2}
\usage{
tjursR2Weighted(
pres,
contrast,
presWeight = rep(1, length(pres)),
contrastWeight = rep(1, length(contrast)),
na.rm = FALSE,
bg = NULL,
bgWeight = NULL,
...
)
}
\arguments{
\item{pres}{Predictions at presence sites.}
\item{contrast}{Predictions at absence/background sites.}
\item{presWeight}{Weights of presence cases. The default is to assign each presence case a weight of 1.}
\item{contrastWeight}{Weights of absence/background cases. The default is to assign each case a weight of 1.}
\item{na.rm}{Logical. If \code{TRUE} then remove any presences and associated weights and background predictions and associated weights with \code{NA}s.}
\item{bg}{Same as \code{contrast}. Included for backwards compatibility. Ignored if \code{contrast} is not \code{NULL}.}
\item{bgWeight}{Same as \code{contrastWeight}. Included for backwards compatibility. Ignored if \code{contrastWeight} is not \code{NULL}.}
\item{...}{Other arguments (unused).}
}
\value{
Numeric value.
}
\description{
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).
}
\examples{
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)
}
\references{
Tjur, T. 2009. Coefficients of determination in logistic regression models—A new proposal: The coefficient of discrimination. \emph{The American Statistician} 63:366–372. \doi{10.1198/tast.2009.08210}.
}
\seealso{
\code{\link{tjursR2Weighted}}, \code{\link{fpb}}, \code{\link{contBoyce}}, \code{\link[dismo]{evaluate}}
}