
Random variables with the values and the spatial structure of real ones
Source:R/relevance.R
random_variables.RdMakes layers that mean nothing to the species, to be modelled together
with the real predictors in any software: a real predictor that gets no
more importance than these is not informative (see
compare_to_random()). Each random layer takes the values of one real
layer, so it has exactly the same distribution of values (range, mean,
skewness, ties) and the same cells without values, and arranges them
anew:
Usage
random_variables(
env,
n = 5,
method = c("field", "shuffle"),
layers = NULL,
range_km = NULL,
seed = NULL,
filename = "",
overwrite = FALSE
)Arguments
- env
Predictor layers (terra::SpatRaster or file paths).
- n
Number of random layers. They are made from the real layers in turn (the first from the first layer, and so on, starting again after the last), or from those named in
layers.- method
"field"or"shuffle".- layers
Optional names of the real layers to imitate.
- range_km
With
method = "field": size of the patches (range of spatial autocorrelation, km).NULL= that of each imitated layer; one number = the same for all.- seed
Seed.
- filename
Optional output file.
- overwrite
Overwrite
filename.
Value
A terra::SpatRaster with layers named random_1, random_2,
...; attr(, "source") says which real layer each one imitates.
Details
"field"(default): in smooth patches with the same range of spatial autocorrelation as the real layer (estimated as insuggest_block_size()). This is the fair comparison: real layers are smooth and records are clustered, so a smooth layer gains importance by chance far more easily than noise does."shuffle": cell by cell at random (white noise), the classic random variable. A real predictor will almost always beat it; use it only to compare with earlier work.
Limits. The field method reproduces the range of spatial autocorrelation estimated from a variogram, not the whole spatial structure: anisotropy and broad gradients of the real layers are not copied.
References
Fourcade, Y., Besnard, A.G., Secondi, J. (2018) Paintings predict the distribution of species, or the challenge of selecting environmental predictors and evaluation statistics. Global Ecology and Biogeography 27, 245-256. doi:10.1111/geb.12684
