ensemble_models() offers four ways to combine models (PCAm, median,
mean, weighted mean), and none is best everywhere (Zhu et al. 2021).
ensemble_scenarios() combines the same models with each method on one
sample of cells and compares the results:
Usage
ensemble_scenarios(
models,
evaluation = NULL,
methods = c("pcam", "median", "mean", "weighted"),
use = c("selected", "all"),
weights = NULL,
threshold = NULL,
presence = NULL,
absence = NULL,
coords = NULL,
points_crs = "EPSG:4326",
n_sample = 1e+05,
pattern = "\\.tif{1,2}$",
recursive = FALSE,
seed = 1,
rescale = TRUE,
crs = NULL
)Arguments
- models
Prediction rasters: a terra::SpatRaster with one layer per model (layer names = model names), or raster files and/or folders (model names = file names without extension; with
patternandrecursiveas incrop_rasters()). All must share the same grid.- evaluation
Optional result of
select_models()orevaluate_models()(orevaluate_cv()passed throughselect_models()); itsmodelnames must match the rasters.- methods
Methods compared (
"weighted"needsweightsor an evaluation with criteria; it is skipped otherwise).- use
"selected"(default; the Pareto front for anevaluate_models()result) or"all"models of the evaluation.- weights
Optional named weights for
method = "weighted"(names = models); default: the compromise score of the evaluation.- threshold
Optional threshold (0-1 scale) for the suitable share.
- presence, absence
Optional independent points (data frames with coordinates,
sforSpatVector) for the AUC of each ensemble.- coords, points_crs
Coordinate columns and CRS of the points.
- n_sample
Number of cells sampled for the PCA of
"pcam"and for the summaries.- pattern, recursive
File search in folders, as in
crop_rasters().- seed
Seed for the cell sample.
- rescale
Bring every model to the 0-1 scale before combining: algorithms write 0-1, 0-100 or 0-1000, recognised from the largest value of each layer; layers on 0-100 or 0-1000 are divided by 100 or 1000, with a message.
FALSEkeeps them and warns.- crs
Deprecated: the former name of
points_crs, still accepted with a warning.
Value
An object of class ensemble_scenarios: pairs (one row per
pair of methods: mean_abs_diff, spearman), methods (one row per
method: suitable_share, AUC, the PCAm members), sample (the
ensembles of every method at the sampled cells) and settings.
Details
per pair of methods: the mean absolute difference of the ensembles and their rank correlation over the cells;
with
threshold: the share of cells at or above it under each method (the suitable share of the area when the cells represent it);with
presenceandabsence(independent points): the AUC of each ensemble at these points.
It works on a sample of cells (n_sample) and reads the rasters only
there, so global layers are no problem.
Status and limits. A preENM sensitivity design over the methods of
ensemble_models(). The grades of the largest mean absolute difference
(below 0.02 negligible, below 0.05 small, otherwise noticeable, for
predictions on the 0-1 scale) are preENM defaults, not from the
literature. Agreement between methods is not accuracy: all can be wrong
together. What to vary. The models given (use), threshold, and
the independent points.
References
Zhu, G., Fan, J., Peterson, A.T. (2021) Cautions in weighting individual ecological niche models in ensemble forecasting. Ecological Modelling 448, 109502. doi:10.1016/j.ecolmodel.2021.109502
Examples
sim <- simulate_enm_data(seed = 1)
ev <- evaluate_models(sim$models, sim$presence, sim$absence)
es <- ensemble_scenarios(sim$models, ev, use = "all", threshold = 0.5,
presence = sim$presence, absence = sim$absence,
n_sample = 5000)
es
#> Ensemble methods compared: pcam, median, mean, weighted; 7 models, 4800 cells
#>
#> IN SHORT
#> - The choice of method matters noticeable: the largest mean absolute
#> difference between two methods is 0.099 (pcam against mean); rank
#> correlations 0.93 to 0.97.
#> - At the threshold 0.5 the suitable share is pcam 68%, median 72%, mean
#> 73%, weighted 70%.
#> - AUC at the independent points: pcam 0.983, median 0.979, mean 0.979,
#> weighted 0.984. Agreement between methods is not accuracy: they can all
#> be wrong together.
#>
#> method_1 method_2 mean_abs_diff max_abs_diff spearman
#> pcam median 0.056 0.389 0.954
#> pcam mean 0.099 0.311 0.926
#> pcam weighted 0.053 0.188 0.971
#> median mean 0.082 0.259 0.938
#> median weighted 0.057 0.240 0.969
#> mean weighted 0.055 0.200 0.957
#>
#> PCAm members: Maxent_LQ, Maxent_H_rm4, GLM, RandomForest
#>
#> mean_abs_diff = mean absolute difference of the two ensembles over the
#> sampled cells. Grades of the largest one (below 0.02 negligible, below 0.05
#> small) are preENM defaults for the 0-1 scale, not from the literature.
#>
#> A preENM sensitivity analysis: how much the result depends on how the
#> ensemble is built. The others are listed in ?sensitivity_analyses.
plot_ensemble_scenarios(es)
