Skip to contents

Any metrics, the Pareto front, bootstrap, prediction scales, calibration, the Boyce index, response curves and variable importance.

17. Evaluating and selecting models

The model-selection tools implement the approach of:

Konowalik, K., Nosol, A. (2021). Evaluation metrics and validation of presence-only species distribution models based on distributional maps with varying coverage. Scientific Reports 11, 1482. https://doi.org/10.1038/s41598-020-80062-1

One finding of the paper was that AUC and MAE used together are a reliable way to compare models (Figure 6 in the paper). AUC measures how well a model ranks presences above absences. MAE measures how close the predicted suitability values are to what was observed. A model can have an excellent AUC and still be badly calibrated, and MAE reveals this (see section 18.1).

On top of this, the package offers:

  • any metrics you choose: AUC vs MAE by default, plus TSS, the continuous Boyce index, bias, the calibration slope and intercept, the Brier score or your own metrics;
  • Pareto-front selection with a tolerance for ties, or conventional minimum values;
  • bootstrap confidence intervals and the probability that each model is on the Pareto front, resampling single points or whole spatial blocks;
  • spatial block cross-validation across folds and background sets;
  • temporal validation of hindcasts against fossil or other dated records;
  • a check of the response curves for ecological plausibility;
  • ready-to-publish ggplot2 figures.

17.1 Quick start with example data

library(preENM)

sim <- simulate_enm_data(seed = 1)          # 7 example "models" + points
res <- evaluate_models(sim$models, sim$presence, sim$absence,
                       n_boot = 500, seed = 1)
res
plot_pareto(res)
plot_pareto(res, zoom = TRUE)               # zoom in on the best models
ENM evaluation: 7 model(s), 100 presence and 300 absence/background points
Bootstrap: 500 resamples, 95% percentile intervals
Criteria: AUC (higher is better), MAE (lower is better)
Pareto front (best trade-offs): Maxent_LQ, GLM, Maxent_H_rm4

 rank        model   AUC AUC_lower AUC_upper   MAE MAE_lower MAE_upper   bias   TSS  Boyce pareto_front p_pareto distance
    1    Maxent_LQ 0.980     0.967     0.990 0.164     0.143     0.185 -0.109 0.850  0.908            1    1.000    0.001
    2          GLM 0.981     0.969     0.991 0.316     0.296     0.336 -0.290 0.883  0.911            1    0.386    0.234
    3 Maxent_H_rm4 0.980     0.968     0.990 0.247     0.231     0.264 -0.146 0.857  0.961            1    0.344    0.128
    4 RandomForest 0.978     0.964     0.989 0.204     0.193     0.216  0.027 0.877  0.941            2    0.352    0.062
    5          GBM 0.968     0.951     0.982 0.239     0.218     0.259 -0.162 0.820  0.978            3    0.028    0.116
    6      BIOCLIM 0.821     0.777     0.863 0.623     0.610     0.637 -0.604 0.587  0.830            4    0.000    0.739
    7       Random 0.457     0.396     0.523 0.522     0.495     0.549 -0.261 0.033 -0.263            4    0.000    0.896

In the plots, axes are oriented so that better models are top-right: the MAE axis is reversed because lower MAE is better.

All modelsZoomed on the best models

In the zoomed plot, the top five models have overlapping AUC intervals, so AUC alone cannot separate them. MAE can. Maxent_LQ is on the Pareto front in 100% of bootstrap resamples, which makes it a robust choice. GLM, Maxent_H_rm4 and RandomForest reach the front only about a third of the time.

17.2 Using your own data

You need three things:

  1. Model output rasters, from Maxent, biomod2, ENMeval, predicts, dismo, or any other software, even outside R. Values should be on a 0–1 scale (e.g. Maxent cloglog or logistic output); see Prediction scales below.
  2. Presence points.
  3. Absence points. If you have no true absences, use background or pseudo-absence points.
library(preENM)

models <- c(maxent  = "M:/GIS/models/maxent_model.tif",
            glm     = "M:/GIS/models/glm_model.tif",
            rf      = "M:/GIS/models/rf_model.tif")
# or: models <- terra::rast(list.files("M:/GIS/models", "\\.tif$", full.names = TRUE))

