This internal biomod2 function allows to select pseudo-absences according
to 4 different methods : random, sre, disk or user.defined (see Details).
bm_PseudoAbsences(
resp.var,
expl.var,
nb.rep = 1,
strategy = "random",
nb.absences = NULL,
sre.quant = 0,
dist.min = 0,
dist.max = NULL,
fact.aggr = NULL,
user.table = NULL,
seed.val = NULL
)
bm_PseudoAbsences_user.defined(resp.var, expl.var, ...)
# S4 method for class 'ANY,SpatVector'
bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table)
# S4 method for class 'ANY,SpatRaster'
bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table)
bm_PseudoAbsences_random(resp.var, expl.var, ...)
# S4 method for class 'ANY,SpatVector'
bm_PseudoAbsences_random(resp.var, expl.var, nb.absences, nb.rep, fact.aggr)
# S4 method for class 'ANY,SpatRaster'
bm_PseudoAbsences_random(resp.var, expl.var, nb.absences, nb.rep, fact.aggr)
bm_PseudoAbsences_sre(resp.var, expl.var, ...)
# S4 method for class 'ANY,SpatVector'
bm_PseudoAbsences_sre(resp.var, expl.var, sre.quant, nb.absences, nb.rep)
# S4 method for class 'ANY,SpatRaster'
bm_PseudoAbsences_sre(resp.var, expl.var, sre.quant, nb.absences, nb.rep)
bm_PseudoAbsences_disk(resp.var, expl.var, ...)
# S4 method for class 'ANY,SpatVector'
bm_PseudoAbsences_disk(
resp.var,
expl.var,
dist.min,
dist.max,
nb.absences,
nb.rep,
fact.aggr
)
# S4 method for class 'ANY,SpatRaster'
bm_PseudoAbsences_disk(
resp.var,
expl.var,
dist.min,
dist.max,
nb.absences,
nb.rep,
fact.aggr
)a vector, SpatialPoints or
SpatialPointsDataFrame object containing binary data (0 : absence,
1 : presence, NA : indeterminate) for a single species that will be used to
find the pseudo-absences
a matrix, data.frame, SpatialPointsDataFrame
or SpatRaster object containing the explanatory variables (in
columns or layers) that will be used to find the pseudo-absences
an integer corresponding to the number of sets (repetitions) of
pseudo-absence points that will be drawn
a character corresponding to the pseudo-absence selection strategy,
must be among random, sre, disk or user.defined
(optional, default NULL)
If strategy = 'random' or strategy = 'sre' or strategy = 'disk', an
integer corresponding to the number of pseudo-absence points that will be selected for
each pseudo-absence repetition (true absences included).
It can also be a vector of the same length as nb.rep containing integer
values corresponding to the different numbers of pseudo-absences to be selected (see Details)
(optional, default 0)
If strategy = 'sre', a numeric between 0 and 0.5 defining the
half-quantile used to make the sre pseudo-absence selection (see bm_SRE)
(optional, default 0)
If strategy = 'disk', a numeric defining the minimal distance to presence points
used to make the disk pseudo-absence selection (in the same projection system units as
expl.var)
(optional, default NULL)
If strategy = 'disk', a numeric defining the maximal distance to presence points
used to make the disk pseudo-absence selection (in the same projection system units as
expl.var)
(optional, default NULL)
If strategy = 'random' or strategy = 'disk', an integer defining the
factor of aggregation to reduce the spatial resolution of the environmental variables
(optional, default NULL)
If strategy = 'user.defined', a matrix or data.frame with as many rows as
resp.var values, as many columns as nb.rep, and containing TRUE or
FALSE values defining which points will be used to build the species distribution
model(s) for each repetition
(optional, default NULL)
An integer value corresponding to the new seed value to be set
(optional, one or several of the listed above arguments depending on the selected method)
A list containing the following elements :
xy : the coordinates of the species observations
sp : the values of the species observations (0, 1 or NA)
env : the explanatory variables
pa.tab : the corresponding table of selected pseudo-absences (indicated by
TRUE or FALSE)
Concerning random selection :
The idea is to select pseudo-absences randomly in spatial locations where the species has not
been sampled. This method is the simplest one and the most appropriate if lacking information
about the presence sampling (non-exhaustive, biased sampling, etc).
Concerning SRE selection (see bm_SRE) :
The idea is to select pseudo-absences in spatial locations whose environmental conditions are
different from those of the presence points. This method is appropriate when most of the
environmental space of the species has been sampled.
Concerning disk selection :
The idea is to select pseudo-absences, not too close from presence points, but not too far
away either. This method is appropriate when most of the spatial range of the species has
been sampled.
Concerning user defined selection :
The user can provide pseudo-absences locations through a table containing spatial locations
in rows, pseudo-absences repetitions in columns, and TRUE/FALSE values indicating
whether each point is to be considered as pseudo-absence or not for each dataset.
Concerning multiple size selection :
It is possible to select create several pseudo-absence repetitions with different number of
points, BUT with the same sampling strategy. nb.absences must contain as many values
as the number of sets of pseudo-absences (nb.rep).
bm_SRE, BIOMOD.formated.data.PA,
BIOMOD_FormatingData
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
library(terra)
# Load species occurrences (6 species available)
data(DataSpecies)
head(DataSpecies)
# Select the name of the studied species
myRespName <- 'GuloGulo'
# Get corresponding presence/absence data
myResp <- as.numeric(DataSpecies[, myRespName])
# Get corresponding XY coordinates
myRespXY <- DataSpecies[, c('X_WGS84', 'Y_WGS84')]
# Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12)
data(bioclim_current)
myExpl <- terra::rast(bioclim_current)
DONTSHOW({
myExtent <- terra::ext(0,30,45,70)
myExpl <- terra::crop(myExpl, myExtent)
})
# --------------------------------------------------------------- #
# Create the different pseudo-absence datasets
# Transform true absences into potential pseudo-absences
myResp.PA <- ifelse(myResp == 1, 1, NA)
myResp.PA.vect <- vect(cbind(myRespXY, myResp.PA), geom = c("X_WGS84","Y_WGS84"))
# random method
PA.r <- bm_PseudoAbsences(resp.var = myResp.PA.vect,
expl.var = myExpl,
nb.rep = 4,
nb.absences = 1000,
strategy = 'random')
# disk method
PA.d <- bm_PseudoAbsences(resp.var = myResp.PA.vect,
expl.var = myExpl,
nb.rep = 4,
nb.absences = 500,
strategy = 'disk',
dist.min = 5,
dist.max = 35)
# SRE method
PA.s <- bm_PseudoAbsences(resp.var = myResp.PA.vect,
expl.var = myExpl,
nb.rep = 4,
nb.absences = 1000,
strategy = 'sre',
sre.quant = 0.025)
# user.defined method
myPAtable <- data.frame(PA1 = ifelse(myResp == 1, TRUE, FALSE),
PA2 = ifelse(myResp == 1, TRUE, FALSE))
for (i in 1:ncol(myPAtable)) myPAtable[sample(which(myPAtable[, i] == FALSE), 500), i] = TRUE
PA.u <- bm_PseudoAbsences(resp.var = myResp.PA.vect,
expl.var = myExpl,
strategy = 'user.defined',
user.table = myPAtable)
str(PA.r)
head(PA.r$pa.tab)
apply(PA.r$pa.tab, 2, table)
head(PA.d$pa.tab)
apply(PA.d$pa.tab, 2, table)
head(PA.s$pa.tab)
apply(PA.s$pa.tab, 2, table)
tail(PA.u$pa.tab)
apply(PA.u$pa.tab, 2, table)
# random method : different number of PA
PA.r_mult <- bm_PseudoAbsences(resp.var = myResp.PA.vect,
expl.var = myExpl,
nb.rep = 4,
nb.absences = c(1000, 500, 500, 200),
strategy = 'random')
str(PA.r_mult)
head(PA.r_mult$pa.tab)
apply(PA.r_mult$pa.tab, 2, table)