
Random "occurrences" for null models, with the sampling bias of the records
Source:R/transfer_bias.R
null_occurrences.RdNull models of ecological niche models are fitted to points that carry no information about the species: locations drawn from the study area instead of the real records (Raes and ter Steege 2007). How the locations are drawn matters. Real records are concentrated where people collect, and models of uniformly random points are then too easy to beat: Warren et al. (2026) found false positive rates of 65-87% for tests of model fit when the records were collected with bias and the null points were not, and about the nominal 5% when the null points followed the same bias. This function draws the point sets, for any modelling software:
Usage
null_occurrences(
area,
points = NULL,
n = NULL,
method = c("uniform", "bias", "pattern"),
weight = NULL,
n_sets = 99,
coords = NULL,
points_crs = "EPSG:4326",
seed = 1
)Arguments
- area
The study area (the area the background is taken from): a terra::SpatRaster or file, of which the cells with a value in the first layer are used.
- points
The real records (data.frame, CSV path,
sforSpatVector). They give the number of points (records in distinct cells of the area) and, for"pattern", the pattern.- n
Number of points per set, instead of
points.- method
"uniform","bias"or"pattern", see above.- weight
Raster of relative recording effort, for
"bias".- n_sets
Number of point sets.
- coords, points_crs
Coordinate columns and CRS of
points.- seed
Seed.
Value
A list of n_sets data.frames with x and y (cell centres,
in the CRS of area; for "pattern" the moved coordinates), with
class null_occurrences and the attributes method and, for
"pattern", redrawn (mean share of points drawn again).
Details
"uniform": every cell of the area is equally likely (the original test)."bias": cells are drawn in proportion toweight, an estimate of recording effort, e.g. fromgbif_effort_rasters()(Warren et al. 2026). The recommended choice when such an estimate exists."pattern": the real point pattern is turned by a random angle and moved to a random place in the area, which keeps the clustering of the records exactly (Beale et al. 2008, Nunes and Pearson 2017). For when there is no estimate of effort. Points that land outside the area are drawn again at random (in proportion toweightwhen given); the mean share of such points is reported, and a high share means that the area is too small for this method. As Warren et al. (2026) point out, part of the clustering of real records is the species following a patchy environment, so this null is conservative.
Fit your models to each set exactly as to the real records (same area,
background, variables, settings), then give the predictions to
transfer_bias_test(), or their evaluation to your own comparison.
null_model_test() is the quick version for models that are already
fitted, without refitting.
Status, limits and what to vary. Implements the null points of Raes & ter Steege (2007) with the bias of the records, as recommended by Warren et al. (2026). The bias null is only as good as the effort estimate: vary the number of sets and the effort surface (e.g. raw against smoothed effort).
References
Raes, N., ter Steege, H. (2007) A null-model for significance testing of presence-only species distribution models. Ecography 30, 727-736.
Warren, D.L., Casadei-Ferreira, A., Economo, E.P., Dinnage, R., Kass, J.M. (2026) Incorporating sampling bias into ENM/SDM permutation tests: new methods and a case study on neotropical ants. Ecography 2026, e08559. doi:10.1002/ecog.08559
Beale, C.M., Lennon, J.J., Gimona, A. (2008) Opening the climate envelope reveals no macroscale associations with climate in European birds. PNAS 105, 14908-14912.
Nunes, L.A., Pearson, R.G. (2017) A null biogeographical test for assessing ecological niche evolution. Journal of Biogeography 44, 1331-1343.
Examples
sim <- simulate_enm_data(seed = 1)
effort <- sim$env[[1]] # more recording towards the east
sets <- null_occurrences(sim$env, sim$presence, method = "bias",
weight = effort, n_sets = 5)
head(sets[[1]])
#> x y
#> 1 22.6875 52.75
#> 2 23.5625 49.05
#> 3 20.1875 49.05
#> 4 22.0625 54.05
#> 5 22.3125 52.15
#> 6 19.6875 52.05
# write.csv(sets[[1]], "null_001.csv", row.names = FALSE)