res <- evaluate_models(models,
                       presence = "D:/rs_pres.csv",
                       absence  = "D:/rs_abs.csv",
                       n_boot = 1000, seed = 123)
res
plot_pareto(res)

# Save the results
write.csv(res, "model_evaluation.csv", row.names = FALSE)
plot_pareto(res, file = "model_selection.png", width = 2100, height = 1500)

Coordinate columns named lon/lat, longitude/latitude, x/y or decimalLongitude/decimalLatitude (GBIF) are detected automatically. Otherwise pass coords = c("my_x_column", "my_y_column"). Coordinates in a CSV are assumed to be WGS84 longitude/latitude. If they are not, give the CRS, e.g. points_crs = "EPSG:3035". Points that fall on NA cells are dropped from all models (na_action = "common"), so every model is compared on the same points. Use na_action = "per_model" to drop them separately for each model instead.

If you already have predicted values at your points, skip the rasters:

tab <- data.frame(obs = c(1, 1, 0, 0, ...),   # 1 = presence, 0 = absence
                  maxent = c(...), glm = c(...))
evaluate_models(data = tab, n_boot = 1000)

17.3 Prediction scales (0-1, 0-100, 0-1000)

Algorithms write their predictions on different scales: 0-1 (probability, Maxent cloglog), 0-100 or 0-1000 (biomod2 stores integers to save space). AUC does not care, but MAE, bias, calibration, thresholds and ensembles are only comparable on one scale. Every function that takes several models (extract_predictions(), evaluate_models(), evaluate_cv(), calibration_curve(), ensemble_models(), partition_uncertainty()) therefore checks the scale of each model from its largest value and, with rescale = TRUE (the default), divides models on 0-100 or 0-1000 by 100 or 1000, with a message naming them. rescale = FALSE keeps the values and warns. Models whose scale cannot be recognised (negative values, or values above 1000 such as raw Maxent output) are left as they are, with a warning: use probability-like output instead. A model on 0-100 that never exceeds 1 cannot be recognised, so check the message.

17.4 Choosing which metrics to compare

AUC vs MAE is the default, but any metric pair, or more than two metrics, can be compared. Give each criterion a direction: "max" (higher is better), "min" (lower is better) or "zero" (closer to 0 is better):

# TSS and the Boyce index instead of AUC and MAE
res2 <- evaluate_models(sim$models, sim$presence, sim$absence,
                        criteria = c(TSS = "max", Boyce = "max"),
                        n_boot = 500, seed = 1)
plot_pareto(res2)

# three criteria: AUC, MAE and bias (closer to 0 is better)
res3 <- evaluate_models(sim$models, sim$presence, sim$absence,
                        criteria = c(AUC = "max", MAE = "min", bias = "zero"))
plot_pareto(res3)                         # shows AUC vs MAE, front on all three
plot_pareto(res3, x_metric = "bias")      # any metric on either axis

# your own metric, e.g. the Brier score
brier <- function(obs, pred) mean((obs - pred)^2)
res4 <- evaluate_models(sim$models, sim$presence, sim$absence,
                        metrics = list(Brier = brier),
                        criteria = c(AUC = "max", Brier = "min"))
TSS vs Boyce
TSS vs Boyce

The built-in metrics are AUC, MAE, MAEbal, bias, TSS and Boyce. MAEbal (balanced MAE) averages the error on presences and on background points, (mean(1 - pred | presence) + mean(pred | background)) / 2. With thousands of background points the plain MAE is dominated by them and rewards narrow models; MAEbal weighs both classes equally and does not depend on the number of background points, so prefer it with presence-background data: criteria = c(AUC = "max", MAEbal = "min"). A custom metric is any function(obs, pred) that returns one number (obs is 0/1, pred the predicted suitability); one with a built-in name replaces it. The same metrics argument works in evaluate_cv(), and select_models() / plot_selection() take the same criteria. The bootstrap gives confidence intervals and p_pareto for whichever criteria you choose.

