Skip to contents

niche_truncation() tells whether the records crowd against the limits of M; truncation_remedy() says what to do about it, using predictor layers that extend beyond M. A model can only learn the part of a response that its calibration data contain, and models transferred to other regions or times lose accuracy with distance and extrapolation (Rousseau & Betts 2022), with niche change (Liu et al. 2022), and for invasive species in their new ranges (Nguyen & Leung 2022). Two remedies use data from beyond the region: integrating data from other regions (Chevalier et al. 2021) and spatially nested hierarchical models, in which a model of the whole range informs the regional one (Goicolea et al. 2025). This function proposes and prepares; it fits nothing.

Usage

truncation_remedy(
  trunc,
  records,
  env,
  m,
  parent_records = NULL,
  tail = 0.25,
  tail_bins = 4,
  min_cells = 5,
  max_increase = 3,
  max_gap_km = NULL,
  donor_km = 100,
  parent_fact = 4,
  n = 2e+05,
  coords = NULL,
  points_crs = "EPSG:4326",
  seed = 1
)

Arguments

trunc

A niche_truncation object from niche_truncation().

records

The records (as given to niche_truncation()).

env

Predictor layers covering a region larger than M (same layer names), e.g. the continent; terra::SpatRaster or files.

m

The calibration area: an m_area from delimit_m() or polygons.

parent_records

Optional records of the whole range (e.g. GBIF), for the parent dataset.

tail

Width of the missing band, as a share of M's range.

tail_bins, min_cells

Parts of the band that must each have min_cells sampled cells in the proposed extent.

max_increase

Largest area of the proposed extent, as a multiple of M's, for the extension to be advised.

max_gap_km

