Skip to contents

The alternative to thinning that discards nothing: every record is kept and weighted by the inverse of the number of records around it, so a cluster of densely recorded records counts about as much as one record would after thinning, while isolated records keep their full weight. Most modelling software accepts case weights for presences (e.g. the weights of a GLM, GAM or boosted tree); a weighted presence sample corrects for uneven recording in the same direction as thinning or a bunched background (sample_background() with "thickening"), which is useful when a sample is too small to thin (Vollering et al. 2019).

Usage

record_weights(
  points,
  dist_km,
  kernel = c("uniform", "gaussian"),
  coords = NULL,
  points_crs = "EPSG:4326"
)

Arguments

points

Records: a data.frame with coordinates, an sf object or a terra::SpatVector.

dist_km

Distance (km) within which records count as neighbours (uniform kernel) or the bandwidth (Gaussian kernel).

kernel

"uniform" or "gaussian".

coords, points_crs

Coordinate columns and their CRS when points is a table.

Value

An object of class record_weights: data (the records with density, the number of records around each, and weight), summary (records, effective sample size, the range of the weights) and settings.

Details

With kernel = "uniform" (default) the density of a record is the number of records within dist_km (itself included), so a cluster of k records within the distance shares a total weight of about 1, as thin_distance() at the same distance would keep about one. With "gaussian", neighbours count by exp(-d^2 / (2 dist_km^2)) (within three times the distance). Weights are scaled to a mean of 1; the effective sample size (Kish 1965), sum(w)^2 / sum(w^2), says how many equally weighted records they are worth.

Status, assumptions and limits. A preENM helper: weighting by inverse sampling density is a common idea, but there is no standard implementation to follow, and whether reducing the influence of dense records improves models is debated (Ten Caten & Dallas 2023). The weights assume that local density reflects recording, not abundance or habitat: a species that is truly aggregated loses weight in its strongholds. They do not change the background; with a bias-corrected background as well, the correction is applied twice.

What to vary. dist_km (as for thin_distance()), kernel, and compare models fitted with and without the weights.

References

Kish, L. (1965) Survey Sampling. Wiley, New York.

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

Vollering, J., Halvorsen, R., Auestad, I., Rydgren, K. (2019) Bunching up the background betters bias in species distribution models. Ecography 42, 1717-1727. doi:10.1111/ecog.04503

Examples

sim <- simulate_enm_data(seed = 1, n_presence = 150)
rw <- record_weights(sim$presence, dist_km = 20)
rw
#> Record weights by inverse local density (uniform kernel, 20 km)
#> 
#> IN SHORT
#> - All 150 records are kept; weighted, they are worth about 134 equally
#>   weighted records (effective sample size).
#> - Weights range from 0.31 (records in dense clusters) to 1.25 (isolated
#>   records); mean 1.
#> - At this distance, thinning would keep about 120 records; weighting keeps
#>   all of them with the same total influence.
#> 
#> Weights are 1 / (records within the distance), scaled to a mean of 1. Pass them
#> as case weights of the presences in your modelling software.
head(rw$data$weight)
#> [1] 1.2543554 0.6271777 1.2543554 1.2543554 1.2543554 0.6271777