17.5 How the selection works

  1. Metrics. For each model, compute AUC (Mann–Whitney formulation, higher is better), MAE (mean(|obs − pred|), lower is better), MAEbal (MAE averaged over presences and background, lower is better), bias (mean(obs − pred), closer to 0 is better), TSS and the Boyce index. AUC and MAE are the default criteria; see Choosing which metrics to compare.
  2. Pareto front. Model A dominates model B if A is at least as good on every criterion (by default AUC and MAE) and strictly better on one. Models that no other model dominates form the Pareto front. These are the defensible choices, each a different trade-off. With tol, differences smaller than the tolerance count as ties. Dominated models can be discarded. Repeating the procedure on the remaining models gives fronts 2, 3, … (non-dominated sorting).
  3. Compromise distance. The criteria are rescaled to 0–1 and each model’s distance to the ideal point (the best value of every criterion) is computed. Use it to pick one model from the front. weights = c(AUC = 2, MAE = 1) makes AUC count twice as much.
  4. Bootstrap robustness. Presence and absence points are resampled with replacement (stratified) n_boot times and everything is recomputed. This gives confidence intervals for each criterion and p_pareto, the proportion of resamples in which a model is on the Pareto front. Small differences between models are often within sampling noise, and p_pareto shows how much your choice depends on the particular evaluation points. Records are usually clustered, so nearby points are not independent and a bootstrap of single points makes the intervals too narrow: boot_blocks = 50 resamples whole 50 km blocks instead (or give one block id per point, e.g. attr(spatial_folds(...), "block")).
  5. Final rank. Models are ordered by Pareto front, then p_pareto, then distance. With rank_by = "front" the compromise distance is left out: models of one front share a rank, so the order within the front is yours to choose.

What the metrics mean depends on what the zeros are. With background points (data_type = "background", the default) AUC measures how well a model separates presences from the background, while MAE, bias and the calibration metrics treat background points as absences: they compare models evaluated on the same background, not absolute errors. With recorded absences (data_type = "absence") they have their usual meaning; with pseudo-absences ("pseudo_absence") they depend on how these were generated. The setting changes no number, only what the printout says.

pareto_rank() works on any table with any number of criteria, e.g. metrics computed elsewhere such as AICc or omission rates:

pareto_rank(my_table, maximize = c("AUC", "TSS"), minimize = c("MAE", "AICc"),
            zero = "bias")

17.6 Plotting any metrics, zoom and 3-D

When many algorithms perform alike, the plot gets crowded in one corner. plot(sel) (also drawn by select_models() in interactive sessions) shows the full view and, next to it, a zoom on the region of the best models: the Pareto fronts of the two plotted metrics are added one by one until at least half of the models are included. Models outside the zoom are named in the subtitle, and selected models are always drawn on top. Dashed lines mark the required minimum and maximum values. Error bars (red, bar_colour to change, error_bars = FALSE to hide) show, for each axis, the bootstrap interval (<metric>_lower, <metric>_upper) or else +/- 1 SD across runs (<metric>_sd); keep those columns when you join tables for select_models(). evaluate_models(boot_metrics = "all") gives intervals for every metric, not only the criteria.

Full view and zoom
Full view and zoom

plot_models() draws any metrics of select_models(), evaluate_models() or evaluate_cv() output (or any table with a model column):

plot_models(sel, x = "bias", y = "AUC")                  # any pair
plot_models(sel, x = "MAEbal", y = "AUC", zoom = TRUE)   # zoom only
plot_models(sel, x = "MAEbal", y = "AUC", zoom = list(x = c(0.19, 0.24),
                                                      y = c(0.89, 0.93)))
plot_models(sel, x = "MAEbal", y = "AUC", interactive = TRUE)  # hover, zoom
plot_models(sel, x = "MAEbal", y = "AUC", z = "fossil_AUC_deep",  # 3-D
            file = "selection_3d.html")                 # saved, opens in browser

Interactive and 3-D plots use the plotly package (install.packages("plotly")); they open in the RStudio viewer or the browser, can be rotated and hovered over (all values of a model), and saved as one HTML file. Axes always run from worse to better. Static plots are ggplot objects: save them with ggplot2::ggsave().

18. Beyond discrimination: calibration, Boyce index, response curves, importance

Discrimination metrics such as AUC tell whether presences rank above absences. Four further questions decide whether a model can be trusted as a map and read ecologically: are its values probabilities (18.1), is the Boyce index reliable with the presences available (18.2), does the model respond to the environment in a plausible way (18.3), and is the importance of the variables stable (18.4)?