Largest distance between M and the nearest cell of the missing conditions for them to count as adjacent (default: a tenth of the radius of a circle with M's area).

donor_km

Distance linking cells into one donor region.

parent_fact

Aggregation factor suggested for the parent's layers.

n

Random cells sampled from env.

coords, points_crs

Coordinate columns and their CRS.

seed

Random seed.

Value

An object of class truncation_remedy: remedy (the main remedy: "none", "extend", "donors" or "accept"), ends (one row per truncated end: the band, its cells in env, whether the extension covers it, and the remedy for that end), extension (distance, area, increase, the extent as sfc), donors (one row per region) and donor_cells (sf points), nested (parent and child datasets) and settings. See plot_truncation_remedy().

Details

  1. The missing tail. For each truncated end (from trunc), the conditions just beyond M's limit: a band of tail times M's range on that variable, with the other variables within the range of the records (so that the conditions are a plausible extension of the niche, not any cell beyond the limit).

  2. Extension. Cells in that band are sampled from env (n random cells). The extension reaches the smallest distance from M at which each of tail_bins parts of every band has at least min_cells sampled cells; the proposed extent is the convex hull of M and the band cells within that distance (so M grows only towards the missing conditions), within the area of env. The report gives the distance and how many times larger the extent is than M.

  3. Donor regions. Cells of the bands outside the proposed extent, or all of them when no extension covers the bands, are grouped into regions (cells within donor_km of each other), with their size, distance from M and the ends they supply: places to look for records of the species.

  4. Advice, per truncated end. Extend the extent when the missing conditions are adjacent: the band begins within max_gap_km of M (default a tenth of the radius of a circle of M's area) and the extension covering it is at most max_increase times M's area; otherwise integrate the donor regions; when the conditions occur nowhere in env (e.g. only in a future climate), accept the truncation and state it. The main remedy is "donors" if any end needs them, else "extend", else "accept".

  5. Nested design. nested holds a parent (whole range: the records of parent_records, or of records when that is all there is, within the extended extent and the donor regions, to be modelled at a coarser resolution, parent_fact cells aggregated, with climatic variables) and a child (the records in M at full resolution, with all predictors). Fit the parent model first, project it onto the child's grid, and either use the projection as a covariate of the child model ("covariate" strategy) or combine the two predictions by their geometric mean ("multiply"); the covariate strategy was the more accurate of the two (Goicolea et al. 2025). write_truncation_remedy() writes both datasets and the extents.

With records of the whole range, niche_coverage() measures how much of the niche the region misses (unfilling) and whether a nested model is worth it; this function answers where the missing conditions are and prepares the data.

When a nested model can mislead. Extending M, donor regions and nested models all assume that records from elsewhere show conditions the regional populations could occupy. With local adaptation, ecotypes, different ploidy levels or long isolation, a limit of the regional records can be real, and these remedies remove it. Where such differentiation is likely, compare the regional and the whole-range model against independent regional records before relying on either.

What to vary. tail (the width of the missing band), max_increase and max_gap_km, which decide between extending M and using donors: the advice should hold across sensible values.

References

Chevalier, M., Broennimann, O., Cornuault, J., Guisan, A. (2021) Data integration methods to account for spatial niche truncation effects in regional projections of species distribution. Ecological Applications 31, e02427. doi:10.1002/eap.2427

Goicolea, T., Adde, A., Broennimann, O., Garcia-Vinas, J.I., Gaston, A., Aroca-Fernandez, M.J., Guisan, A., Mateo, R.G. (2025) Spatially-nested hierarchical species distribution models to overcome niche truncation in national-scale studies. Ecography 2025, e07328. doi:10.1111/ecog.07328

Rousseau, J.S., Betts, M.G. (2022) Factors influencing transferability in species distribution models. Ecography 2022, e06060. doi:10.1111/ecog.06060

Liu, C., Wolter, C., Courchamp, F., Roura-Pascual, N., Jeschke, J.M. (2022) Biological invasions reveal how niche change affects the transferability of species distribution models. Ecology 103, e3719. doi:10.1002/ecy.3719

Nguyen, D., Leung, B. (2022) How well do species distribution models predict occurrences in exotic ranges? Global Ecology and Biogeography 31, 1051-1065. doi:10.1111/geb.13482

Examples

# \donttest{
# a west-east temperature gradient; the species lives at 6-14 degrees
r <- terra::rast(nrows = 30, ncols = 100, xmin = 0, xmax = 20,
                 ymin = 45, ymax = 51, crs = "EPSG:4326")
xy <- terra::crds(r, na.rm = FALSE)
set.seed(1)
env <- c(terra::rast(r, vals = xy[, 1] + rnorm(nrow(xy), 0, 0.1)),
         terra::rast(r, vals = xy[, 2]))
names(env) <- c("temp", "north")
pres <- data.frame(lon = runif(150, 6, 10), lat = runif(150, 46, 50))
# a calibration area that ends at 10 degrees east
m <- sf::st_sfc(sf::st_polygon(list(rbind(c(2, 45), c(10, 45), c(10, 51),
                                          c(2, 51), c(2, 45)))),
                crs = 4326)
tr <- niche_truncation(pres, crop_to_m(env, m))
rem <- truncation_remedy(tr, pres, env, m)
rem
#> Remedy for a truncated niche: 1 truncated end(s)
#> 
#> IN SHORT
#> - Truncated: temp (high end).
#> - Extend the calibration area for temp (high): the missing conditions lie
#>   next to M. Extending M by up to 124 km towards them covers the band of
#>   25% of M's range beyond this end, at 1.2 times the area of M (462 816
#>   km2).
#> - With records of the whole range, niche_coverage() measures how much of
#>   the niche the region misses.
#> 
#>  layer  end band_lo band_hi cells gap_km covered remedy
#>   temp high    10.1    12.1   207   7.28    TRUE extend
#> 
#> band = conditions within 25% of M's range beyond the truncated end, with
#> the other variables in the records' range; cells = sampled cells of the
#> layers in the band outside M; covered = every one of 4 parts of the band
#> has 5 cells within the extension; gap_km = distance from M to the nearest
#> cell of the band. The limits (3 times M's area, a gap of 36 km) are preENM
#> defaults, not from the literature. Nested design (x$nested): fit the parent
#> on the whole-range records at a coarser resolution, project it to the
#> child's grid, and use it as a covariate of the child model (or combine the
#> two predictions by their geometric mean). Extending M, donors and nested
#> models assume that records from elsewhere show conditions the regional
#> populations could occupy; with local adaptation, ecotypes or different
#> ploidy levels a regional limit can be real.
plot_truncation_remedy(rem)

# }