roc | R Documentation |
Computes the Receiver Operating Characteristic curve for a point pattern or a fitted point process model.
roc(X, ...)
## S3 method for class 'ppp'
roc(X, covariate,
...,
baseline = NULL, high = TRUE, weights = NULL,
observations=c("exact", "presence"),
method = "raw",
CI = "none", alpha=0.05,
subset=NULL)
## S3 method for class 'cdftest'
roc(X, ..., high=TRUE)
## S3 method for class 'bermantest'
roc(X, ..., high=TRUE)
## S3 method for class 'im'
roc(X, covariate, ..., high=TRUE)
X |
Point pattern (object of class |
covariate |
Spatial covariate. Either a |
... |
Arguments passed to |
baseline |
Optional. A spatial object giving a baseline intensity.
Usually a |
high |
Logical value indicating whether the threshold operation should favour high or low values of the covariate. |
weights |
Optional. Numeric vector of weights attached to the data points. |
observations |
Character string (partially matched)
specifying whether to compute the ROC curve using the
exact point coordinates ( |
method |
The method or methods that should be used to estimate the ROC curve.
A character vector: current choices are
|
CI |
Character string (partially matched) specifying whether confidence intervals should be computed, and for which method. See Details. |
alpha |
Numeric value between 0 and 1. The confidence intervals will have
confidence level |
subset |
Optional. A spatial window (object of class |
This command computes the Receiver Operating Characteristic (ROC)
curve. The area under the ROC is computed by auc
.
The function roc
is generic, with methods for point patterns,
fitted point process models, and other kinds of data.
For a point pattern X
and a spatial covariate Z
, the
ROC is a plot showing the ability of the
covariate
to separate the spatial domain
into areas of high and low density of points.
For each possible threshold z
, the algorithm calculates
the fraction a(z)
of area in the study region where the
covariate takes a value greater than z
, and the
fraction b(z)
of data points for which the covariate value
is greater than z
. The ROC is a plot of b(z)
against
a(z)
for all thresholds z
. This is called the βrawβ
ROC curve.
There are currently three methods to estimate the ROC curve:
"raw"
uses the raw empirical spatial cummulative distribution function of the covariate.
"monotonic"
uses a monotonic regression to estimate the relation between the covariate and the point process intensity and then calculates the ROC from that. This corresponds to a either a convex minorant or a concave majorant of the raw ROC curve.
"smooth"
uses a smooth estimate of the relation between the covariate and the point
process intensity and then calculates the ROC from that. See
roc.rhohat
for details.
"all"
uses all of the above methods.
If CI
is one of the strings 'raw'
,
'monotonic'
or 'smooth'
, then
pointwise 95% confidence intervals for the true ROC curve
will be computed based on the raw
, monotonic
or
smooth
estimates, respectively.
The confidence level is 1-alpha
, so that for example
alpha=0.01
would give 99% confidence intervals.
By default, confidence bands for the ROC curve are not computed.
Some other kinds of objects in spatstat contain sufficient data to
compute the ROC curve. These include the objects returned by
rhohat
,
cdf.test
and berman.test
. Methods are
provided here to compute the ROC curve from these objects.
The method for pixel images (objects of class "im"
)
assumes that X
represents a density or intensity function,
and that the objective is to segregate the spatial region into
subregions of high and low total density by thresholding the
covariate
.
Function value table (object of class "fv"
)
which can be plotted to show the ROC curve.
Also belongs to class "roc"
.
.
.
Lobo, J.M., Jimenez-Valverde, A. and Real, R. (2007) AUC: a misleading measure of the performance of predictive distribution models. Global Ecology and Biogeography 17(2) 145β151.
Nam, B.-H. and D'Agostino, R. (2002) Discrimination index, the area under the ROC curve. Pages 267β279 in Huber-Carol, C., Balakrishnan, N., Nikulin, M.S. and Mesbah, M., Goodness-of-fit tests and model validity, Birkhauser, Basel.
roc.ppm
,
roc.lpp
,
roc.rhohat
.
auc
gold <- rescale(murchison$gold, 1000, "km")
faults <- rescale(murchison$faults, 1000, "km")
dfault <- distfun(faults)
if(interactive()) {
plot(roc(gold, dfault, method = "all", high=FALSE))
} else {
## reduce sample resolution to save computation time in test
plot(roc(gold, dfault, method = "all", high=FALSE, eps=8))
}
# Using either an image or reference population as baseline
cases <- split(chorley)$larynx
controls <- split(chorley)$lung
covar <- distfun(as.ppp(chorley.extra$incin, W = Window(chorley)))
if(interactive()) {
population <- density(controls, sigma=0.15, eps=0.1)
} else {
## reduce resolution to save computation time in test
population <- density(controls, sigma=0.3, eps=0.25)
}
population <- eval.im(pmax(population, 1e-10))
roc1 <- roc(cases, covar, baseline = population, high = FALSE, method="all")
roc2 <- roc(cases, covar, baseline = controls, high = FALSE, method="all")
plot(anylist(roc1=roc1, roc2=roc2), main = "")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.