Skip to contents

preENM offers several corrections of sampling bias (thinning in geographic or environmental space, one record per cell, and backgrounds weighted by environment, effort or a target group), and the literature gives no rule for choosing among them: there is no optimal spatial filtering distance (Lamboley & Fourcade 2024), thinning often does no better than removing the same number of records at random (Ten Caten & Dallas 2023), the best correction depends on the structure of the bias and can even make predictions worse for narrow niches (Inman et al. 2021), and without independent test data the effect of a correction on model performance cannot be judged reliably; results with and without correction should be presented (Baker et al. 2024).

Usage

bias_sensitivity(
  records,
  env,
  thin = c("none", "cell", "distance", "environment"),
  thin_km = c(5, 10, 25, 50),
  env_mult = c(1, 2),
  background = list(uniform = list()),
  bg_n = c(1000, 10000),
  ref_n = 1e+05,
  total_bins = 1000,
  n_null = 10,
  intact_limit = 0.95,
  env_thin_args = list(),
  coords = NULL,
  points_crs = "EPSG:4326",
  seed = 1,
  verbose = TRUE
)

Arguments

records

Presence records: a data.frame with coordinates, a CSV path, sf or terra::SpatVector.

env

Predictor layers clipped to M (terra::SpatRaster or files).

thin

Thinning methods: "none" (the uncorrected records), "cell" (one per raster cell, thin_by_cell()), "distance" (spatial filtering: no two records closer than each of thin_km, as in thin_distance() and spThin, Aiello-Lammens et al. 2015) and "environment" (thin_environment() on the cell-thinned records, at each of env_mult).

thin_km

Filtering distances (km) for "distance".

env_mult

Bin-width multipliers for "environment" (its width_mult).

background

Named list of background strategies: each a list of arguments for sample_background(), e.g. list(uniform = list(), target = list(method = "target_group", target = tg)).

bg_n

Background sizes.

ref_n

Cells sampled from M for its environmental space.

total_bins

Approximate number of environmental bins.

n_null

Random subsets per thinning design for the null.

intact_limit

Limit of range_kept and niche_kept for an intact niche.

env_thin_args

Further arguments for thin_environment().

coords, points_crs

Coordinate columns and their CRS.

seed

Random seed.

verbose

Print progress.

Value

An object of class bias_sensitivity: designs (one row per thinning design and background: the measures above), thinning (one row per thinning design), backgrounds (one row per background), effects (how much each choice changes each measure), records (the kept records of each thinning design) and settings. See plot_bias_sensitivity().

Details

bias_sensitivity() therefore makes a statement about the data, not about a model: it applies a grid of corrections and reports how each changes the design. It fits nothing and reports no predictive performance.

Records (each thinning design):

  • n, n_share: records kept, and their share of all records.

  • env_coverage: the share of the environmental bins of M (a PCA of ref_n cells of M, cut into about total_bins bins) that hold a record; niche_kept: the share of the bins occupied by all records that are still occupied.

  • null_coverage: the same coverage for random subsets of the same size (n_null draws), and coverage_gain = env_coverage - null_coverage: does the thinning keep more of the environment than losing the same number of records at random?

  • nn_km, clark_evans: mean nearest-neighbour distance and its ratio to the expectation for random points in M (Clark-Evans ratio; below 1 clustered, about 1 random, above 1 regular).

  • range_kept: the smallest share, over the layers, of the range of the records' values that the kept records still span; gap_max, n_truncated: the largest gap between the records and the limits of M and the number of truncated ends, as niche_truncation() reports them.

  • shift: 1 - Schoener's D between the environmental bins of the kept and of all records: 0 = the same distribution in environmental space, 1 = no overlap. How far the design moved from the uncorrected one.

  • niche_intact: range_kept and niche_kept both at least intact_limit (default 0.95; a preENM default, not from the literature).

Backgrounds (each strategy and size, drawn with sample_background()): bg_coverage (bins of M covered), bg_shift (1 - D against a uniform background of the same size: how far the strategy moves the background) and, for each combination with a thinning design, overlap (Schoener's D between the kept records and the background in environmental space: a corrected background that carries the records' sampling bias overlaps them more).

Status. A preENM method: it compares the data designs that bias corrections produce, not the models fitted to them.

References

Aiello-Lammens, M.E., Boria, R.A., Radosavljevic, A., Vilela, B., Anderson, R.P. (2015) spThin: an R package for spatial thinning of species occurrence records for use in ecological niche models. Ecography 38, 541-545. doi:10.1111/ecog.01132