18.1 Calibration: can the predictions be read as probabilities?

Discrimination (AUC, TSS, Boyce) only asks whether presences get higher predictions than absences; calibration asks whether a prediction of 0.3 means the species is found at about 30% of such places. MAE is one answer; the machine-learning literature has since formalised the question into a standard toolkit (Silva Filho et al. 2023, Machine Learning 112, 3211-3260), which calibration_curve() implements:

tab <- extract_predictions(models, presence, absence)
cc <- calibration_curve(tab)                 # every model; bins = 10
cc                                           # over- or under-confident?
plot_calibration(cc, file = "calibration.pdf")
brier_decompose(tab$obs, tab$GLM)            # reliability, resolution, uncertainty
Reliability diagrams of seven models
Reliability diagrams of seven models
  • Reliability diagram: the predictions are cut into bins of equal width (or, with binning = "count", equal numbers of points); for each bin the observed frequency of presences is plotted against the mean prediction of the bin, with a binomial confidence interval. Points on the dashed 1:1 line mean good calibration.
  • Calibration slope: the slope of a logistic regression of the observations on the logit of the predictions. 1 is calibrated; below 1 the model is over-confident (too extreme: high predictions too high, low ones too low); above 1 under-confident (too moderate).
  • Calibration intercept: the intercept of the same regression with the slope fixed at 1. 0 is calibrated; above 0 the predictions are too low on average, below 0 too high.
  • Brier score and its decomposition: Brier = reliability - resolution + uncertainty, plus two small within-bin terms that make it exact with binned predictions (Stephenson et al. 2008). Lower reliability (calibration loss) and higher resolution are better; uncertainty is the same for every model.

The three can be Pareto criteria next to AUC and MAE, which gives the evaluation all three sides, discrimination, calibration and ranking:

evaluate_models(data = tab, criteria = c(AUC = "max",
                                         calibration_slope = "one"))
evaluate_models(data = tab, metrics = "brier")   # only add the column

"one" is a direction like "max", "min" and "zero": closer to 1 is better.

Presence-background data. With background points instead of true absences, the “observed frequency” in a bin is the share of presences among presences and background points. It depends on the number of background points and on how well they represent the environment of the study area (the environmental representativeness effect; Jimenez-Valverde 2025, Ecology and Evolution 15, e72573; 2026, Biodiversity Informatics 20, 74-80). Then these values compare models evaluated on the same presences and background; they do not measure calibration in absolute terms. Predictions must be on the 0-1 scale (e.g. Maxent cloglog, not raw output).

18.2 The Boyce index with few presences

The continuous Boyce index (Hirzel et al. 2006) correlates the predicted-to-expected (P/E) ratio, the share of presences divided by the share of background points, with the predicted value. The classical estimator computes the ratio in a moving window; with few presences the ratios of neighbouring windows fluctuate and every fluctuation lowers the index, so it is underestimated below about 50-200 presences (Liu et al. 2024, Ecography 2025, e07218). Liu et al. instead model the probability that a point is a presence rather than a background point as a smooth function of the prediction, from all points at once; the odds of that curve are proportional to the P/E ratio.

pres <- tab$GLM[tab$obs == 1]
bg <- tab$GLM[tab$obs == 0]
boyce_index(pres, bg)                         # moving window (default)
b <- boyce_index(pres, bg, smooth = "spline", n_boot = 199, seed = 1)
b                                             # index, interval, P/E curve
plot_boyce(b, file = "boyce.pdf")
evaluate_models(data = tab, metrics = "Boyce_smooth")   # next to Boyce
Smoothed P/E curve of a simulated model evaluated with 30 presences and 5000 background points, with its 95% bootstrap band
Smoothed P/E curve of a simulated model evaluated with 30 presences and 5000 background points, with its 95% bootstrap band

smooth = "spline" is a penalised logistic regression spline computed without extra packages, "gam" the thin plate spline of Liu et al. (needs mgcv; the two agree closely), "loess" a local regression. n_boot resamples presences and background for a confidence interval of the index and a band around the curve; details = TRUE returns the curve without bootstrap.

