generateRandomSp {virtualspecies} | R Documentation |
Generate a random virtual species distribution from environmental variables
Description
This function generates randomly a virtual species distribution.
Usage
generateRandomSp(
raster.stack,
approach = "automatic",
rescale = TRUE,
convert.to.PA = TRUE,
relations = c("gaussian", "linear", "logistic", "quadratic"),
rescale.each.response = TRUE,
realistic.sp = TRUE,
species.type = "multiplicative",
niche.breadth = "any",
sample.points = FALSE,
nb.points = 10000,
PA.method = "probability",
alpha = -0.1,
adjust.alpha = TRUE,
beta = "random",
species.prevalence = NULL,
plot = TRUE
)
Arguments
raster.stack |
a SpatRaster object, in which each layer represent an environmental variable. |
approach |
|
rescale |
|
convert.to.PA |
|
relations |
[response approach] a vector containing the possible types
of response function.
The implemented type of relations are |
rescale.each.response |
|
realistic.sp |
[response approach] |
species.type |
[response approach] |
niche.breadth |
[pca approach] |
sample.points |
[pca approach] |
nb.points |
[pca approach] a numeric value. Only useful if
|
PA.method |
|
alpha |
|
adjust.alpha |
|
beta |
|
species.prevalence |
|
plot |
|
Details
Online tutorial for this function
This function generate random virtual species, either using a PCA approach, or using a response approach. In case of a response approach, only four response functions are currently used: gaussian, linear, logistic and quadratic functions.
Note that in case of numerous predictor variables, the "response" approach will not work well because it will often generate contradicting response functions (e.g., mean annual temperature optimum at degrees C and temperature of the coldest month at 10 degrees C). In these case, it is advised to use the PCA approach (by default, a PCA approach will be used if there are more than 6 predictor variables).
If rescale.each.response = TRUE
, then the probability response to each
variable will be normalised between 0 and 1 according to the following
formula:
P.rescaled = (P - min(P)) / (max(P) - min (P)). Similarly, if
rescale = TRUE
,
the final environmental suitability will be rescaled between 0 and 1
with the same formula.
By default, the function will perform a probabilistic conversion into presence- absence, with a randomly chosen beta threshold. If you want to customise the conversion parameters, you have to define two of the three following parameters:
beta
: the 'threshold' of the logistic function (i.e. the inflexion point)alpha
: the slope of the logistic functionspecies.prevalence
: the proportion of sites in which the species occur
If you provide beta
and alpha
, the species.prevalence
is calculated immediately calculated after conversion into presence-absence.
As explained in convertToPA
, if you choose choose a precise
species.prevalence
, it may not be possible to reach this particular
value because of the availability of environmental conditions. Several
runs may be necessary to reach the desired species.prevalence
.
Value
a list
with 3 to 5 elements (depending if the conversion
to presence-absence was performed):
approach
: the approach used to generate the species, i.e.,"response"
details
: the details and parameters used to generate the speciessuitab.raster
: the virtual species distribution, as a SpatRaster object containing the environmental suitability)PA.conversion
: the parameters used to convert the suitability into presence-absencepa.raster
: the presence-absence map, as a SpatRaster object containing 0 (absence) / 1 (presence) / NA
The structure of the virtualspecies can object be seen using str()
Author(s)
Boris Leroy leroy.boris@gmail.com
with help from C. N. Meynard, C. Bellard & F. Courchamp
Examples
# Create an example stack with six environmental variables
a <- matrix(rep(dnorm(1:100, 50, sd = 25)),
nrow = 100, ncol = 100, byrow = TRUE)
env <- c(rast(a * dnorm(1:100, 50, sd = 25)),
rast(a * 1:100),
rast(a * logisticFun(1:100, alpha = 10, beta = 70)),
rast(t(a)),
rast(exp(a)),
rast(log(a)))
names(env) <- paste("Var", 1:6, sep = "")
# More than 6 variables: by default a PCA approach will be used
generateRandomSp(env)
# Manually choosing a response approach: this may fail because it is hard
# to find a realistic species with six distinct responses to six variables
generateRandomSp(env, approach = "response")
# Randomly choosing the approach
generateRandomSp(env, approach = "random")