Learn R Programming

spatstat.model (version 3.4-0)

roc.ppm: Receiver Operating Characteristic For Fitted Point Process Model

Description

Computes the Receiver Operating Characteristic curve for a fitted point process model.

Usage

# S3 method for ppm
roc(X, covariate=NULL,
                  ..., baseline=NULL, high=TRUE,
                  method = "raw",
                  CI = "none", alpha=0.05,
                  leaveoneout=FALSE, subset=NULL)

# S3 method for slrm roc(X, covariate=NULL, ..., baseline=NULL, high=TRUE, method = "raw", CI = "none", alpha=0.05, leaveoneout=FALSE, subset=NULL)

# S3 method for kppm roc(X, covariate=NULL, ..., baseline=NULL, high=TRUE, method = "raw", CI = "none", alpha=0.05, leaveoneout=FALSE, subset=NULL)

Value

Function value table (object of class "fv") which can be plotted to show the ROC curve. Also belongs to class "roc".

Arguments

X

Fitted point process model (object of class "ppm" or "kppm") or fitted spatial logistic regression model (object of class "slrm").

covariate

Spatial covariate. Either a function(x,y), a pixel image (object of class "im"), or one of the strings "x" or "y" indicating the Cartesian coordinates. Traditionally omitted when X is a fitted model.

...

Arguments passed to as.mask controlling the pixel resolution for calculations.

baseline

Optional. A spatial object giving a baseline intensity. Usually a function(x,y) or a pixel image (object of class "im") giving the baseline intensity at any location within the observation window. Alternatively a point pattern (object of class "ppp") with the locations of the reference population.

high

Logical value indicating whether the threshold operation should favour high or low values of the covariate.

method

The method or methods that should be used to estimate the ROC curve. A character vector: current choices are "raw", "monotonic", "smooth" and "all". See Details.

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 1-alpha. The default gives 95% confidence intervals.

leaveoneout

Logical value specifying (for roc.ppm, roc.slrm, roc.kppm and roc.lppm) whether the fitted intensity of the model at each of the original data points should be computed by the leave-one-out procedure (i.e. by removing the data point in question from the point pattern, re-fitting the model to the reduced point pattern, and computing the intensity of this modified model at the point in question) as described in Baddeley et al (2025). It is also possible to specify leaveoneout=c(TRUE,FALSE) so that both versions are calculated.

subset

Optional. A spatial window (object of class "owin") specifying a subset of the data, from which the ROC should be calculated.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Ege Rubak rubak@math.aau.dk and Suman Rakshit Suman.Rakshit@curtin.edu.au.

Details

The generic function roc computes the Receiver Operating Characteristic (ROC) curve. The area under the ROC is computed by auc.

For a fitted model X and a spatial covariate Z, two ROC curves are computed and plotted together. The first curve is obtained by extracting the original point pattern data to which the model X was fitted, and computing the raw ROC curve as described above. The second curve is the predicted value of the raw curve according to the model, as described in Baddeley et al (2025).

For a fitted model X, if covariate is missing or NULL, the default is to take the covariate to be the fitted probability of presence (if X is a spatial logistic regression model) or the fitted point process intensity (for other models). This is the standard use of the ROC curve in spatial ecology. The ROC shows the ability of the fitted model to separate the spatial domain into areas of high and low density of points. For a fitted spatial logistic regression model, similarly the ROC shows the ability of the fitted presence probabilities to segregate the spatial domain into pixels with high and low probability of presence. The ROC is not a diagnostic for the goodness-of-fit of the model (Lobo et al, 2007).

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.

References

Baddeley, A., Rubak, E., Rakshit, S. and Nair, G. (2025) ROC curves for spatial point patterns and presence-absence data. tools:::Rd_expr_doi("10.48550/arXiv.2506.03414")..

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.

See Also

roc, roc.lpp, roc.rhohat.

addROC, dropROC, addapply, dropply for adding or removing variables from a model.

auc

Examples

Run this code
  gold <- rescale(murchison$gold, 1000, "km")
  faults <- rescale(murchison$faults, 1000, "km")
  dfault <- distfun(faults)
  
  fit <- ppm(gold ~ dfault)
  plot(roc(fit, method="all"))

  ## compare raw estimates with and without using leave-one-out intensity
  plot(roc(fit, leaveoneout=c(FALSE, TRUE)))

Run the code above in your browser using DataLab