
How much does the evaluation depend on the cross-validation design?
Source:R/cv_designs.R
cv_sensitivity.RdRandom folds, spatial blocks (and where their boundaries fall), buffered
blocks, environmental folds, held-out groups and held-out periods answer
different questions: interpolation, transfer in space, transfer to new
conditions, transfer between units or forward in time. Random
cross-validation can greatly overestimate performance when the data are
spatially structured (Roberts et al. 2017). cv_sensitivity() takes the
evaluate_cv() results of the same models under several designs and
reports how much the metrics and the ranking of the models change.
Arguments
- ...
Named
evaluate_cv()results, one per design (e.g.random = cv1, blocks = cv2, buffered = cv3), or one named list of them.- metric
Metric compared.
- higher_better
Is a higher value of
metricbetter?
Value
An object of class cv_sensitivity: table (one row per model
and design: the metric and the model's rank), by_model (range of the
metric over designs), rank_agreement (Spearman correlations of the
rankings between designs) and settings.
Details
Status and limits. A preENM comparison of established designs. The designs must be applied to the same models and data. The grades (a ranking is stable when the rank correlations between designs are all at least 0.8; a metric changes noticeably when its range over designs exceeds 0.05) are preENM defaults, not from the literature. What to vary. The designs themselves: include at least the random and the design closest to the intended use.
References
Roberts, D.R., Bahn, V., Ciuti, S., et al. (2017) Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure. Ecography 40, 913-929. doi:10.1111/ecog.02881
Examples
mk <- function(auc) structure(data.frame(model = c("A", "B", "C"),
AUC = auc), class = c("enm_cv",
"data.frame"))
cs <- cv_sensitivity(random = mk(c(0.92, 0.90, 0.85)),
blocks = mk(c(0.80, 0.83, 0.74)))
cs
#> Cross-validation designs compared: random, blocks; 3 model(s), AUC
#>
#> IN SHORT
#> - The mean AUC is random 0.890, blocks 0.790; it changes by up to 0.120 for
#> one model across designs (noticeably).
#> - The best model depends on the design: random A; blocks B. Choose the
#> design that matches how the model will be used (interpolation, transfer
#> in space or time).
#> - Rankings differ between designs (lowest rank correlation 0.50).
#>
#> model random blocks
#> A 0.92 0.80
#> B 0.90 0.83
#> C 0.85 0.74
#>
#> Rankings agree when every rank correlation between designs is at least 0.8;
#> a change above 0.05 is noticeable. preENM defaults, not from the
#> literature.
#>
#> A preENM sensitivity analysis: how much the result depends on the
#> cross-validation design. The others are listed in ?sensitivity_analyses.
plot_cv_sensitivity(cs)