auc_metrics | R Documentation |
Computes partial AUC ratios between model predictions and random curves at a specified threshold, with options for sampling and iterations. Handles both numeric vectors and SpatRaster inputs.
auc_metrics(
test_prediction,
prediction,
threshold = 5,
sample_percentage = 50,
iterations = 500,
compute_full_auc = TRUE
)
test_prediction |
Numeric vector of test prediction values (e.g., model outputs) |
prediction |
Numeric vector or SpatRaster object containing prediction values |
threshold |
Percentage threshold for partial AUC calculation (default = 5) |
sample_percentage |
Percentage of test data to sample (default = 50) |
iterations |
Number of iterations for estimating bootstrap statistics (default = 500) |
compute_full_auc |
Logical. If TRUE, the complete AUC values will be computed |
Partial ROC is calculated following Peterson et al. (2008; \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.ecolmodel.2007.11.008")}). The function calculates partial AUC ratios by:
Validating input types and completeness
Handling NA values and SpatRaster conversion
Checking for prediction variability
Computing AUC metrics using optimized C++ code
When prediction values have no variability (all equal), the function returns NA values with a warning.
A list containing:
If input has no variability: List with NA values for AUC metrics
Otherwise: Matrix of AUC results.
Peterson, A.T. et al. (2008) Rethinking receiver operating characteristic analysis applications in ecological niche modeling. Ecol. Modell., 213, 63–72.
# With numeric vectors
test_data <- rnorm(100)
pred_data <- rnorm(100)
result <- fpROC::auc_metrics(test_prediction = test_data, prediction = pred_data)
# With SpatRaster
library(terra)
r <- terra::rast(ncol=10, nrow=10)
values(r) <- rnorm(terra::ncell(r))
result <- fpROC::auc_metrics(test_prediction = test_data, prediction = r)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.