Skip to contents

sample_background() draws n = 10000 points by default, yet the number and the spatial spread of background points change presence-background models (Whitford et al. 2024), and the best number depends on the species and the study area (Rausell-Moreno et al. 2025). background_sufficiency() checks the part of the question that does not depend on the model: how many points are needed for the background to represent the environment available in the calibration area. It draws background at an increasing series of n, several times each, and measures:

Usage

background_sufficiency(
  raster,
  ns = c(250, 500, 1000, 2500, 5000, 10000, 25000, 50000),
  n_rep = 5,
  ref_n = 1e+05,
  total_bins = 1000,
  env_cumvar = 0.95,
  env_axes = NULL,
  tol = 0.01,
  n_presences = NULL,
  log_vars = NULL,
  seed = 1,
  ...
)

Arguments

raster

Predictor layers clipped to M (terra::SpatRaster or files), as for sample_background().

ns

Numbers of background points to try.

n_rep

Replicate draws per n (different seeds).

ref_n

Cells in the reference sample of M (all cells if fewer).

total_bins

Approximate number of environmental bins.

env_cumvar, env_axes

PCs used for the bins: those explaining env_cumvar of the variance (at most 3), or exactly env_axes.

tol

Tolerance of the saturation (coverage, 0-1).

n_presences

Optional number of presences, to report the ratio of background to presences.

log_vars

Layers log-transformed for the PCA (default: bioclim precipitation amounts).

seed

Random seed of the reference sample and the draws.

...

Further arguments for sample_background() (e.g. method, effort, target, exclude), so that the background you will use is the one assessed.

Value

An object of class background_sufficiency: draws (one row per n and replicate), summary (per n: mean and SD of the measures), recommended_n, saturated, reference (bins, PCs) and settings. See plot_background_sufficiency().

Details

  • Coverage of environmental space: the environment of M is a PCA of a large reference sample of its cells (ref_n), cut into about total_bins bins on the first PCs (as in sample_background()'s environmental methods). Coverage is the share of the occupied bins that hold at least one background point (coverage), and the share of the area of M in covered bins (coverage_area). Rare environments, in bins with few cells, are the last to be covered.

  • Stability of the marginal distributions: the largest Kolmogorov-Smirnov distance between the background and the reference values of any layer (ks_max). It falls roughly as one over the square root of n for a uniform background; for a biased (effort or target-group) background it levels off at the size of the bias.

Recommended n: the smallest n whose mean coverage is within tol (default 1 percentage point) of the coverage at the largest n tested. When coverage still rises by more than tol between the two largest n, the curve has not saturated within the range tested, and the printout says so.

This is about representing M, not about the accuracy of a particular model: in simulations, the best background was about 0.5-1 times the number of presences or about 5% of the cells of the area, depending on prevalence, and the number of background points mattered little for projections to future climates (Rausell-Moreno et al. 2025). Use the saturation point as a defensible lower bound for representing the environment, and test the models themselves if they are sensitive.

What it measures. How well a background of each size covers the environment of the area. It does not show that a model fitted with that number of points converges or gives stable estimates, which depends on the algorithm.

Status and what to vary. A preENM method. The answer depends on the environmental space (total_bins, env_cumvar) and on tol: a finer space needs more points before coverage saturates.

References

Whitford, A.M., Shipley, B.R., McGuire, J.L. (2024) The influence of the number and distribution of background points in presence-background species distribution models. Ecological Modelling 488, 110604. doi:10.1016/j.ecolmodel.2023.110604

Rausell-Moreno, A., Galiana, N., Naimi, B., Araujo, M.B. (2025) Improving species distribution models by optimising background points: impacts on current and future climate projections. Ecological Modelling 507, 111177. doi:10.1016/j.ecolmodel.2025.111177

Examples

sim <- simulate_enm_data(seed = 1)
bs <- background_sufficiency(sim$env, ns = c(100, 250, 500, 1000, 2500),
                             n_rep = 3, total_bins = 400, seed = 1)
bs
#> Background sufficiency (uniform background): n from 100 to 2 500, 3 draws each
#> 
#> IN SHORT
#> - Coverage has not saturated within the range tested: it still rises from
#>   93.4% to 100.0% between n = 1 000 and 2 500. Test larger n, or accept
#>   that the rarest environments (0 bins with at most 2 of the reference
#>   cells) stay partly uncovered.
#> - The marginal distributions differ from those of M by at most 0.009
#>   (Kolmogorov-Smirnov distance, worst layer) at that n, 0.009 at the
#>   largest.
#> - The number and spread of background points change model predictions in a
#>   species-dependent way (Whitford et al. 2024); test your models at the
#>   chosen n and at a larger one if the result matters. Coverage of the
#>   environment is not the same as a stable model fit, which depends on the
#>   algorithm.
#> 
#>     n coverage coverage_sd coverage_area ks_max ks_sd
#>   100    0.224       0.008         0.224  0.128 0.062
#>   250    0.486       0.014         0.486  0.060 0.025
#>   500    0.741       0.003         0.741  0.044 0.016
#>  1000    0.934       0.009         0.934  0.028 0.005
#>  2500    1.000       0.000         1.000  0.009 0.003
#> 
#> coverage = share of the environmental bins of M (PC1-PC2, 100% of the
#> variance, 20 bins per axis, from 4 800 reference cells) holding at least
#> one background point; coverage_area = share of the area of M in covered
#> bins; ks_max = largest Kolmogorov-Smirnov distance between background and
#> reference values of any layer; _sd over 3 draws. Saturation = within 0.01
#> of the coverage at the largest n: a preENM default, not from the
#> literature.
#> 
#> A preENM sensitivity analysis: how much the result depends on the number of
#> background points. The others are listed in ?sensitivity_analyses.
plot_background_sufficiency(bs)