Which estimator? The moving window stays the default, so earlier results do not change, and because the smoothed index has two weaknesses of its own. For a model no better than random the fitted curve is nearly a straight line, and the Spearman correlation of any straight line is +1 or -1: in 200 simulated random models with 50 presences, the smoothed index was 0.9 or more in a third, the moving window never. And for good models it is often exactly 1, so it no longer separates them (in the example data, four of five good models score 1.000 against 0.91-0.98 with the moving window). The printout therefore tests the smoothed curve against a flat one and says when the index cannot be read. Use the smoothed index with few presences, together with its bootstrap interval, and compare models with the same estimator.

18.3 Response curves: are they ecologically plausible?

Performance metrics do not tell whether a model responds to the environment in a plausible way. Models selected by the usual metrics can have implausible responses that extrapolate badly under climate change (Fiorentino et al. 2025, Ecological Modelling 508, 111207), and machine-learning models overfit into irregular responses that the metrics do not reveal (Chollet Ramampiandra et al. 2023, Ecological Modelling 481, 110353). The shape also decides how a model behaves under new conditions: predictions hold where new conditions fall near the optimum and fail in the tails (Allyn et al. 2025, Diversity and Distributions 31, e70036), and a truncated niche worsens extrapolation (Yau et al. 2026, Ecological Informatics 99, 104008).

response_check() takes the response curves your modelling software exports (a long table of variable, value, suitability, optionally by model and run), or raw predictions with the predictor values (then the mean prediction in classes of each predictor, a marginal response):

rc <- response_check(curves, occurrences = env_at_presences,
                     background = env_at_background,
                     projection = future_env)       # data.frame or rasters
rc                                    # implausible shapes, rising edges
plot_response_check(rc, file = "responses.pdf")
Response curves of two models with their shapes and the density of records
Response curves of two models with their shapes and the density of records

For each variable and model it reports the shape (increasing, decreasing, unimodal, U-shaped, irregular or flat), the number of turning points (reversals larger than 5% of the curve’s range), the wiggliness (total variation / range: 1 for a monotonic curve, up to 2 for one peak; above 3 irregular), the optimum and its position in the calibrated range, and whether the curve is still rising at an edge of the calibrated range, where the optimum may lie beyond the data and predictions beyond depend on how the algorithm extrapolates. With occurrences (and background) it says whether the curve follows the records along the gradient, and with projection how much of the projected area lies beyond a rising edge (compare extrapolation_risk() and environment_shift()). The limits are preENM defaults, not from the literature.

Which shape is plausible? It depends on the gradient and on how much of it the data cover (Austin 2002, Ecological Modelling 157, 101-118):

Gradient Plausible shape
Direct, acting on the physiology (temperature, pH) a bell: highest at the optimum, falling to zero beyond the tolerance; narrow or broad, skewed, with a peak or a plateau (Fiorentino et al. 2025)
Resource (water, nutrients) a rise that levels off (plateau)
Covered only on one side of the niche monotonic, still rising at the edge: a truncated niche, not a wrong model; the response beyond the edge is unknown (see section 11)
Indirect (elevation, latitude) any shape; the curve says little about the species
Any irregular curves and U-shapes are rarely plausible: the model fits noise or follows where records happen to lie

The curve should not follow how common the values of a predictor are in the area (the raster’s own distribution, often unimodal), but how much more often the species occurs at a value than that value is available. Give background so that the comparison uses the ratio of presence to background density; otherwise a bell of records can merely mirror a bell of available conditions. Background drawn evenly in environmental space (sample_background(method = "envstrat")) gives response curves closer to the species’ true response (Broussin et al. 2024, Ecological Modelling 498, 110865).

18.4 Is variable importance stable?

Importance from one run is a weak basis for interpretation: it changes between algorithms, folds and replicates, and between regions or scenarios. importance_stability() takes importance from any software as a long table (variable, importance, and optionally algorithm, run and group) and gives each variable’s mean share of importance, its mean rank and rank spread, how often it ranks first, and Kendall’s W, the agreement of the rankings over runs. With group it says whether the most important variable differs between regions or scenarios.

st <- importance_stability(importance, algorithm = "algorithm", run = "fold",
                           group = "region")
st
plot_importance_stability(st)
Rank of each variable over runs and algorithms, with Kendall W
Rank of each variable over runs and algorithms, with Kendall W