Compares the number of records with commonly cited minimum numbers, after filtering and thinning:
Usage
check_sample_size(
points,
env = NULL,
n_predictors = NULL,
k = NULL,
per_predictor = 10,
per_fold = 5,
coords = NULL,
points_crs = "EPSG:4326"
)Arguments
- points
Records (data.frame, CSV path,
sfor terra::SpatVector), or their number.- env
Optional predictor rasters you will model with.
- n_predictors
Number of predictors (default: the layers of
env).- k
Optional number of cross-validation folds.
- per_predictor, per_fold
Records required per predictor and per fold.
- coords, points_crs
Coordinate columns and their CRS.
Details
at least 14 records for narrow-ranged and 25 for widespread species, the minimum numbers found by van Proosdij et al. (2016) for real landscapes (fewer records gave models no better than chance);
at least
per_predictor(default 10) records per predictor, so that responses can be estimated without overfitting;with
kfolds, at leastper_fold(default 5) records in a fold on average, or the metrics of the folds are too noisy.
With env, the records are counted as occupied cells (several records
in a cell add no information to a model fitted on that grid) and the
share of the valid cells that is occupied is reported as a lower bound
of the prevalence.
Limits. The minimum numbers of van Proosdij et al. (2016) come from simulations with particular landscapes and algorithms; the numbers per predictor and per fold are common conventions. Passing them does not guarantee a good model, and failing them does not make one useless.
References
van Proosdij, A.S.J., Sosef, M.S.M., Wieringa, J.J., Raes, N. (2016) Minimum required number of specimen records to develop accurate species distribution models. Ecography 39, 542-552.
Examples
sim <- simulate_enm_data(seed = 1, n_presence = 40)
check_sample_size(sim$presence, sim$env, k = 5)
#> check value required
#> 1 number of occupied cells with values 40.00000 14
#> 2 share of the cells occupied (lower bound of prevalence) 0.00833 NA
#> 3 records per predictor (2) 20.00000 10
#> 4 records per fold (k = 5) 8.00000 5
#> ok note
#> 1 TRUE enough also for a widespread species
#> 2 NA the more widespread a species, the more records it needs
#> 3 TRUE
#> 4 TRUE
check_sample_size(18, n_predictors = 6)
#> check value required ok
#> 1 number of records 18 14 TRUE
#> 2 records per predictor (6) 3 10 FALSE
#> note
#> 1 enough only for a narrow-ranged species
#> 2 use at most 1 predictors, or simpler models