Baker, D.J., Maclean, I.M.D., Gaston, K.J. (2024) Effective strategies for correcting spatial sampling bias in species distribution models without independent test data. Diversity and Distributions 30, e13802. doi:10.1111/ddi.13802

Inman, R., Franklin, J., Esque, T., Nussear, K. (2021) Comparing sample bias correction methods for species distribution modeling using virtual species. Ecosphere 12, e03422. doi:10.1002/ecs2.3422

Ten Caten, C., Dallas, T. (2023) Thinning occurrence points does not improve species distribution model performance. Ecosphere 14, e4703. doi:10.1002/ecs2.4703

Lamboley, Q., Fourcade, Y. (2024) No optimal spatial filtering distance for mitigating sampling bias in ecological niche models. Journal of Biogeography 51, 1783-1794. doi:10.1111/jbi.14854

Examples

# \donttest{
sim <- simulate_enm_data(seed = 1, n_presence = 300)
bs <- bias_sensitivity(sim$presence, sim$env, thin_km = c(10, 30),
                       env_mult = 1, bg_n = 1000, n_null = 3,
                       total_bins = 400, seed = 1, verbose = FALSE)
bs
#> Bias-correction sensitivity: 5 thinning design(s) x 1 background(s); 300 records
#> 
#> IN SHORT
#> - Uncorrected: 300 records covering 49% of the environmental bins of M
#>   (Clark-Evans ratio 0.95, near random).
#> - The choice that changes the design most is the thinning radius / width;
#>   the one that matters least, the thinning method (mean relative change
#>   over the measures: thinning radius / width 0.92, thinning method 0.54).
#> - Leave the niche intact (range and occupied bins kept at least 95%): cell,
#>   distance_10km, environment_x1. Cut the niche: distance_30km (range 98%,
#>   bins 72%).
#> - Removed no record: cell (the records are already one per cell).
#> - Against random removal of the same number of records: more environment
#>   kept by distance_10km, distance_30km, environment_x1.
#> - This describes the data, not model performance: no correction can be
#>   recommended from first principles (no optimal filtering distance,
#>   Lamboley & Fourcade 2024; thinning often no better than random removal,
#>   Ten Caten & Dallas 2023; the best correction depends on the bias, Inman
#>   et al. 2021). Without independent test data, fit models with and without
#>   correction and report both (Baker et al. 2024).
#> 
#> Thinning designs:
#>        thinning   n env_coverage niche_kept coverage_gain clark_evans
#>            none 300         0.49       1.00          0.00        0.95
#>            cell 300         0.49       1.00          0.00        0.95
#>   distance_10km 280         0.48       0.99          0.02        1.01
#>   distance_30km 145         0.35       0.72          0.06        1.31
#>  environment_x1 273         0.48       0.99          0.03        1.00
#>  range_kept gap_max n_truncated shift niche_intact
#>        1.00    0.09           0  0.00         TRUE
#>        1.00    0.09           0  0.00         TRUE
#>        1.00    0.09           0  0.06         TRUE
#>        0.98    0.09           0  0.31        FALSE
#>        1.00    0.09           0  0.08         TRUE
#> 
#> Backgrounds:
#>     background bg_method bg_n bg_drawn bg_coverage bg_shift
#>  uniform_n1000   uniform 1000     1000        0.92        0
#> 
#> env_coverage = share of the 400 environmental bins of M holding a record;
#> niche_kept = share of the bins of all records still occupied; coverage_gain
#> = env_coverage minus that of random subsets of the same size (3 draws);
#> clark_evans = mean nearest-neighbour distance / its expectation for random
#> points in M (below 1 clustered); range_kept = smallest share of a layer's
#> range still spanned; gap_max, n_truncated as in niche_truncation(); shift =
#> 1 - Schoener's D between kept and all records in environmental space;
#> bg_shift = 1 - D between the background and a uniform one of the same size;
#> overlap (in x$designs) = D between kept records and background. The limits
#> (0.95 for an intact niche, 0.01 for a gain, 0.1 for a choice that barely
#> matters) are preENM defaults, not from the literature.
#> 
#> A preENM sensitivity analysis: how much the result depends on the thinning
#> and background design. The others are listed in ?sensitivity_analyses.
plot_bias_sensitivity(bs)

# }