| Title: | Ensemble Platform for Species Distribution Modeling |
|---|---|
| Description: | Functions for species distribution modeling, calibration and evaluation, ensemble of models, ensemble forecasting and visualization. The package permits to run consistently up to 10 single models on a presence/absences (resp presences/pseudo-absences) dataset and to combine them in ensemble models and ensemble projections. Some bench of other evaluation and visualisation tools are also available within the package. |
| Authors: | Maya Guéguen [aut, cre], Hélène Blancheteau [aut], Rémi Lemaire-Patin [aut], Wilfried Thuiller [aut] |
| Maintainer: | Maya Guéguen <[email protected]> |
| License: | GPL-3 |
| Version: | 4.3-4-7 |
| Built: | 2026-06-03 18:29:33 UTC |
| Source: | https://github.com/biomodhub/biomod2 |
A SpatRaster with 5 bioclimatic variables commonly
used for SDM and describing current climate. Additional information available
at worldclim.
bioclim_currentbioclim_current
A SpatRaster with 5 layers:
Isothermality
Temperature Seasonality
Temperature Annual Range
Mean Temperature of Coldest Quarter
Annual Precipitation
A SpatRaster with 5 bioclimatic variables commonly
used for SDM and describing future climate based on old RCP scenarios at the
horizon 2080.
bioclim_futurebioclim_future
A SpatRaster with 5 layers:
Isothermality
Temperature Seasonality
Temperature Annual Range
Mean Temperature of Coldest Quarter
Annual Precipitation
This function allows to project ensemble models built with the
BIOMOD_EnsembleModeling function onto new environmental data
(which can represent new areas, resolution or time scales for example).
BIOMOD_EnsembleForecasting( bm.em, bm.proj = NULL, proj.name = NULL, new.env = NULL, new.env.xy = NULL, models.chosen = "all", metric.binary = NULL, metric.filter = NULL, na.rm = TRUE, nb.cpu = 1, ... )BIOMOD_EnsembleForecasting( bm.em, bm.proj = NULL, proj.name = NULL, new.env = NULL, new.env.xy = NULL, models.chosen = "all", metric.binary = NULL, metric.filter = NULL, na.rm = TRUE, nb.cpu = 1, ... )
bm.em |
a |
bm.proj |
a |
proj.name |
(optional, default |
new.env |
(optional, default |
new.env.xy |
(optional, default |
models.chosen |
a |
metric.binary |
(optional, default |
metric.filter |
(optional, default |
na.rm |
(optional, default |
nb.cpu |
(optional, default |
... |
(optional, see Details) |
... can take the following values :
(optional, default 0) :
an integer value corresponding to the number of digits of the predictions
(optional, default TRUE) :
a logical value defining whether 0 - 1 probabilities are to be converted to
0 - 1000 scale to save memory on backup
(optional, default TRUE) :
a logical value defining whether all projections are to be kept loaded at once in
memory, or only links pointing to hard drive are to be returned
(optional, default TRUE) :
a logical value defining whether all projections are to be saved as one
SpatRaster object or several SpatRaster
files (the default if projections are too heavy to be all loaded at once in memory)
(optional, default .RData or .tif) :
a character value corresponding to the projections saving format on hard drive, must
be either .grd, .img, .tif or .RData (the default if
new.env is given as matrix or data.frame)
(optional, default TRUE) :
a logical or a character value defining whether and how objects should be
compressed when saved on hard drive. Must be either TRUE, FALSE, gzip
(for Windows OS) or xz (for other OS)
A BIOMOD.projection.out object containing models projections, or links to saved
outputs.
Models projections are stored out of R (for memory storage reasons) in
proj.name folder created in the current working directory :
the output is a data.frame if new.env is a matrix or a
data.frame
it is a SpatRaster if new.env is a
SpatRaster (or several SpatRaster
objects, if new.env is too large)
raw projections, as well as binary and filtered projections (if asked), are saved in
the proj.name folder
Wilfried Thuiller, Damien Georges, Robin Engler
BIOMOD_FormatingData, bm_ModelingOptions,
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
BIOMOD_RangeSize
Other Main functions:
BIOMOD_EnsembleModeling(),
BIOMOD_FormatingData(),
BIOMOD_LoadModels(),
BIOMOD_Modeling(),
BIOMOD_Projection(),
BIOMOD_RangeSize()
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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', build.clamping.mask = TRUE) } file.EM <- paste0(myRespName, "/", myRespName, ".AllModels.ensemble.models.out") if (file.exists(file.EM)) { myBiomodEM <- get(load(file.EM)) } else { # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # # Project ensemble models (from single projections) myBiomodEMProj <- BIOMOD_EnsembleForecasting(bm.em = myBiomodEM, bm.proj = myBiomodProj, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all') # Project ensemble models (building single projections) myBiomodEMProj <- BIOMOD_EnsembleForecasting(bm.em = myBiomodEM, proj.name = 'CurrentEM', new.env = myExpl, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all') myBiomodEMProj plot(myBiomodEMProj)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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', build.clamping.mask = TRUE) } file.EM <- paste0(myRespName, "/", myRespName, ".AllModels.ensemble.models.out") if (file.exists(file.EM)) { myBiomodEM <- get(load(file.EM)) } else { # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # # Project ensemble models (from single projections) myBiomodEMProj <- BIOMOD_EnsembleForecasting(bm.em = myBiomodEM, bm.proj = myBiomodProj, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all') # Project ensemble models (building single projections) myBiomodEMProj <- BIOMOD_EnsembleForecasting(bm.em = myBiomodEM, proj.name = 'CurrentEM', new.env = myExpl, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all') myBiomodEMProj plot(myBiomodEMProj)
This function allows to combine a range of models built with the
BIOMOD_Modeling function in one (or several) ensemble model. Modeling
uncertainty can be assessed as well as variables importance, ensemble predictions can be
evaluated against original data, and created ensemble models can be projected over new
conditions (see Details).
BIOMOD_EnsembleModeling( bm.mod, models.chosen = "all", em.by = "PA+run", em.algo, metric.select = "all", metric.select.thresh = NULL, metric.select.table = NULL, metric.select.dataset = NULL, metric.eval = c("KAPPA", "TSS", "AUCroc"), var.import = 0, EMci.alpha = 0.05, EMwmean.decay = "proportional", nb.cpu = 1, seed.val = NULL, do.progress = TRUE )BIOMOD_EnsembleModeling( bm.mod, models.chosen = "all", em.by = "PA+run", em.algo, metric.select = "all", metric.select.thresh = NULL, metric.select.table = NULL, metric.select.dataset = NULL, metric.eval = c("KAPPA", "TSS", "AUCroc"), var.import = 0, EMci.alpha = 0.05, EMwmean.decay = "proportional", nb.cpu = 1, seed.val = NULL, do.progress = TRUE )
bm.mod |
a |
models.chosen |
a |
em.by |
a |
em.algo |
a |
metric.select |
a |
metric.select.thresh |
(optional, default |
metric.select.table |
(optional, default |
metric.select.dataset |
(optional, default |
metric.eval |
a |
var.import |
(optional, default |
EMci.alpha |
(optional, default |
EMwmean.decay |
(optional, default |
nb.cpu |
(optional, default |
seed.val |
(optional, default |
do.progress |
(optional, default |
Concerning models sub-selection (models.chosen) :
Applying get_built_models function to the bm.mod object gives the names
of the single models created with the BIOMOD_Modeling function. The
models.chosen argument can take either a sub-selection of these single model names, or
the all default value, to decide which single models will be used for the ensemble
model building.
Concerning models assembly rules (em.by) :
Single models built with the BIOMOD_Modeling function can be combined in 5
different ways to obtain ensemble models :
each combination of pseudo-absence and repetition datasets is done, merging algorithms together
each combination of pseudo-absence and algorithm datasets is done, merging repetitions together
pseudo-absence datasets are considered individually, merging algorithms and repetitions together
algorithm datasets are considered individually, merging pseudo-absence and repetitions together
all single models are combined into one
Hence, depending on the chosen method, the number of ensemble models built will vary.
If no evaluation data was given to the BIOMOD_FormatingData function,
some ensemble model evaluations may be biased due to difference in data used for single
model evaluations.
Be aware that all of these combinations are allowed, but some may not make sense
depending mainly on how pseudo-absence datasets have been built and whether all of them
have been used for all single models or not (see PA.nb.absences and models.pa
parameters in BIOMOD_FormatingData and BIOMOD_Modeling functions
respectively).
Concerning evaluation metrics :
metric(s) must be chosen among the ones used within the
BIOMOD_Modeling function to build the bm.mod object, unless
metric.select = 'user.defined' and therefore values will be provided through the
metric.select.table parameter.
Each selected metric will be used at different steps of the ensemble modeling function to :
remove low quality single models having a score lower than
metric.select.thresh
perform the binary transformation if em.algo = 'EMca'
weight models if em.algo = 'EMwmean'
Note that metrics are not combined together, and one ensemble model is built for each metric provided.
if metric.select = 'user.defined', this parameter allows
to use evaluation metrics other than those calculated within biomod2. It must be a
data.frame containing as many columns as models.chosen with matching names,
and as many rows as evaluation metrics to be used. The number of rows must match the length
of metric.select.thresh, and values will be compared to those defined in
metric.select.thresh to remove low quality single models from the ensemble
model building.
by default, validation datasets will be used, unless no
validation is available (no cross-validation) in which case calibration datasets
will be used
Concerning ensemble algorithms :
6 modeling techniques are currently available :
median of probabilities over the selected models
Less sensitive to outliers than the mean
mean of probabilities over the selected models
weighted mean of probabilities over the selected models
Probabilities are weighted according to their model evaluation scores obtained when
building the bm.out object with the BIOMOD_Modeling function (better a
model is, more importance it has in the ensemble) and summed.
The EMwmean.decay is the ratio between a weight and the next or previous one.
The formula is : W = W(-1) * EMwmean.decay.
For example, with the value of 1.6 and 4 weights wanted, the relative
importance of the weights will be 1 / 1.6 / 2.56 (=1.6*1.6) / 4.096 (=2.56*1.6) from
the weakest to the strongest, and gives 0.11 / 0.17 / 0.275 / 0.445 considering that
the sum of the weights is equal to one. The lower the EMwmean.decay, the smoother
the differences between the weights enhancing a weak discrimination between models.
If EMwmean.decay = 'proportional', the weights are assigned to each model
proportionally to their evaluation scores. The discrimination is fairer than using the
decay method where close scores can have strongly diverging weights, while the
proportional method would assign them similar weights.
It is also possible to define the EMwmean.decay parameter as a function that will be
applied to single models scores and transform them into weights.
For example, if EMwmean.decay = function(x) {x^2}, the squared of evaluation
score of each model will be used to weight the models predictions.
committee averaging over the selected models
Probabilities are first transformed into binary data according to the threshold defined
when building the bm.out object with the BIOMOD_Modeling function
(maximizing the evaluation metric score over the calibration dataset). The committee
averaging score is obtained by taking the average of these binary predictions.
It is built on the analogy of a simple vote :
each single model votes for the species being either present (1) or absent
(0)
the sum of 1 is then divided by the number of single models voting
The interesting feature of this measure is that it gives both a prediction and a measure of
uncertainty. When the prediction is close to 0 or 1, it means that all models
agree to predict 0 or 1 respectively. When the prediction is around
0.5, it means that half the models predict 1 and the other half 0.
Note that this is for binary data only.
confidence interval around the mean of probabilities of the selected models
It creates 2 ensemble models :
LOWER : there is less than 100 * EMci.alpha / 2 % of chance to get
probabilities lower than the given ones
UPPER : there is less than 100 * EMci.alpha / 2 % of chance to get
probabilities upper than the given ones
These intervals are calculated with the following function :
coefficient of variation (sd / mean) of probabilities over the selected
models
This is the only ensemble model that might not be over the same scale than the others, as CV is a measure of uncertainty rather a measure of probability of occurrence. It will be evaluated like all other ensemble models although its interpretation will be obviously different. If the CV gets a high evaluation score, it means that the uncertainty is high where the species is observed (which might not be a good feature of the model). The lower is the score, the better are the models.
mode of the predictions over the selected models
For multiclass and ordinal data, EMmode will return the most frequent class found for each point. This is the only ensemble model that will return categorical data and not numeric values.
mode frequency of the predictions over the selected models
For multiclass and ordinal data, EMfreq will return the frequency of the mode found for each point. This is a way of assessing the uncertainty between models: the higher the frequency, the lower the uncertainty.
A BIOMOD.ensemble.models.out object containing models outputs, or links to saved
outputs.
Models outputs are stored out of R (for memory storage reasons) in 2 different
folders created in the current working directory :
a models folder, named after the resp.name argument of
BIOMOD_FormatingData, and containing all ensemble models
a hidden folder, named .BIOMOD_DATA, and containing outputs related
files (original dataset, calibration lines, pseudo-absences selected, predictions,
variables importance, evaluation values...), that can be retrieved with
get_[...]
or load functions, and used by other biomod2 functions, like
BIOMOD_EnsembleForecasting
Wilfried Thuiller, Damien Georges, Robin Engler
BIOMOD_FormatingData, bm_ModelingOptions,
bm_CrossValidation, bm_VariablesImportance,
BIOMOD_Modeling, BIOMOD_EnsembleForecasting,
bm_PlotEvalMean, bm_PlotEvalBoxplot,
bm_PlotVarImpBoxplot, bm_PlotResponseCurves
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_FormatingData(),
BIOMOD_LoadModels(),
BIOMOD_Modeling(),
BIOMOD_Projection(),
BIOMOD_RangeSize()
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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodEM # Get evaluation scores & variables importance get_evaluations(myBiomodEM) get_variables_importance(myBiomodEM) # Represent evaluation scores bm_PlotEvalMean(bm.out = myBiomodEM, dataset = 'calibration') bm_PlotEvalBoxplot(bm.out = myBiomodEM, group.by = c('algo', 'algo')) # # Represent variables importance # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('expl.var', 'algo', 'algo')) # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('expl.var', 'algo', 'merged.by.PA')) # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('algo', 'expl.var', 'merged.by.PA')) # # Represent response curves # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM), # fixed.var = 'median') # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM), # fixed.var = 'min') # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM, algo = 'EMmean'), # fixed.var = 'median', # do.bivariate = TRUE)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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodEM # Get evaluation scores & variables importance get_evaluations(myBiomodEM) get_variables_importance(myBiomodEM) # Represent evaluation scores bm_PlotEvalMean(bm.out = myBiomodEM, dataset = 'calibration') bm_PlotEvalBoxplot(bm.out = myBiomodEM, group.by = c('algo', 'algo')) # # Represent variables importance # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('expl.var', 'algo', 'algo')) # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('expl.var', 'algo', 'merged.by.PA')) # bm_PlotVarImpBoxplot(bm.out = myBiomodEM, group.by = c('algo', 'expl.var', 'merged.by.PA')) # # Represent response curves # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM), # fixed.var = 'median') # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM), # fixed.var = 'min') # bm_PlotResponseCurves(bm.out = myBiomodEM, # models.chosen = get_built_models(myBiomodEM, algo = 'EMmean'), # fixed.var = 'median', # do.bivariate = TRUE)
This function gathers together all input data needed (xy, presences/absences, explanatory variables, and the same for evaluation data if available) to run biomod2 models. It allows to select pseudo-absences if no absence data is available, with different strategies (see Details).
BIOMOD_FormatingData( resp.name, resp.var, resp.xy = NULL, expl.var, dir.name = ".", data.type = "binary", eval.resp.var = NULL, eval.resp.xy = NULL, eval.expl.var = NULL, PA.strategy = NULL, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL )BIOMOD_FormatingData( resp.name, resp.var, resp.xy = NULL, expl.var, dir.name = ".", data.type = "binary", eval.resp.var = NULL, eval.resp.xy = NULL, eval.expl.var = NULL, PA.strategy = NULL, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL )
resp.name |
a |
resp.var |
a |
resp.xy |
(optional, default |
expl.var |
a |
dir.name |
(optional, default |
data.type |
a |
eval.resp.var |
(optional, default |
eval.resp.xy |
(optional, default |
eval.expl.var |
(optional, default |
PA.strategy |
(optional, default |
PA.nb.rep |
(optional, default |
PA.nb.absences |
(optional, default |
PA.dist.min |
(optional, default |
PA.dist.max |
(optional, default |
PA.sre.quant |
(optional, default |
PA.fact.aggr |
(optional, default |
PA.user.table |
(optional, default |
na.rm |
(optional, default |
filter.raster |
(optional, default |
seed.val |
(optional, default |
This function gathers and formats all input data needed to run biomod2 models. It
supports different kind of inputs (e.g. matrix,
SpatVector, SpatRaster)
and provides different methods to select pseudo-absences if needed.
Concerning explanatory variables and XY coordinates :
if SpatRaster, RasterLayer or RasterStack
provided for expl.var or eval.expl.var,
biomod2 will extract
the corresponding values from XY coordinates provided :
either through resp.xy or eval.resp.xy respectively
or through resp.var or eval.resp.var, if provided as
SpatVector or SpatialPointsDataFrame
Be sure to give the objects containing XY coordinates in the same projection system than the raster objects !
if data.frame or matrix provided for expl.var or
eval.expl.var,
biomod2 will simply merge it (cbind)
with resp.var without considering XY coordinates.
Be sure to give explanatory and response values in the same row order !
Concerning pseudo-absence selection (see bm_PseudoAbsences) :
Only in the case of binary data !
if both presence and absence data are available : PA.nb.rep = 0 and no
pseudo-absence will be selected.
if no absence data is available, several pseudo-absence repetitions
are recommended (to estimate the effect of pseudo-absence selection), as well as high
number of pseudo-absence points.
Be sure not to select more pseudo-absence points than maximum number of pixels in
the studied area !
it is possible to create several pseudo-absence repetitions with different
number of points, BUT with the same sampling strategy. PA.nb.absences must contain
as many values as the number of sets of pseudo-absences (PA.nb.rep).
biomod2 models single species at a time (no multi-species).
Hence, resp.var must be an uni-dimensional object, either :
a vector, a one-column matrix or data.frame, a
SpatVector (without associated data - if presence-only)
a SpatialPoints (if presence-only)
a SpatialPointsDataFrame or SpatVector object
If resp.var is a non-spatial object (vector, matrix or
data.frame), XY coordinates must be provided through resp.xy.
Different data types are available, and require different values :
1 : presences, 0 : true absences or NA : no
information point (can be used to select pseudo-absences)
If no true absences are available, pseudo-absence selection must be done.
positive integer values
factor values
ordered factor values
numeric values between 0 and 1
positive numeric values
Factorial variables are allowed, but might lead to some pseudo-absence strategy or models
omissions (e.g. sre).
Although biomod2 provides tools to automatically divide dataset into calibration and
validation parts through the modeling process (see CV.[..] parameters in
BIOMOD_Modeling function ; or bm_CrossValidation
function), it is also possible (and strongly advised) to directly provide two independent
datasets, one for calibration/validation and one for evaluation
bm_PseudoAbsences)Only in the case of binary data !
If no true absences are available, pseudo-absences must be selected from the
background data, meaning data there is no information whether the species of
interest occurs or not. It corresponds either to the remaining pixels of the expl.var
(if provided as a SpatRaster or RasterStack)
or to the points identified as NA in resp.var (if expl.var
provided as a matrix or data.frame).
Several methods are available to do this selection :
all points of initial background are pseudo-absence candidates.
PA.nb.absences are drawn randomly, for each PA.nb.rep requested.
pseudo-absences have to be selected in conditions (combination of explanatory
variables) that differ in a defined proportion (PA.sre.quant) from those of
presence points. A Surface Range Envelop model is first run over the species of
interest (see bm_SRE), and pseudo-absences are selected outside this envelop.
This case is appropriate when all the species climatic niche has been sampled,
otherwise it may lead to over-optimistic model evaluations and predictions !
pseudo-absences are selected within circles around presence points defined by
PA.dist.min and PA.dist.max distance values (in the same projection system
units as coord and expl.var). It allows to select pseudo-absence points that
are not too close to (avoid same niche and pseudo-replication) or too far (localized
sampling strategy) from presences.
pseudo-absences are defined in advance and given as data.frame
through the PA.user.table parameter.
A BIOMOD.formated.data or BIOMOD.formated.data.PA object that can
be used to build species distribution model(s) with the BIOMOD_Modeling
function. print/show,
plot and
summary functions
are available to have a summary of the created object.
Damien Georges, Wilfried Thuiller
bm_PseudoAbsences, BIOMOD_Modeling
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_EnsembleModeling(),
BIOMOD_LoadModels(),
BIOMOD_Modeling(),
BIOMOD_Projection(),
BIOMOD_RangeSize()
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) # ---------------------------------------------------------------# # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData summary(myBiomodData) plot(myBiomodData) # ---------------------------------------------------------------# # # Transform true absences into potential pseudo-absences # myResp.PA <- ifelse(myResp == 1, 1, NA) # # # Format Data with pseudo-absences : random method # myBiomodData.r <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 1000, # PA.strategy = 'random') # # # Format Data with pseudo-absences : disk method # myBiomodData.d <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 500, # PA.strategy = 'disk', # PA.dist.min = 5, # PA.dist.max = 35) # # # Format Data with pseudo-absences : SRE method # myBiomodData.s <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 1000, # PA.strategy = 'sre', # PA.sre.quant = 0.025) # # # Format Data with pseudo-absences : 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 # myBiomodData.u <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.strategy = 'user.defined', # PA.user.table = myPAtable) # # myBiomodData.r # myBiomodData.d # myBiomodData.s # myBiomodData.u # plot(myBiomodData.r) # plot(myBiomodData.d) # plot(myBiomodData.s) # plot(myBiomodData.u) # ---------------------------------------------------------------# # # Select multiple sets of pseudo-absences # # # Transform true absences into potential pseudo-absences # myResp.PA <- ifelse(myResp == 1, 1, NA) # # # Format Data with pseudo-absences : random method # myBiomodData.multi <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = c(1000, 500, 500, 200), # PA.strategy = 'random') # myBiomodData.multi # summary(myBiomodData.multi) # plot(myBiomodData.multi)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) # ---------------------------------------------------------------# # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData summary(myBiomodData) plot(myBiomodData) # ---------------------------------------------------------------# # # Transform true absences into potential pseudo-absences # myResp.PA <- ifelse(myResp == 1, 1, NA) # # # Format Data with pseudo-absences : random method # myBiomodData.r <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 1000, # PA.strategy = 'random') # # # Format Data with pseudo-absences : disk method # myBiomodData.d <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 500, # PA.strategy = 'disk', # PA.dist.min = 5, # PA.dist.max = 35) # # # Format Data with pseudo-absences : SRE method # myBiomodData.s <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = 1000, # PA.strategy = 'sre', # PA.sre.quant = 0.025) # # # Format Data with pseudo-absences : 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 # myBiomodData.u <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.strategy = 'user.defined', # PA.user.table = myPAtable) # # myBiomodData.r # myBiomodData.d # myBiomodData.s # myBiomodData.u # plot(myBiomodData.r) # plot(myBiomodData.d) # plot(myBiomodData.s) # plot(myBiomodData.u) # ---------------------------------------------------------------# # # Select multiple sets of pseudo-absences # # # Transform true absences into potential pseudo-absences # myResp.PA <- ifelse(myResp == 1, 1, NA) # # # Format Data with pseudo-absences : random method # myBiomodData.multi <- BIOMOD_FormatingData(resp.name = myRespName, # resp.var = myResp.PA, # resp.xy = myRespXY, # expl.var = myExpl, # PA.nb.rep = 4, # PA.nb.absences = c(1000, 500, 500, 200), # PA.strategy = 'random') # myBiomodData.multi # summary(myBiomodData.multi) # plot(myBiomodData.multi)
This function loads individual models built with BIOMOD_Modeling
or BIOMOD_EnsembleModeling functions.
BIOMOD_LoadModels( bm.out, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.PA = NULL, merged.by.run = NULL, merged.by.algo = NULL, filtered.by = NULL )BIOMOD_LoadModels( bm.out, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.PA = NULL, merged.by.run = NULL, merged.by.algo = NULL, filtered.by = NULL )
bm.out |
a |
full.name |
(optional, default |
PA |
(optional, default |
run |
(optional, default |
algo |
(optional, default |
merged.by.PA |
(optional, default |
merged.by.run |
(optional, default |
merged.by.algo |
(optional, default |
filtered.by |
(optional, default |
This function might be of particular use to load models and make response plot analyses.
Running the function providing only bm.out argument will load all models built by the
BIOMOD_Modeling or BIOMOD_EnsembleModeling function, but a
subselection of models can be done using the additional arguments (full.name, PA,
run, algo, merged.by.PA, merged.by.run, merged.by.algo,
filtered.by).
A vector containing the names of the loaded models.
Damien Georges
BIOMOD_Modeling, BIOMOD_EnsembleModeling
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_EnsembleModeling(),
BIOMOD_FormatingData(),
BIOMOD_Modeling(),
BIOMOD_Projection(),
BIOMOD_RangeSize()
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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Loading some models built BIOMOD_LoadModels(bm.out = myBiomodModelOut, algo = 'RF')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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Loading some models built BIOMOD_LoadModels(bm.out = myBiomodModelOut, algo = 'RF')
This function allows to calibrate and evaluate a range of modeling techniques for a given species distribution. The dataset can be split up in calibration/validation parts, and the predictive power of the different models can be estimated using a range of evaluation metrics (see Details).
BIOMOD_Modeling( bm.format, modeling.id, models = c("ANN", "CTA", "DNN", "FDA", "GAM", "GBM", "GLM", "MARS", "MAXENT", "MAXNET", "RF", "RFd", "SRE", "XGBOOST"), models.pa = NULL, CV.strategy = NULL, CV.nb.rep = NULL, CV.perc = NULL, CV.k = NULL, CV.balance = NULL, CV.env.var = NULL, CV.strat = NULL, CV.user.table = NULL, CV.do.full.models = NULL, OPT.strategy = "default", OPT.user.val = NULL, OPT.user.base = NULL, OPT.user = NULL, metric.eval = NULL, var.import = 0, weights = NULL, prevalence = 0.5, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE )BIOMOD_Modeling( bm.format, modeling.id, models = c("ANN", "CTA", "DNN", "FDA", "GAM", "GBM", "GLM", "MARS", "MAXENT", "MAXNET", "RF", "RFd", "SRE", "XGBOOST"), models.pa = NULL, CV.strategy = NULL, CV.nb.rep = NULL, CV.perc = NULL, CV.k = NULL, CV.balance = NULL, CV.env.var = NULL, CV.strat = NULL, CV.user.table = NULL, CV.do.full.models = NULL, OPT.strategy = "default", OPT.user.val = NULL, OPT.user.base = NULL, OPT.user = NULL, metric.eval = NULL, var.import = 0, weights = NULL, prevalence = 0.5, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE )
bm.format |
a |
modeling.id |
a |
models |
a |
models.pa |
(optional, default |
CV.strategy |
(optional, default |
CV.nb.rep |
(optional, default |
CV.perc |
(optional, default |
CV.k |
(optional, default |
CV.balance |
(optional, default |
CV.env.var |
(optional, default |
CV.strat |
(optional, default |
CV.user.table |
(optional, default |
CV.do.full.models |
(optional, default |
OPT.strategy |
(default |
OPT.user.val |
(optional, default |
OPT.user.base |
(optional, default |
OPT.user |
(optional, default |
metric.eval |
a |
var.import |
(optional, default |
weights |
(optional, default |
prevalence |
(optional, default |
scale.models |
(optional, default |
nb.cpu |
(optional, default |
seed.val |
(optional, default |
do.progress |
(optional, default |
If pseudo-absences have been added to the original dataset (see
BIOMOD_FormatingData), PA.nb.rep *(nb.rep + 1) models will be
created.
The set of models to be calibrated on the data. 12 modeling techniques are currently available :
ANN : Artificial Neural Network (nnet)
CTA : Classification Tree Analysis (rpart)
DNN : Deep Neural Network (cito)
FDA : Flexible Discriminant Analysis (fda)
GAM : Generalized Additive Model (gam, gam
or bam)
(see bm_ModelingOptions for details on algorithm selection)
GBM : Generalized Boosting Model, or usually called Boosted Regression Trees
(gbm)
GLM : Generalized Linear Model (glm)
MARS : Multiple Adaptive Regression Splines (earth)
MAXENT : Maximum Entropy
(see Maxent website)
MAXNET : Maximum Entropy (maxnet)
RF : Random Forest (randomForest)
RFd : Random Forest downsampled (randomForest)
SRE : Surface Range Envelop or usually called BIOCLIM (bm_SRE)
XGBOOST : eXtreme Gradient Boosting Training (xgboost)
| ANN | CTA | DNN | FDA | GAM | GBM | GLM | MARS | MAXENT | MAXNET | RF | RFd | SRE | XGBOOST | |
| binary | x | x | x | x | x | x | x | x | x | x | x | x | x | x |
| multiclass | x | x | x | x | x | x | ||||||||
| ordinal | x | x | x | x | x | x | x | x | ||||||
| abundance / count / relative | x | x | x | x | x | x | x | x |
Different models might respond differently to different numbers of
pseudo-absences. It is possible to create sets of pseudo-absences with different numbers
of points (see BIOMOD_FormatingData) and to assign only some of these
datasets to each single model.
Different methods are available to calibrate/validate the
single models (see bm_CrossValidation).
Different methods are available to parameterize the
single models (see bm_ModelingOptions and
BIOMOD.options.dataset).
default : only default parameter values of default parameters of the single
models functions are retrieved. Nothing is changed so it might not give good results.
bigboss : uses parameters pre-defined by biomod2 team and that are
available in the dataset OptionsBigboss.
to be optimized in near future
user.defined : updates default or bigboss parameters with some parameters
values defined by the user (but matching the format of a
BIOMOD.models.options object)
tuned : calling the bm_Tuning function to try and optimize
some default values
Please refer to
CAWRC website ("Methods for
dichotomous forecasts") to get detailed description (simple/complex metrics).
Several evaluation metrics can be selected.
Optimal value of each method can be obtained with the get_optim_value
function.
POD : Probability of detection (hit rate)
FAR : False alarm ratio
POFD : Probability of false detection (fall-out)
SR : Success ratio
ACCURACY : Accuracy (fraction correct)
BIAS : Bias score (frequency bias)
AUCroc : Area Under Curve of Relative operating characteristic
AUCprg : Area Under Curve of Precision-Recall-Gain curve
TSS : True skill statistic (Hanssen and Kuipers discriminant, Peirce's
skill score)
KAPPA : Cohen's Kappa (Heidke skill score)
OR : Odds Ratio
ORSS : Odds ratio skill score (Yule's Q)
CSI : Critical success index (threat score)
ETS : Equitable threat score (Gilbert skill score)
BOYCE : Boyce index
MPA : Minimal predicted area (cutoff optimizing MPA to predict 90% of
presences)
RMSE : Root Mean Square Error
MSE : Mean Square Error
MAE : Mean Absolute Error
Rsquared : R squared
Rsquared_aj : R squared adjusted
Max_error : Maximum error
Accuracy : Accuracy
Recall : Macro average Recall
Precision : Macro average Precision
F1 : Macro F1 score
Results after modeling can be obtained through the get_evaluations function.
Evaluation metric are calculated on the calibrating data (column calibration), on
the cross-validation data (column validation) or on the evaluation data
(column evaluation).
For cross-validation data, see CV.[...] parameters in
BIOMOD_Modeling function.
For evaluation data, see
eval.[...] parameters in BIOMOD_FormatingData.
A value characterizing how much each variable has an impact on each model
predictions can be calculated by randomizing the variable of interest and computing the
correlation between original and shuffled variables (see bm_VariablesImportance).
More or less weight can be given to some specific observations.
Automatically created
weights will be integer values to prevent some modeling issues.
Note that MAXENT, MAXNET, RF, RFd and SRE models
do not take weights into account.
If prevalence = 0.5 (the default), presences and absences will be weighted equally
(i.e. the weighted sum of presences equals the weighted sum of absences).
If prevalence is set below (above) 0.5, more weight will be
given to absences (presences).
If weights is defined, prevalence argument will be ignored
(EXCEPT for MAXENT).
A binomial GLM is created to scale predictions from 0 to 1. SRE is never scaled, and ANN and FDA categorical models always are.
Note that it may lead to reduction in projected scale amplitude.
This parameter is quite experimental and it is recommended not to use it. It was
developed in the idea to ensure comparable predictions by removing the scale prediction
effect (the more extended projections are, the more they influence ensemble
forecasting results).
A BIOMOD.models.out object containing models outputs, or links to saved outputs.
Models outputs are stored out of R (for memory storage reasons) in 2 different folders
created in the current working directory :
a models folder, named after the resp.name argument of
BIOMOD_FormatingData, and containing all calibrated models for each
repetition and pseudo-absence run
a hidden folder, named .BIOMOD_DATA, and containing outputs related
files (original dataset, calibration lines, pseudo-absences selected, predictions,
variables importance, evaluation values...), that can be retrieved with
get_[...]
or load functions, and used by other biomod2 functions, like
BIOMOD_Projection or BIOMOD_EnsembleModeling
Wilfried Thuiller, Damien Georges, Robin Engler
glm, gam,
gam, bam, gbm,
rpart, nnet, cito,
fda, earth,
randomForest, maxnet,
xgboost, BIOMOD_FormatingData,
bm_ModelingOptions, bm_Tuning,
bm_CrossValidation,
bm_VariablesImportance, BIOMOD_Projection,
BIOMOD_EnsembleModeling, bm_PlotEvalMean,
bm_PlotEvalBoxplot, bm_PlotVarImpBoxplot,
bm_PlotResponseCurves
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_EnsembleModeling(),
BIOMOD_FormatingData(),
BIOMOD_LoadModels(),
BIOMOD_Projection(),
BIOMOD_RangeSize()
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) # ---------------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # ---------------------------------------------------------------------------- # # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 2, seed.val = 42) myBiomodModelOut # Get evaluation scores & variables importance get_evaluations(myBiomodModelOut) get_variables_importance(myBiomodModelOut) # Represent evaluation scores bm_PlotEvalMean(bm.out = myBiomodModelOut, dataset = 'calibration') bm_PlotEvalMean(bm.out = myBiomodModelOut, dataset = 'validation') bm_PlotEvalBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'run')) # # Represent variables importance # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'algo')) # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'run')) # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'expl.var', 'run')) # # Represent response curves # mods <- get_built_models(myBiomodModelOut, run = 'RUN1') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'median') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'min') # mods <- get_built_models(myBiomodModelOut, full.name = 'GuloGulo_allData_RUN2_RF') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'median', # do.bivariate = TRUE)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) # ---------------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # ---------------------------------------------------------------------------- # # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 2, seed.val = 42) myBiomodModelOut # Get evaluation scores & variables importance get_evaluations(myBiomodModelOut) get_variables_importance(myBiomodModelOut) # Represent evaluation scores bm_PlotEvalMean(bm.out = myBiomodModelOut, dataset = 'calibration') bm_PlotEvalMean(bm.out = myBiomodModelOut, dataset = 'validation') bm_PlotEvalBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'run')) # # Represent variables importance # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'algo')) # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'run')) # bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'expl.var', 'run')) # # Represent response curves # mods <- get_built_models(myBiomodModelOut, run = 'RUN1') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'median') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'min') # mods <- get_built_models(myBiomodModelOut, full.name = 'GuloGulo_allData_RUN2_RF') # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'median', # do.bivariate = TRUE)
This function allows to project a range of models built with the
BIOMOD_Modeling function onto new environmental data (which can
represent new areas, resolution or time scales for example).
BIOMOD_Projection( bm.mod, proj.name, new.env, new.env.xy = NULL, models.chosen = "all", metric.binary = NULL, metric.filter = NULL, build.clamping.mask = TRUE, nb.cpu = 1, seed.val = NULL, ... )BIOMOD_Projection( bm.mod, proj.name, new.env, new.env.xy = NULL, models.chosen = "all", metric.binary = NULL, metric.filter = NULL, build.clamping.mask = TRUE, nb.cpu = 1, seed.val = NULL, ... )
bm.mod |
a |
proj.name |
a |
new.env |
A |
new.env.xy |
(optional, default |
models.chosen |
a |
metric.binary |
(optional, default |
metric.filter |
(optional, default |
build.clamping.mask |
(optional, default |
nb.cpu |
(optional, default |
seed.val |
(optional, default |
... |
(optional, see Details)) |
If models.chosen = 'all', projections are done for all calibration and pseudo-absences
runs if applicable.
These projections may be used later by the
BIOMOD_EnsembleForecasting function.
If build.clamping.mask = TRUE, a raster file will be saved within the projection folder.
This mask values will correspond to the number of variables in each pixel that are out of their
calibration / validation range, identifying locations where predictions are uncertain.
... can take the following values :
(optional, default TRUE) :
a logical value defining whether all not fully referenced environmental points will
get NA as predictions or not
(optional, default 0) :
an integer value corresponding to the number of digits of the predictions
(optional, default TRUE) :
a logical value defining whether 0 - 1 probabilities are to be converted to
0 - 1000 scale to save memory on backup
(optional, default TRUE) :
a logical value defining whether all projections are to be kept loaded at once in
memory, or only links pointing to hard drive are to be returned
(optional, default TRUE) :
a logical value defining whether all projections are to be saved as one
SpatRaster object or several SpatRaster
files (the default if projections are too heavy to be all loaded at once in memory)
(optional, default .RData or .tif) :
a character value corresponding to the projections saving format on hard drive, must
be either .grd, .img, .tif or .RData (the default if
new.env is given as matrix or data.frame)
(optional, default TRUE) :
a logical or a character value defining whether and how objects should be
compressed when saved on hard drive. Must be either TRUE, FALSE, gzip
(for Windows OS) or xz (for other OS)
(optional, default do.stack) :
a logical defining whether pre-existing projections with same modeling ID and
project name should be replaced or not
A BIOMOD.projection.out object containing models projections, or links to saved
outputs.
Models projections are stored out of R (for memory storage reasons) in
proj.name folder created in the current working directory :
the output is a data.frame if new.env is a matrix or a
data.frame
it is a SpatRaster if new.env is a
SpatRaster (or several SpatRaster
objects, if new.env is too large)
raw projections, as well as binary and filtered projections (if asked), are saved in
the proj.name folder
Wilfried Thuiller, Damien Georges
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
BIOMOD_RangeSize
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_EnsembleModeling(),
BIOMOD_FormatingData(),
BIOMOD_LoadModels(),
BIOMOD_Modeling(),
BIOMOD_RangeSize()
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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Project single models file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all') } myBiomodProj plot(myBiomodProj)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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Project single models file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all') } myBiomodProj plot(myBiomodProj)
This function allows to calculate the absolute number of locations (pixels) lost, stable and gained, as well as the corresponding relative proportions, between two (or more) binary projections of (ensemble) species distribution models (which can represent new time scales or environmental scenarios for example).
BIOMOD_RangeSize( proj.current, proj.future, models.chosen = "all", metric.binary = NULL )BIOMOD_RangeSize( proj.current, proj.future, models.chosen = "all", metric.binary = NULL )
proj.current |
a |
proj.future |
a |
models.chosen |
a |
metric.binary |
(optional, default |
A BIOMOD.rangesize.out containing principaly two objects :
a data.frame containing the summary of range change for each
comparison
Loss : number of pixels predicted to be lost
Stable_Abs : number of pixels not currently occupied and not predicted to be
Stable_Pres : number of pixels currently occupied and predicted to remain
occupied
Gain : number of pixels predicted to be gained
PercLoss : percentage of pixels currently occupied and predicted to be lost
(Loss / (Loss + Stable_Pres))
PercGain : percentage of pixels predicted to be gained compare to the
number of pixels currently occupied (Gain / (Loss + Stable_Pres))
SpeciesRangeChange : percentage of pixels predicted to change (loss or gain)
compare to the number of pixels currently occupied (PercGain - PercLoss)
CurrentRangeSize : number of pixels currently occupied
FutureRangeSize0Disp : number of pixels predicted to be occupied, assuming
no migration
FutureRangeSize1Disp : number of pixels predicted to be occupied, assuming
migration
an object in the same form than the input data (proj.current and
proj.future) and containing a value for each point/pixel of each comparison among :
-2 : predicted to be lost
-1 : predicted to remain occupied
0 : predicted to remain unoccupied
1 : predicted to be gained
an object in the same form than the input data (proj.current and
proj.future) and containing a value for each point/pixel of each comparison obtain with :
Future - 2* Current for binary data
Future - Current for nonbinary after rescaling Future and Current from 0 to 1.
Maya Guéguen, Hélène Blancheteau
BIOMOD_Projection, BIOMOD_EnsembleForecasting,
bm_PlotRangeSize
Other Main functions:
BIOMOD_EnsembleForecasting(),
BIOMOD_EnsembleModeling(),
BIOMOD_FormatingData(),
BIOMOD_LoadModels(),
BIOMOD_Modeling(),
BIOMOD_Projection()
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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all', build.clamping.mask = TRUE) # --------------------------------------------------------------- # # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Compute differences myBiomodRangeSize <- BIOMOD_RangeSize(proj.current = myBiomodProj, proj.future = myBiomodProjectionFuture, metric.binary = "TSS") # Represent main results bm_PlotRangeSize(bm.range = myBiomodRangeSize)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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all', build.clamping.mask = TRUE) # --------------------------------------------------------------- # # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Compute differences myBiomodRangeSize <- BIOMOD_RangeSize(proj.current = myBiomodProj, proj.future = myBiomodProjectionFuture, metric.binary = "TSS") # Represent main results bm_PlotRangeSize(bm.range = myBiomodRangeSize)
This function allows to produce summary report or ODMAP table from a biomod2 simulation folder.
BIOMOD_Report( bm.out, strategy = "report", params.color = list(color1 = "#eb4034", color2 = "#e0918b", color3 = "#658f70"), params.ODMAP = list(O.mod.objective = NULL, O.boundary = NULL, O.obs.type = NULL, O.pred.type = NULL, D.eco.level = NULL, D.samp.design = NULL) )BIOMOD_Report( bm.out, strategy = "report", params.color = list(color1 = "#eb4034", color2 = "#e0918b", color3 = "#658f70"), params.ODMAP = list(O.mod.objective = NULL, O.boundary = NULL, O.obs.type = NULL, O.pred.type = NULL, D.eco.level = NULL, D.samp.design = NULL) )
bm.out |
a |
strategy |
a |
params.color |
a |
params.ODMAP |
a |
This function gathers and formats all objects contained in one biomod2 modeling folder
to produce, based on Rmarkdown templates, standardized reports to help the user :
summarize its modeling results
share them through standardized informations through ODMAP protocol
provide reproducible code
Different data types are available, and require different values :
biomod2 provides functions to summarize the information, such as
print, plot or summary methods adapted to BIOMOD.[...].out
objects, as well as
get_[...]
and bm_Plot[...] functions. All these are called here and applied to objects
contained in the provided modeling folder.
following Zurell et al. 2020, ODMAP (Overview, Data, Model, Assessment and Prediction) protocol aims to standardize documentation of modeling to help improve both transparency and reproducibility of results. ODMAP v1.0 website provides an application to fill this type of report. biomod2 tries here to help one user to pre-fill the fields of this protocol.
call slot contained within BIOMOD.formated.data,
BIOMOD.models.out, BIOMOD.projection.out and
BIOMOD.ensemble.models.out objects keep in memory the R command used to obtain
them. All these calls are gathered here in one summary file.
A standardized .html file obtained from an Rmarkdown template, and a .csv
table in the case of ODMAP report.
Maya Guéguen
Zurell D, Franklin J, König C, Bouchet PJ, Serra-Diaz JM, Dormann CF, Elith J, Fandos Guzman G, Feng X, Guillera-Arroita G, Guisan A, Leitão PJ, Lahoz-Monfort JJ, Park DS, Peterson AT, Rapacciuolo G, Schmatz DR, Schröder B, Thuiller W, Yates KL, Zimmermann NE, Merow C (2020). A standard protocol for describing species distribution models. Ecography 43: 1261-1277. doi:10.1111/ecog.04960
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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', build.clamping.mask = TRUE) } file.EM <- paste0(myRespName, "/", myRespName, ".AllModels.ensemble.models.out") if (file.exists(file.EM)) { myBiomodEM <- get(load(file.EM)) } else { # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # # Compile summary reports # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodProj, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodEM, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'ODMAP') # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'code')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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } file.proj <- paste0(myRespName, "/proj_Current/", myRespName, ".Current.projection.out") if (file.exists(file.proj)) { myBiomodProj <- get(load(file.proj)) } else { # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', build.clamping.mask = TRUE) } file.EM <- paste0(myRespName, "/", myRespName, ".AllModels.ensemble.models.out") if (file.exists(file.EM)) { myBiomodEM <- get(load(file.EM)) } else { # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # # Compile summary reports # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodProj, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodEM, strategy = 'report') # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'ODMAP') # BIOMOD_Report(bm.out = myBiomodModelOut, strategy = 'code')
BIOMOD_EnsembleModeling() output object classClass returned by BIOMOD_EnsembleModeling, and used by
BIOMOD_LoadModels, BIOMOD_PresenceOnly and
BIOMOD_EnsembleForecasting
## S4 method for signature 'BIOMOD.ensemble.models.out' show(object)## S4 method for signature 'BIOMOD.ensemble.models.out' show(object)
object |
a |
modeling.ida character corresponding to the name (ID) of the
simulation set
dir.namea character corresponding to the modeling folder
sp.namea character corresponding to the species name
expl.var.namesa vector containing names of explanatory
variables
data.typea character corresponding to the data type
models.outa BIOMOD.stored.models.out-class object
containing informations from BIOMOD_Modeling object
em.bya character corresponding to the way kept models have
been combined to build the ensemble models, must be among
PA+run, PA+algo, PA,
algo, all
em.computeda vector containing names of ensemble models
em.faileda vector containing names of failed ensemble models
em.models_kepta list containing single models for each ensemble model
models.evaluationa BIOMOD.stored.data.frame-class object
containing models evaluation
variables.importancea BIOMOD.stored.data.frame-class object
containing variables importance
models.predictiona BIOMOD.stored.data.frame-class object
containing models predictions
models.prediction.evala BIOMOD.stored.data.frame-class
object containing models predictions for evaluation data
linka character containing the file name of the saved object
calla language object corresponding to the call used to obtain the object
Damien Georges
BIOMOD_EnsembleModeling, BIOMOD_LoadModels,
BIOMOD_PresenceOnly, bm_VariablesImportance,
bm_PlotEvalMean, bm_PlotEvalBoxplot,
bm_PlotVarImpBoxplot, bm_PlotResponseCurves
Other Toolbox objects:
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.ensemble.models.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodEMshowClass("BIOMOD.ensemble.models.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Model ensemble models myBiomodEM <- BIOMOD_EnsembleModeling(bm.mod = myBiomodModelOut, models.chosen = 'all', em.by = 'all', em.algo = c('EMmean', 'EMca'), metric.select = c('TSS'), metric.select.thresh = c(0.7), metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodEM
BIOMOD_FormatingData() output object classClass returned by BIOMOD_FormatingData, and used by
bm_Tuning, bm_CrossValidation and
BIOMOD_Modeling
## S4 method for signature 'numeric,data.frame' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, data.mask = NULL, shared.eval.env = FALSE, filter.raster = FALSE ) ## S4 method for signature 'data.frame,ANY' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, filter.raster = FALSE ) ## S4 method for signature 'numeric,matrix' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, filter.raster = FALSE ) ## S4 method for signature 'numeric,SpatRaster' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, shared.eval.env = FALSE, filter.raster = FALSE ) ## S4 method for signature 'BIOMOD.formated.data' show(object)## S4 method for signature 'numeric,data.frame' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, data.mask = NULL, shared.eval.env = FALSE, filter.raster = FALSE ) ## S4 method for signature 'data.frame,ANY' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, filter.raster = FALSE ) ## S4 method for signature 'numeric,matrix' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, filter.raster = FALSE ) ## S4 method for signature 'numeric,SpatRaster' BIOMOD.formated.data( sp, env, xy = NULL, dir.name = ".", data.type = NULL, sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, na.rm = TRUE, shared.eval.env = FALSE, filter.raster = FALSE ) ## S4 method for signature 'BIOMOD.formated.data' show(object)
sp |
a |
env |
a |
xy |
(optional, default |
dir.name |
a |
data.type |
a |
sp.name |
a |
eval.sp |
(optional, default |
eval.env |
(optional, default |
eval.xy |
(optional, default |
na.rm |
(optional, default |
data.mask |
(optional, default |
shared.eval.env |
(optional, default |
filter.raster |
(optional, default |
object |
a |
data.typea character corresponding to the data type
dir.namea character corresponding to the modeling folder
sp.namea character corresponding to the species name
coorda 2-columns data.frame containing the corresponding X and Y
coordinates
data.speciesa vector containing the species observations (0, 1 or
NA)
data.env.vara data.frame containing explanatory variables
data.maska SpatRaster object containing the mask of the
studied area
has.data.evala logical value defining whether evaluation data is given
has.filter.rastera logical value defining whether filtering have been done or not
eval.coord(optional, default NULL)
A 2-columns data.frame containing the corresponding X and Y
coordinates for evaluation data
eval.data.species(optional, default NULL)
A vector containing the species observations (0, 1 or NA) for
evaluation data
eval.data.env.var(optional, default NULL)
A data.frame containing explanatory variables for evaluation data
biomod2.versiona character corresponding to the biomod2 version
calla language object corresponding to the call used to obtain the object
Damien Georges
BIOMOD_FormatingData, bm_Tuning,
bm_CrossValidation, BIOMOD_Modeling,
bm_RunModelsLoop
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.formated.data") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData plot(myBiomodData) summary(myBiomodData)showClass("BIOMOD.formated.data") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData plot(myBiomodData) summary(myBiomodData)
BIOMOD_FormatingData() output object class (with pseudo-absences)Class returned by BIOMOD_FormatingData, and used by
bm_Tuning, bm_CrossValidation and
BIOMOD_Modeling
## S4 method for signature 'numeric,data.frame' BIOMOD.formated.data.PA( sp, env, xy = NULL, dir.name = ".", sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, PA.strategy, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL ) ## S4 method for signature 'numeric,SpatRaster' BIOMOD.formated.data.PA( sp, env, xy = NULL, dir.name = ".", sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, PA.strategy, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL )## S4 method for signature 'numeric,data.frame' BIOMOD.formated.data.PA( sp, env, xy = NULL, dir.name = ".", sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, PA.strategy, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL ) ## S4 method for signature 'numeric,SpatRaster' BIOMOD.formated.data.PA( sp, env, xy = NULL, dir.name = ".", sp.name = NULL, eval.sp = NULL, eval.env = NULL, eval.xy = NULL, PA.strategy, PA.nb.rep = NULL, PA.nb.absences = NULL, PA.dist.min = 0, PA.dist.max = NULL, PA.sre.quant = NULL, PA.fact.aggr = NULL, PA.user.table = NULL, na.rm = TRUE, filter.raster = FALSE, seed.val = NULL )
sp |
a |
env |
a |
xy |
(optional, default |
dir.name |
a |
sp.name |
a |
eval.sp |
(optional, default |
eval.env |
(optional, default |
eval.xy |
(optional, default |
PA.strategy |
(optional, default |
PA.nb.rep |
(optional, default |
PA.nb.absences |
(optional, default |
PA.dist.min |
(optional, default |
PA.dist.max |
(optional, default |
PA.sre.quant |
(optional, default |
PA.fact.aggr |
(optional, default |
PA.user.table |
(optional, default |
na.rm |
(optional, default |
filter.raster |
(optional, default |
seed.val |
(optional, default |
dir.namea character corresponding to the modeling folder
sp.namea character corresponding to the species name
coorda 2-columns data.frame containing the corresponding X and Y
coordinates
data.speciesa vector containing the species observations (0, 1 or
NA)
data.env.vara data.frame containing explanatory variables
data.maska SpatRaster object containing
the mask of the studied area
has.data.evala logical value defining whether evaluation data is given
eval.coord(optional, default NULL)
A 2-columns data.frame containing the corresponding X and Y
coordinates for evaluation data
eval.data.species(optional, default NULL)
A vector containing the species observations (0, 1 or NA) for
evaluation data
eval.data.env.var(optional, default NULL)
A data.frame containing explanatory variables for evaluation data
PA.strategya character corresponding to the pseudo-absence selection strategy
PA.tablea data.frame containing the corresponding table of selected
pseudo-absences (indicated by TRUE or FALSE) from the pa.tab list
element returned by the bm_PseudoAbsences function
Damien Georges
BIOMOD_FormatingData, bm_PseudoAbsences,
bm_Tuning, bm_CrossValidation,
BIOMOD_Modeling, bm_RunModelsLoop
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.formated.data.PA") ## ----------------------------------------------------------------------- # library(terra) # Load species occurrences (6 species available) data(DataSpecies) head(DataSpecies) # Select the name of the studied species myRespName <- 'GuloGulo' # Keep only presence informations DataSpecies <- DataSpecies[which(DataSpecies[, myRespName] == 1), ] # 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) ## ----------------------------------------------------------------------- # # Format Data with pseudo-absences : random method myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl, PA.nb.rep = 4, PA.strategy = 'random', PA.nb.absences = 1000) myBiomodData plot(myBiomodData)showClass("BIOMOD.formated.data.PA") ## ----------------------------------------------------------------------- # library(terra) # Load species occurrences (6 species available) data(DataSpecies) head(DataSpecies) # Select the name of the studied species myRespName <- 'GuloGulo' # Keep only presence informations DataSpecies <- DataSpecies[which(DataSpecies[, myRespName] == 1), ] # 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) ## ----------------------------------------------------------------------- # # Format Data with pseudo-absences : random method myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl, PA.nb.rep = 4, PA.strategy = 'random', PA.nb.absences = 1000) myBiomodData plot(myBiomodData)
bm_ModelingOptions output object classClass returned by bm_ModelingOptions and used by
BIOMOD_Modeling
## S4 method for signature 'BIOMOD.models.options' show(object) ## S4 method for signature 'BIOMOD.models.options' print(x, dataset = "_allData_allRun")## S4 method for signature 'BIOMOD.models.options' show(object) ## S4 method for signature 'BIOMOD.models.options' print(x, dataset = "_allData_allRun")
object |
a |
x |
a |
dataset |
a |
modelsa vector containing model names for which options have
been retrieved and defined, must be algo.datatype.package.function
optionsa list containing BIOMOD.options.dataset
object for each model
Maya Guéguen
BIOMOD.options.default,
BIOMOD.options.dataset,
bm_ModelingOptions, bm_Tuning,
BIOMOD_Modeling
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.models.options")showClass("BIOMOD.models.options")
BIOMOD_Modeling() output object classClass returned by BIOMOD_Modeling, and used by
BIOMOD_LoadModels, BIOMOD_PresenceOnly,
BIOMOD_Projection and BIOMOD_EnsembleModeling
## S4 method for signature 'BIOMOD.models.out' show(object)## S4 method for signature 'BIOMOD.models.out' show(object)
object |
a |
modeling.ida character corresponding to the name (ID) of the
simulation set
dir.namea character corresponding to the modeling folder
sp.namea character corresponding to the species name
data.typea character corresponding to the data type
expl.var.namesa vector containing names of explanatory
variables
models.computeda vector containing names of computed models
models.faileda vector containing names of failed models
has.evaluation.dataa logical value defining whether evaluation
data is given
scale.modelsa logical value defining whether models have been
rescaled or not
formated.input.dataa BIOMOD.stored.formated.data-class
object containing informations from BIOMOD_FormatingData
object
calib.linesa BIOMOD.stored.data.frame-class object
containing calibration lines
models.optionsa BIOMOD.stored.options-class
object containing informations from bm_ModelingOptions
object
models.evaluationa BIOMOD.stored.data.frame-class object
containing models evaluation
variables.importancea BIOMOD.stored.data.frame-class object
containing variables importance
models.predictiona BIOMOD.stored.data.frame-class object
containing models predictions
models.prediction.evala BIOMOD.stored.data.frame-class
object containing models predictions for evaluation data
linka character containing the file name of the saved object
calla language object corresponding to the call used to obtain the object
Damien Georges
BIOMOD_Modeling, BIOMOD_LoadModels,
BIOMOD_PresenceOnly, BIOMOD_Projection,
BIOMOD_EnsembleModeling, bm_VariablesImportance,
bm_PlotEvalMean, bm_PlotEvalBoxplot,
bm_PlotVarImpBoxplot, bm_PlotResponseCurves
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.models.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) ## ----------------------------------------------------------------------- # # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodModelOutshowClass("BIOMOD.models.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) ## ----------------------------------------------------------------------- # # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) myBiomodModelOut
bm_ModelingOptions output object classClass returned by bm_ModelingOptions (a
list of BIOMOD.options.dataset more exactly), and used by
BIOMOD_Modeling
## S4 method for signature 'character' BIOMOD.options.dataset( mod, typ, pkg, fun, strategy, user.val = NULL, user.base = NULL, tuning.fun = NULL, bm.format = NULL, calib.lines = NULL ) ## S4 method for signature 'BIOMOD.options.dataset' show(object) ## S4 method for signature 'BIOMOD.options.dataset' print(x, dataset = "_allData_allRun")## S4 method for signature 'character' BIOMOD.options.dataset( mod, typ, pkg, fun, strategy, user.val = NULL, user.base = NULL, tuning.fun = NULL, bm.format = NULL, calib.lines = NULL ) ## S4 method for signature 'BIOMOD.options.dataset' show(object) ## S4 method for signature 'BIOMOD.options.dataset' print(x, dataset = "_allData_allRun")
mod |
a |
typ |
a |
pkg |
a |
fun |
a |
strategy |
a |
user.val |
(optional, default |
user.base |
(optional, default |
tuning.fun |
(optional, default |
bm.format |
(optional, default |
calib.lines |
(optional, default |
object |
a |
x |
a |
dataset |
a |
modela character corresponding to the model
typea character corresponding to the data type
(binary, binary.PA, abundance, compositional)
packagea character corresponding to the package containing
the model function to be called
funca character corresponding to the model function name
to be called
args.namesa vector containing character corresponding
to the model function arguments
args.defaulta list containing for each dataset the default
values for all arguments listed in args.names
args.valuesa list containing for each dataset the to-be-used
values for all arguments listed in args.names
Maya Guéguen
BIOMOD.options.default, bm_ModelingOptions,
bm_Tuning, BIOMOD_Modeling, bm_RunModelsLoop
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.options.dataset")showClass("BIOMOD.options.dataset")
bm_ModelingOptions output object classClass returned by bm_ModelingOptions (a
list of BIOMOD.options.dataset more exactly), and used by
BIOMOD_Modeling
## S4 method for signature 'character,character' BIOMOD.options.default(mod, typ, pkg, fun)## S4 method for signature 'character,character' BIOMOD.options.default(mod, typ, pkg, fun)
mod |
a |
typ |
a |
pkg |
a |
fun |
a |
modela character corresponding to the model
typea character corresponding to the data type
(binary, binary.PA, abundance, compositional)
packagea character corresponding to the package containing
the model function to be called
funca character corresponding to the model function name
to be called
args.namesa vector containing character corresponding
to the model function arguments
args.defaulta list containing for each dataset the default
values for all arguments listed in args.names
Maya Guéguen
BIOMOD.options.dataset, bm_ModelingOptions,
bm_Tuning, BIOMOD_Modeling, bm_RunModelsLoop
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.options.default")showClass("BIOMOD.options.default")
BIOMOD_Projection() output object classClass returned by BIOMOD_Projection, and used by
BIOMOD_EnsembleForecasting
## S4 method for signature 'BIOMOD.projection.out,missing' plot( x, coord = NULL, plot.output, do.plot = TRUE, std = TRUE, scales, size, maxcell = 5e+05, ... ) ## S4 method for signature 'BIOMOD.projection.out' show(object)## S4 method for signature 'BIOMOD.projection.out,missing' plot( x, coord = NULL, plot.output, do.plot = TRUE, std = TRUE, scales, size, maxcell = 5e+05, ... ) ## S4 method for signature 'BIOMOD.projection.out' show(object)
x |
a |
coord |
a 2-columns |
plot.output |
(optional, default |
do.plot |
(optional, default |
std |
(optional, default |
scales |
(optional, default |
size |
(optional, default |
maxcell |
maximum number of cells to plot. Argument transmitted to |
... |
additional parameters to be passed to |
object |
a |
modeling.ida character corresponding to the name (ID) of the simulation set
proj.namea character corresponding to the projection name
dir.namea character corresponding to the modeling folder
sp.namea character corresponding to the species name
expl.var.namesa vector containing names of explanatory variables
coorda 2-columns matrix or data.frame containing the corresponding
X and Y coordinates used to project the species distribution model(s)
scale.modelsa logical value defining whether models have been rescaled or
not
models.projecteda vector containing names of projected models
models.outa BIOMOD.stored.data object
typea character corresponding to the class of the val slot of the
proj.out slot
data.typea character corresponding to the data type
proj.outa BIOMOD.stored.data object
calla language object corresponding to the call used to obtain the object
Damien Georges
BIOMOD_Projection, BIOMOD_EnsembleForecasting
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.projection.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all', build.clamping.mask = TRUE) myBiomodProj plot(myBiomodProj)showClass("BIOMOD.projection.out") ## ----------------------------------------------------------------------- # 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) ## ----------------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'AUCroc'), var.import = 3, seed.val = 42) } ## ----------------------------------------------------------------------- # # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'Current', new.env = myExpl, models.chosen = 'all', metric.binary = 'all', metric.filter = 'all', build.clamping.mask = TRUE) myBiomodProj plot(myBiomodProj)
BIOMOD_RangeSize() output object classClass returned by BIOMOD_RangeSize, and used by
bm_PlotRangeSize
Compt.By.Modelsa data.frame containing the summary of range change for each comparison
Diff.By.Pixela SpatRaster or a data.frame containing a value for each point/pixel of each comparison
loss.gaina SpatRaster or a data.frame containg for each point/pixel
a value indicating a loss, a gain or a stable sitatution
data.typea character corresponding to the data type
coorda 2-columns matrix or data.frame containing the corresponding
X and Y coordinates used to project the species distribution model(s)
row.namesA vector containing tags matching models names splitted by
'_' character
Hélène Blancheteau
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.stored.data,
biomod2_ensemble_model,
biomod2_model
BIOMOD_Modeling and BIOMOD_EnsembleModeling
output object classClasses used by BIOMOD_Modeling and
BIOMOD_EnsembleModeling to build their output object (see
BIOMOD.models.out objects)
BIOMOD.stored.data is the basic object containing the slots inMemory and
link.
All listed classes below are derived from BIOMOD.stored.data, and
contain a val slot of specific type :
BIOMOD.stored.data.frame : val is a data.frame
BIOMOD.stored.SpatRaster : val is a
PackedSpatRaster
BIOMOD.stored.files : val is a character
BIOMOD.stored.formated.data : val is a
BIOMOD.formated.data object
BIOMOD.stored.options : val is a
BIOMOD.models.options object
BIOMOD.stored.models.out : val is a
BIOMOD.models.out object
inMemorya logical defining whether the val slot has been loaded in
memory or not
linka character containing the file name of the saved val slot
valan object of type depending on the BIOMOD.stored.[...] class (see Details)
Damien Georges
BIOMOD.formated.data, BIOMOD.models.out,
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
BIOMOD_Projection, BIOMOD_EnsembleForecasting
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
biomod2_ensemble_model,
biomod2_model
showClass("BIOMOD.stored.data") showClass("BIOMOD.stored.data.frame") showClass("BIOMOD.stored.SpatRaster") showClass("BIOMOD.stored.files") showClass("BIOMOD.stored.formated.data") showClass("BIOMOD.stored.options") showClass("BIOMOD.stored.models.out")showClass("BIOMOD.stored.data") showClass("BIOMOD.stored.data.frame") showClass("BIOMOD.stored.SpatRaster") showClass("BIOMOD.stored.files") showClass("BIOMOD.stored.formated.data") showClass("BIOMOD.stored.options") showClass("BIOMOD.stored.models.out")
BIOMOD_EnsembleModeling())Class created by BIOMOD_EnsembleModeling
## S4 method for signature 'biomod2_ensemble_model' show(object)## S4 method for signature 'biomod2_ensemble_model' show(object)
object |
a |
biomod2_model is the basic object for biomod2 ensemble species distribution models.
All listed classes below are derived from biomod2_model, and have a
model_class slot specific value :
biomod2_ensemble_model : model_class is EM
EMmean_biomod2_model : model_class is EMmean
EMmedian_biomod2_model : model_class is EMmedian
EMcv_biomod2_model : model_class is EMcv
EMci_biomod2_model : model_class is EMci
EMca_biomod2_model : model_class is EMca
EMwmean_biomod2_model : model_class is EMwmean
EMmode_biomod2_model : model_class is EMmode
EMfreq_biomod2_model : model_class is EMfreq
modeling.ida character corresponding to the name (ID) of the simulation set
model_namea character corresponding to the model name
model_classa character corresponding to the model class
model_optionsa list containing the model options
modelthe corresponding model object
scaling_modelthe corresponding scaled model object
dir_namea character corresponding to the modeling folder
resp_namea character corresponding to the species name
expl_var_namesa vector containing names of explanatory variables
expl_var_typea vector containing classes of explanatory variables
expl_var_rangea list containing ranges of explanatory variables
model_evaluationa data.frame containing the model evaluations
model_variables_importancea data.frame containing the model variables importance
Damien Georges
biomod2_model, BIOMOD_EnsembleModeling
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_model
showClass("biomod2_ensemble_model") showClass("EMmean_biomod2_model") showClass("EMmedian_biomod2_model") showClass("EMcv_biomod2_model") showClass("EMci_biomod2_model") showClass("EMca_biomod2_model") showClass("EMwmean_biomod2_model") showClass("EMmode_biomod2_model") showClass("EMfreq_biomod2_model")showClass("biomod2_ensemble_model") showClass("EMmean_biomod2_model") showClass("EMmedian_biomod2_model") showClass("EMcv_biomod2_model") showClass("EMci_biomod2_model") showClass("EMca_biomod2_model") showClass("EMwmean_biomod2_model") showClass("EMmode_biomod2_model") showClass("EMfreq_biomod2_model")
BIOMOD_Modeling())Class created by BIOMOD_Modeling and bm_RunModel
## S4 method for signature 'biomod2_model' show(object)## S4 method for signature 'biomod2_model' show(object)
object |
a |
biomod2_model is the basic object for biomod2 single species distribution models.
All listed classes below are derived from biomod2_model, and have a
model_class slot specific value :
ANN_biomod2_model : model_class is ANN
CTA_biomod2_model : model_class is CTA
DNN_biomod2_model : model_class is DNN
FDA_biomod2_model : model_class is FDA
GBM_biomod2_model : model_class is GBM
GLM_biomod2_model : model_class is GLM
MARS_biomod2_model : model_class is MARS
MAXENT_biomod2_model : model_class is MAXENT
MAXNET_biomod2_model : model_class is
MAXNET
RF_biomod2_model : model_class is RF
RFd_biomod2_model : model_class is RFd
SRE_biomod2_model : model_class is SRE
model_namea character corresponding to the model name
model_classa character corresponding to the model class
model_typea character corresponding to the type of data
model_optionsa list containing the model options
modelthe corresponding model object
scaling_modelthe corresponding scaled model object
levels_factorthe levels of the original data for ordinal and multiclass
dir_namea character corresponding to the modeling folder
resp_namea character corresponding to the species name
expl_var_namesa vector containing names of explanatory variables
expl_var_typea vector containing classes of explanatory variables
expl_var_rangea list containing ranges of explanatory variables
model_evaluationa data.frame containing the model evaluations
model_variables_importancea data.frame containing the model variables importance
Damien Georges
Other Toolbox objects:
BIOMOD.ensemble.models.out,
BIOMOD.formated.data(),
BIOMOD.formated.data.PA(),
BIOMOD.models.options,
BIOMOD.models.out,
BIOMOD.options.dataset(),
BIOMOD.options.default(),
BIOMOD.projection.out,
BIOMOD.rangesize.out,
BIOMOD.stored.data,
biomod2_ensemble_model
showClass("biomod2_model") showClass("ANN_biomod2_model") showClass("CTA_biomod2_model") showClass("DNN_biomod2_model") showClass("FDA_biomod2_model") showClass("GAM_biomod2_model") showClass("GBM_biomod2_model") showClass("GLM_biomod2_model") showClass("MARS_biomod2_model") showClass("MAXENT_biomod2_model") showClass("MAXNET_biomod2_model") showClass("RF_biomod2_model") showClass("RFd_biomod2_model") showClass("SRE_biomod2_model")showClass("biomod2_model") showClass("ANN_biomod2_model") showClass("CTA_biomod2_model") showClass("DNN_biomod2_model") showClass("FDA_biomod2_model") showClass("GAM_biomod2_model") showClass("GBM_biomod2_model") showClass("GLM_biomod2_model") showClass("MARS_biomod2_model") showClass("MAXENT_biomod2_model") showClass("MAXNET_biomod2_model") showClass("RF_biomod2_model") showClass("RFd_biomod2_model") showClass("SRE_biomod2_model")
This internal biomod2 function allows to convert probability (not necessary
between 0 and 1) values into binary presence-absence (0 or 1) values
according to a predefined threshold (see Details).
bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'data.frame' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'matrix' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'numeric' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'SpatRaster' bm_BinaryTransformation(data, threshold, do.filtering = FALSE)bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'data.frame' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'matrix' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'numeric' bm_BinaryTransformation(data, threshold, do.filtering = FALSE) ## S4 method for signature 'SpatRaster' bm_BinaryTransformation(data, threshold, do.filtering = FALSE)
data |
a |
threshold |
a |
do.filtering |
(optional, default |
If data is a vector, threshold should be a single
numeric value.
If data is a matrix, data.frame or
SpatRaster, threshold should be a
vector containing as many values as the number of columns or
layers contained in data. If only one numeric value is given,
the same threshold will be applied to all columns or layers.
If do.filtering = FALSE, binary (0 or 1) values are returned.
If do.filtering = TRUE, values will be filtered according to threshold,
meaning that :
data < threshold will return 0
data >= threshold will return the actual values of data (not
transformed in 1)
An object of the same class than data and containing either
binary (0 or 1) values, or filtered values.
Wilfried Thuiller, Damien Georges
BIOMOD_Projection, BIOMOD_EnsembleForecasting
Other Secondary functions:
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
## Generate a 0-1000 vector (normal distribution) vec.d <- rnorm(100, 500, 100) ## From continuous to binary / filtered vector vec.d_bin <- bm_BinaryTransformation(data = vec.d, threshold = 500) vec.d_filt <- bm_BinaryTransformation(data = vec.d, threshold = 500, do.filtering = TRUE) cbind(vec.d, vec.d_bin, vec.d_filt)## Generate a 0-1000 vector (normal distribution) vec.d <- rnorm(100, 500, 100) ## From continuous to binary / filtered vector vec.d_bin <- bm_BinaryTransformation(data = vec.d, threshold = 500) vec.d_filt <- bm_BinaryTransformation(data = vec.d, threshold = 500, do.filtering = TRUE) cbind(vec.d, vec.d_bin, vec.d_filt)
This internal biomod2 function allows to build a cross-validation table
according to 6 different methods : random, kfold, block, strat,
env or user.defined (see Details).
bm_CrossValidation( bm.format, strategy, nb.rep = NULL, perc = NULL, k = NULL, balance = NULL, strat = NULL, env.var = NULL, user.table = NULL, do.full.models = FALSE, seed.val = NULL ) bm_CrossValidation_user.defined(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_user.defined(bm.format, user.table) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_user.defined(bm.format, user.table) bm_CrossValidation_random(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_random(bm.format, nb.rep, perc) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_random(bm.format, nb.rep, perc) bm_CrossValidation_kfold(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_kfold(bm.format, nb.rep, k) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_kfold(bm.format, nb.rep, k) bm_CrossValidation_block(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_block(bm.format) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_block(bm.format) bm_CrossValidation_strat(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_strat(bm.format, balance, strat, k) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_strat(bm.format, balance, strat, k) bm_CrossValidation_env(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_env(bm.format, balance, k, env.var) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_env(bm.format, balance, k, env.var)bm_CrossValidation( bm.format, strategy, nb.rep = NULL, perc = NULL, k = NULL, balance = NULL, strat = NULL, env.var = NULL, user.table = NULL, do.full.models = FALSE, seed.val = NULL ) bm_CrossValidation_user.defined(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_user.defined(bm.format, user.table) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_user.defined(bm.format, user.table) bm_CrossValidation_random(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_random(bm.format, nb.rep, perc) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_random(bm.format, nb.rep, perc) bm_CrossValidation_kfold(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_kfold(bm.format, nb.rep, k) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_kfold(bm.format, nb.rep, k) bm_CrossValidation_block(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_block(bm.format) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_block(bm.format) bm_CrossValidation_strat(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_strat(bm.format, balance, strat, k) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_strat(bm.format, balance, strat, k) bm_CrossValidation_env(bm.format, ...) ## S4 method for signature 'BIOMOD.formated.data' bm_CrossValidation_env(bm.format, balance, k, env.var) ## S4 method for signature 'BIOMOD.formated.data.PA' bm_CrossValidation_env(bm.format, balance, k, env.var)
bm.format |
a |
strategy |
a |
nb.rep |
(optional, default |
perc |
(optional, default |
k |
(optional, default |
balance |
(optional, default |
strat |
(optional, default |
env.var |
(optional) |
user.table |
(optional, default |
do.full.models |
(optional, default |
seed.val |
(optional, default |
... |
(optional, one or several of the listed above arguments depending on the selected method) |
Several parameters are available within the function and some of them can be used with different cross-validation strategies :
| ....... | random | kfold | block | strat | env |
__________________________________________________ | nb.rep. | x..... | x.... | ..... | ..... | ... | | perc... | x..... | ..... | ..... | ..... | ... | | k...... | ...... | x.... | ..... | x.... | x.. | | balance | ...... | ..... | ..... | x.... | x.. | | strat.. | ...... | ..... | ..... | x.... | ... |
Concerning column names of matrix output :
The number of columns depends on the strategy selected.
The column names are given a posteriori of the selection, ranging from 1 to the
number of columns.
If do.full.models = TRUE, columns merging runs (and/or pseudo-absence datasets)
are added at the end.
Concerning cross-validation strategies :
Most simple method to calibrate and validate a model is to split the original
dataset in two datasets : one to calibrate the model and the other one to validate it. The
splitting can be repeated nb.rep times.
The k-fold method splits the original dataset in k datasets of equal
sizes : each part is used successively as the validation dataset while the other k-1
parts are used for the calibration, leading to k calibration/validation ensembles.
This multiple splitting can be repeated nb.rep times.
It may be used to test for model overfitting and to assess transferability in
geographic space. block stratification was described in Muscarella et al. 2014
(see References). Four bins of equal size are partitioned (bottom-left, bottom-right,
top-left and top-right).
It may be used to test for model overfitting and to assess transferability
in geographic space. x and y stratification was described in Wenger and
Olden 2012 (see References). y stratification uses k partitions along the
y-gradient, x stratification does the same for the x-gradient. both returns
2k partitions: k partitions stratified along the x-gradient and k
partitions stratified along the y-gradient.
It may be used to test for model overfitting and to assess
transferability in environmental space. It returns k partitions for each variable
given in env.var.
Allow the user to give its own crossvalidation table. For a
presence-absence dataset, column names must be formatted as: _allData_RUNx with
x an integer. For a presence-only dataset for which several pseudo-absence dataset
were generated, column names must be formatted as: _PAx_RUNy with x an
integer and PAx an existing pseudo-absence dataset and y an integer
Concerning balance parameter :
If balance = 'presences', presences are divided (balanced) equally over the partitions
(e.g. Fig. 1b in Muscarelly et al. 2014).
Absences or pseudo-absences will however be unbalanced over the partitions especially if the
presences are clumped on an edge of the study area.
If balance = 'absences', absences (resp. pseudo-absences or background) are divided
(balanced) as equally as possible between the partitions (geographical balanced bins given
that absences are spread over the study area equally, approach similar to Fig. 1 in
Wenger et Olden 2012). Presences will however be unbalanced over the partitions especially
if the presences are clumped on an edge of the study area.
A matrix or data.frame defining for each repetition (in columns) which
observation lines should be used for models calibration (TRUE) and validation
(FALSE).
Maya Guéguen
Muscarella R, Galante PJ, Soley-Guardia M, Boria RA, Kass JM, Uriarte M, Anderson RP (2014). ENMeval: An R package for conducting spatially independent evaluations and estimating optimal model complexity for Maxent ecological niche models. Methods in Ecology and Evolution, 5, 1198-1205. doi:10.1111/2041-210X.12261
Wenger SJ and Olden JD (2012). Assessing transferability of ecological models: an underappreciated aspect of statistical validation. Methods in Ecology and Evolution, 3, 260-267. doi:10.1111/j.2041-210X.2011.00170.x
get.block, kfold,
BIOMOD_FormatingData, BIOMOD_Modeling
Other Secondary functions:
bm_BinaryTransformation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
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) # --------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # --------------------------------------------------------------- # # Create the different validation datasets # random selection cv.r <- bm_CrossValidation(bm.format = myBiomodData, strategy = "random", nb.rep = 3, perc = 0.8) # k-fold selection cv.k <- bm_CrossValidation(bm.format = myBiomodData, strategy = "kfold", nb.rep = 2, k = 3) # block selection cv.b <- bm_CrossValidation(bm.format = myBiomodData, strategy = "block") # stratified selection (geographic) cv.s <- bm_CrossValidation(bm.format = myBiomodData, strategy = "strat", k = 2, balance = "presences", strat = "x") # stratified selection (environmental) cv.e <- bm_CrossValidation(bm.format = myBiomodData, strategy = "env", k = 2, balance = "presences") head(cv.r) apply(cv.r, 2, table) head(cv.k) apply(cv.k, 2, table) head(cv.b) apply(cv.b, 2, table) head(cv.s) apply(cv.s, 2, table) head(cv.e) apply(cv.e, 2, table)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) # --------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # --------------------------------------------------------------- # # Create the different validation datasets # random selection cv.r <- bm_CrossValidation(bm.format = myBiomodData, strategy = "random", nb.rep = 3, perc = 0.8) # k-fold selection cv.k <- bm_CrossValidation(bm.format = myBiomodData, strategy = "kfold", nb.rep = 2, k = 3) # block selection cv.b <- bm_CrossValidation(bm.format = myBiomodData, strategy = "block") # stratified selection (geographic) cv.s <- bm_CrossValidation(bm.format = myBiomodData, strategy = "strat", k = 2, balance = "presences", strat = "x") # stratified selection (environmental) cv.e <- bm_CrossValidation(bm.format = myBiomodData, strategy = "env", k = 2, balance = "presences") head(cv.r) apply(cv.r, 2, table) head(cv.k) apply(cv.k, 2, table) head(cv.b) apply(cv.b, 2, table) head(cv.s) apply(cv.s, 2, table) head(cv.e) apply(cv.e, 2, table)
This internal biomod2 function allows the user to find the threshold to convert continuous values into binary ones leading to the best score for a given evaluation metric.
bm_FindOptimStat( metric.eval = "TSS", obs, fit, nb.thresh = 100, threshold = NULL, boyce.bg.env = NULL, mpa.perc = 0.9, k = NULL ) get_optim_value(metric.eval) bm_CalculateStatBin(misc, metric.eval = "TSS") bm_CalculateStatAbun(metric.eval, obs, fit, k)bm_FindOptimStat( metric.eval = "TSS", obs, fit, nb.thresh = 100, threshold = NULL, boyce.bg.env = NULL, mpa.perc = 0.9, k = NULL ) get_optim_value(metric.eval) bm_CalculateStatBin(misc, metric.eval = "TSS") bm_CalculateStatAbun(metric.eval, obs, fit, k)
metric.eval |
a |
obs |
a |
fit |
a |
nb.thresh |
an |
threshold |
(optional, default |
boyce.bg.env |
(optional, default |
mpa.perc |
a |
k |
an |
misc |
a |
Please refer to CAWRC website
("Methods for dichotomous forecasts") to get detailed description (simple/complex metrics).
Optimal value of each method can be obtained with the get_optim_value function.
POD : Probability of detection (hit rate)
FAR : False alarm ratio
POFD : Probability of false detection (fall-out)
SR : Success ratio
ACCURACY : Accuracy (fraction correct)
BIAS : Bias score (frequency bias)
AUCroc : Area Under Curve of Relative operating characteristic
AUCprg : Area Under Curve of Precision-Recall-Gain curve
TSS : True skill statistic (Hanssen and Kuipers discriminant, Peirce's
skill score)
KAPPA : Cohen's Kappa (Heidke skill score)
OR : Odds Ratio
ORSS : Odds ratio skill score (Yule's Q)
CSI : Critical success index (threat score)
ETS : Equitable threat score (Gilbert skill score)
BOYCE : Boyce index
MPA : Minimal predicted area (cutoff optimizing MPA to predict 90% of
presences)
RMSE : Root Mean Square Error
MSE : Mean Square Error
MAE : Mean Absolute Error
Rsquared : R squared
Rsquared_aj : R squared adjusted
Max_error : Maximum error
Accuracy : Accuracy
Recall : Macro average Recall
Precision : Macro average Precision
F1 : Macro F1 score
Note that if a value is given to threshold, no optimization will be done, and
only the score for this threshold will be returned.
The Boyce index returns NA values for SRE models because it can not be
calculated with binary predictions.
This is also the reason why some NA values
might appear for GLM models if they did not converge.
A 1 row x 5 columns data.frame containing :
metric.eval : the chosen evaluation metric
cutoff : the associated cut-off used to transform the continuous values into
binary
sensitivity : the sensibility obtained on fitted values with this threshold
specificity : the specificity obtained on fitted values with this threshold
best.stat : the best score obtained for the chosen evaluation metric
In order to break dependency loop between packages biomod2 and ecospat,
code of ecospat.boyce() and ecospat.mpa() in ecospat)
functions have been copied within this file from version 3.2.2 (august 2022).
Damien Georges
Engler R, Guisan A, Rechsteiner L (2004). An improved approach for predicting the distribution of rare and endangered species from occurrence and pseudo-absence data. Journal of Applied Ecology, 41(2), 263-274. doi:10.1111/j.0021-8901.2004.00881.x
Hirzel AH, Le Lay G, Helfer V, Randin C, Guisan A (2006). Evaluating the ability of habitat suitability models to predict species presences. Ecological Modelling, 199(2), 142-152. doi:10.1016/j.ecolmodel.2006.05.017
ecospat.boyce() and ecospat.mpa() in ecospat,
BIOMOD_Modeling, bm_RunModelsLoop,
BIOMOD_EnsembleModeling
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
## Generate a binary vector vec.a <- sample(c(0, 1), 100, replace = TRUE) ## Generate a 0-1000 vector (random drawing) vec.b <- runif(100, min = 0, max = 1000) ## Generate a 0-1000 vector (biased drawing) BiasedDrawing <- function(x, m1 = 300, sd1 = 200, m2 = 700, sd2 = 200) { return(ifelse(x < 0.5, rnorm(1, m1, sd1), rnorm(1, m2, sd2))) } vec.c <- sapply(vec.a, BiasedDrawing) vec.c[which(vec.c < 0)] <- 0 vec.c[which(vec.c > 1000)] <- 1000 ## Find optimal threshold for a specific evaluation metric bm_FindOptimStat(metric.eval = 'TSS', fit = vec.b, obs = vec.a) bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, nb.thresh = 100) bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, threshold = 280)## Generate a binary vector vec.a <- sample(c(0, 1), 100, replace = TRUE) ## Generate a 0-1000 vector (random drawing) vec.b <- runif(100, min = 0, max = 1000) ## Generate a 0-1000 vector (biased drawing) BiasedDrawing <- function(x, m1 = 300, sd1 = 200, m2 = 700, sd2 = 200) { return(ifelse(x < 0.5, rnorm(1, m1, sd1), rnorm(1, m2, sd2))) } vec.c <- sapply(vec.a, BiasedDrawing) vec.c[which(vec.c < 0)] <- 0 vec.c[which(vec.c > 1000)] <- 1000 ## Find optimal threshold for a specific evaluation metric bm_FindOptimStat(metric.eval = 'TSS', fit = vec.b, obs = vec.a) bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, nb.thresh = 100) bm_FindOptimStat(metric.eval = 'TSS', fit = vec.c, obs = vec.a, threshold = 280)
This internal biomod2 function allows the user to create easily a standardized formula that can be used later by statistical models.
bm_MakeFormula( resp.name, expl.var, type = "simple", interaction.level = 0, k = NULL )bm_MakeFormula( resp.name, expl.var, type = "simple", interaction.level = 0, k = NULL )
resp.name |
a |
expl.var |
a |
type |
a |
interaction.level |
an |
k |
(optional, default |
It is advised to give only a subset of expl.var table to avoid useless memory consuming.
If some explanatory variables are factorial, expl.var must be a data.frame
whose corresponding columns are defined as factor.
A formula class object that can be directly given to most of R
statistical models.
Damien Georges
formula, s, s,
bm_ModelingOptions, bm_Tuning,
bm_RunModelsLoop
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
## Create simple simulated data myResp.s <- sample(c(0, 1), 20, replace = TRUE) myExpl.s <- data.frame(var1 = sample(c(0, 1), 100, replace = TRUE), var2 = rnorm(100), var3 = 1:100) ## Generate automatic formula bm_MakeFormula(resp.name = 'myResp.s', expl.var = head(myExpl.s), type = 'quadratic', interaction.level = 0)## Create simple simulated data myResp.s <- sample(c(0, 1), 20, replace = TRUE) myExpl.s <- data.frame(var1 = sample(c(0, 1), 100, replace = TRUE), var2 = rnorm(100), var3 = 1:100) ## Generate automatic formula bm_MakeFormula(resp.name = 'myResp.s', expl.var = head(myExpl.s), type = 'quadratic', interaction.level = 0)
This function return several graphs to help analyse the single models.
bm_ModelAnalysis( bm.mod, models.chosen = "all", color.by = "full.name", do.plot = TRUE )bm_ModelAnalysis( bm.mod, models.chosen = "all", color.by = "full.name", do.plot = TRUE )
bm.mod |
a |
models.chosen |
a |
color.by |
a |
do.plot |
(optional, default |
5 plots can be obtained with this function :
to detect outliers. The x-axis only helps to find the outlier number.
to check if residuals follow a normal distribution. Points should follow the black line.
to check if residuals follow a normal distribution. Histogram should represent a gaussian distribution.
to detect an heteroscedasticity of the residuals. It corresponds to the Tukey-Anscombe plot.
to detect overfitting. Representing Rsquared and
Rsquared_aj values, there should not be a big gap between calibration and
validation values.
Please note that all plots are made for all models, independently to the different models assumptions. It is up to the user to interpret the graphics.
A list containing :
a data.frame with variables, predicted values and model residuals
a data.frame with the R score values
5 ggplot objects (from A to E) representing the different analyses.
Hélène Blancheteau
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot()
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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Explore single models myBiomodAnalysis <- bm_ModelAnalysis(bm.mod = myBiomodModelOut, color.by = "run") plot(myBiomodAnalysis$plot.outliers)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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','AUCroc'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Explore single models myBiomodAnalysis <- bm_ModelAnalysis(bm.mod = myBiomodModelOut, color.by = "run") plot(myBiomodAnalysis$plot.outliers)
Parameterize and/or tune biomod2's single models options.
bm_ModelingOptions( data.type = "binary", models, strategy, user.val = NULL, user.base = "bigboss", bm.format = NULL, calib.lines = NULL )bm_ModelingOptions( data.type = "binary", models, strategy, user.val = NULL, user.base = "bigboss", bm.format = NULL, calib.lines = NULL )
data.type |
a |
models |
a |
strategy |
a |
user.val |
(optional, default |
user.base |
(optional, default |
bm.format |
(optional, default |
calib.lines |
(optional, default |
This function creates a BIOMOD.models.options object containing parameter values
for each single model that can be run within biomod2 through
BIOMOD_Modeling function.
11 different algorithms are currently available, with different versions for some (GAM,
MAXENT, RF). These models are associated with binary or nonbinary
datatypes, but all combinations are not available. They are all listed within the
ModelsTable dataset.
Different strategies are available to set those parameters, through the strategy
argument :
all parameters names and values are directly retrieve from functions to be
called through formalArgs and formals functions
default parameter values are updated with values predefined by biomod2
team (see OptionsBigboss)
default parameter values are updated with values provided by the user
default parameter values are updated by calling bm_Tuning
function
To define the same options for all datasets of a model, options can be provided through the
user.val parameter as a list whose name is for_all_datasets.
A BIOMOD.models.options of object that can be used to build species
distribution model(s) with the BIOMOD_Modeling function.
MAXENT being the only external model (not called through a R package),
default parameters, and their values, are the following :
| FLAG | default | Description |
path_to_maxent.jar |
getwd() | a character corresponding to path to
maxent.jar file |
memory_allocated |
512 | an integer corresponding to the amount of memory
(in Mo) reserved for java to run MAXENT, must be either 64,
128, 256, 512, 1024... or NULL to use default java
memory limitation parameter |
initial_heap_size |
NULL | a character corresponding to initial heap
space (shared memory space) allocated to java (argument -Xms when calling
java), must be either 1024K, 4096M, 10G ... or NULL to
use default java parameter. Used in BIOMOD_Projection but not in
BIOMOD_Modeling. |
max_heap_size |
NULL | a character corresponding to maximum heap
space (shared memory space) allocated to java (argument -Xmx when calling
java), must be either 1024K, 4096M, 10G ... or NULL to
use default java parameter, and must be larger than initial_heap_size. Used
in BIOMOD_Projection but not in BIOMOD_Modeling. |
background_data_dir |
'default' | a character corresponding to path
to folder where explanatory variables are stored as ASCII files (raster format).
If specified, MAXENT will generate its own background data from rasters of
explanatory variables ('default' value). Otherwise biomod2 pseudo-absences
will be used (see BIOMOD_FormatingData). |
visible |
FALSE | a logical value defining whether MAXENT
user interface is to be used or not |
linear |
TRUE | a logical value defining whether linear features are
to be used or not |
quadratic |
TRUE | a logical value defining whether quadratic features are
to be used or not |
product |
TRUE | a logical value defining whether product features are
to be used or not |
threshold |
TRUE | a logical value defining whether threshold features are
to be used or not |
hinge |
TRUE | a logical value defining whether hinge features are
to be used or not |
l2lqthreshold |
10 | an integer corresponding to the number of
samples at which quadratic features start being used |
lq2lqptthreshold |
80 | an integer corresponding to the number of
samples at which product and threshold features start being used |
hingethreshold |
15 | an integer corresponding to the number of
samples at which hinge features start being used |
beta_lqp |
-1.0 | a numeric corresponding to the regularization
parameter to be applied to all linear, quadratic and product features (negative value
enables automatic setting) |
beta_threshold |
-1.0 | a numeric corresponding to the regularization
parameter to be applied to all threshold features (negative value enables automatic
setting) |
beta_hinge |
-1.0 | a numeric corresponding to the regularization
parameter to be applied to all hinge features (negative value enables automatic
setting) |
beta_categorical |
-1.0 | a numeric corresponding to the regularization
parameter to be applied to all categorical features (negative value enables automatic
setting) |
betamultiplier |
1 | a numeric corresponding to the number by which
multiply all automatic regularization parameters (higher number gives a more
spread-out distribution) |
defaultprevalence |
0.5 | a numeric corresponding to the default
prevalence of the modelled species (probability of presence at ordinary occurrence
points) |
togglelayerselected |
NULL | a character defining the prefix to be used
to REMOVE environmental layers whose names begin with this prefix (all selected by
default) |
maximumbackground |
10000 | an integer corresponding to the maximum
number of pixels to be selected randomly among background points if larger than this number |
maximumiterations |
500 | an integer corresponding to the maximum number
of iterations for training |
convergencethreshold |
0.00005 | a numeric corresponding to the drop in
log loss per iteration below which the training will be stopped |
autofeature |
TRUE | a logical value defining whether feature classes
to be used will automatically be selected based on number of training samples or not |
jackknife |
FALSE | a logical value defining whether variables'
importance is to be measured or not. If selected, training will be done with each
environmental variable first omitted then used in isolation. |
writeclampgrid |
FALSE | a logical value defining whether clamping mask
is to be saved or not (absolute difference between prediction values with and without
clamping) |
writemess |
FALSE | a logical value defining whether multidimensional
environmental similarity surface (MESS) is to be saved or not (degree of novelness of
environmental conditions; and which variable is the most out of range at each point) |
logfile |
'maxent.log' | a character corresponding to file name in which
debugging information will be written |
verbose |
FALSE | a logical value defining whether detailed diagnostics
for debugging should be given or not
|
Damien Georges, Wilfried Thuiller, Maya Guéguen
ModelsTable, OptionsBigboss,
BIOMOD.models.options,
bm_Tuning, BIOMOD_Modeling
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
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) # ---------------------------------------------------------------# # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # k-fold selection cv.k <- bm_CrossValidation(bm.format = myBiomodData, strategy = 'kfold', nb.rep = 2, k = 3) # ---------------------------------------------------------------# allModels <- c('ANN', 'CTA', 'DNN', 'FDA', 'GAM', 'GBM', 'GLM', 'MARS' , 'MAXENT', 'MAXNET', 'RF', 'RFd', 'SRE', 'XGBOOST') # default parameters opt.d <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default') # providing formated data opt.df <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default', bm.format = myBiomodData, calib.lines = cv.k) opt.d opt.d@models opt.d@options$ANN.binary.nnet.nnet names(opt.d@[email protected]) opt.df@options$ANN.binary.nnet.nnet names(opt.df@[email protected]) # ---------------------------------------------------------------# # bigboss parameters opt.b <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'bigboss') # user defined parameters user.SRE <- list('_allData_allRun' = list(quant = 0.01)) user.XGBOOST <- list('_allData_allRun' = list(nrounds = 10)) user.val <- list(SRE.binary.biomod2.bm_SRE = user.SRE , XGBOOST.binary.xgboost.xgb_train = user.XGBOOST) opt.u <- bm_ModelingOptions(data.type = 'binary', models = c('SRE', 'XGBOOST'), strategy = 'user.defined', user.val = user.val) opt.b opt.u ## Not run: # tuned parameters with formated data opt.t <- bm_ModelingOptions(data.type = 'binary', models = c('SRE', 'XGBOOST'), strategy = 'tuned', bm.format = myBiomodData) opt.t ## End(Not run)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) # ---------------------------------------------------------------# # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # k-fold selection cv.k <- bm_CrossValidation(bm.format = myBiomodData, strategy = 'kfold', nb.rep = 2, k = 3) # ---------------------------------------------------------------# allModels <- c('ANN', 'CTA', 'DNN', 'FDA', 'GAM', 'GBM', 'GLM', 'MARS' , 'MAXENT', 'MAXNET', 'RF', 'RFd', 'SRE', 'XGBOOST') # default parameters opt.d <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default') # providing formated data opt.df <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default', bm.format = myBiomodData, calib.lines = cv.k) opt.d opt.d@models opt.d@options$ANN.binary.nnet.nnet names(opt.d@options$ANN.binary.nnet.nnet@args.values) opt.df@options$ANN.binary.nnet.nnet names(opt.df@options$ANN.binary.nnet.nnet@args.values) # ---------------------------------------------------------------# # bigboss parameters opt.b <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'bigboss') # user defined parameters user.SRE <- list('_allData_allRun' = list(quant = 0.01)) user.XGBOOST <- list('_allData_allRun' = list(nrounds = 10)) user.val <- list(SRE.binary.biomod2.bm_SRE = user.SRE , XGBOOST.binary.xgboost.xgb_train = user.XGBOOST) opt.u <- bm_ModelingOptions(data.type = 'binary', models = c('SRE', 'XGBOOST'), strategy = 'user.defined', user.val = user.val) opt.b opt.u ## Not run: # tuned parameters with formated data opt.t <- bm_ModelingOptions(data.type = 'binary', models = c('SRE', 'XGBOOST'), strategy = 'tuned', bm.format = myBiomodData) opt.t ## End(Not run)
This function represents boxplot of evaluation scores of species distribution
models, from BIOMOD.models.out or BIOMOD.ensemble.models.out
objects that can be obtained from BIOMOD_Modeling or
BIOMOD_EnsembleModeling functions. Scores are represented according to 2
grouping methods (see Details).
bm_PlotEvalBoxplot( bm.out, dataset = "calibration", group.by = c("algo", "run"), do.plot = TRUE, ... )bm_PlotEvalBoxplot( bm.out, dataset = "calibration", group.by = c("algo", "run"), do.plot = TRUE, ... )
bm.out |
a |
dataset |
a |
group.by |
a 2-length |
do.plot |
(optional, default |
... |
some additional arguments (see Details) |
... can take the following values :
main : a character corresponding to the graphic title
scales : a character corresponding to the scales argument of
the facet_wrap function, must be either fixed, free_x,
free_y or free
A list containing a data.frame with evaluation scores and the corresponding
ggplot object representing them in boxplot.
Damien Georges, Maya Guéguen
BIOMOD.models.out, BIOMOD.ensemble.models.out,
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
get_evaluations
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_ModelAnalysis(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot()
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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get evaluation scores get_evaluations(myBiomodModelOut) # Represent evaluation scores bm_PlotEvalBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'run'))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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get evaluation scores get_evaluations(myBiomodModelOut) # Represent evaluation scores bm_PlotEvalBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'run'))
This function represents mean evaluation scores (and their standard deviation)
of species distribution models, from BIOMOD.models.out or
BIOMOD.ensemble.models.out objects that can be obtained from
BIOMOD_Modeling or BIOMOD_EnsembleModeling functions. Scores are
represented according to 2 different evaluation methods, and models can be grouped
(see Details).
bm_PlotEvalMean( bm.out, metric.eval = NULL, dataset = "calibration", group.by = "algo", do.plot = TRUE, ... )bm_PlotEvalMean( bm.out, metric.eval = NULL, dataset = "calibration", group.by = "algo", do.plot = TRUE, ... )
bm.out |
a |
metric.eval |
a 2-length |
dataset |
a |
group.by |
a |
do.plot |
(optional, default |
... |
some additional arguments (see Details) |
... can take the following values :
xlim : an integer corresponding to the x maximum limit to represent
ylim : an integer corresponding to the y maximum limit to represent
main : a character corresponding to the graphic title
col : a vector containing new color values
A list containing a data.frame with mean and standard deviation of evaluation
scores and the corresponding ggplot object representing them according to 2 different
evaluation methods.
Damien Georges, Maya Guéguen
BIOMOD.models.out, BIOMOD.ensemble.models.out,
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
get_evaluations
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_ModelAnalysis(),
bm_PlotEvalBoxplot(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot()
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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get evaluation scores get_evaluations(myBiomodModelOut) # Represent mean evaluation scores bm_PlotEvalMean(bm.out = myBiomodModelOut)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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get evaluation scores get_evaluations(myBiomodModelOut) # Represent mean evaluation scores bm_PlotEvalMean(bm.out = myBiomodModelOut)
This function represents species range change from object that can be obtained
from BIOMOD_RangeSize function. Several graphics can be obtained, representing
global counts or proportions of gains / losses, as well as spatial representations (see Details).
bm_PlotRangeSize( bm.range, do.count = TRUE, do.perc = TRUE, do.maps = TRUE, do.mean = TRUE, do.plot = TRUE )bm_PlotRangeSize( bm.range, do.count = TRUE, do.perc = TRUE, do.maps = TRUE, do.mean = TRUE, do.plot = TRUE )
bm.range |
an |
do.count |
(optional, default |
do.perc |
(optional, default |
do.maps |
(optional, default |
do.mean |
(optional, default |
do.plot |
(optional, default |
4 plots can be obtained with this function :
representing absolute number of locations (pixels) lost, stable and gained
representing percentage of locations (pixels) lost, stable, and
the corresponding Species Range Change (PercGain - PercLoss)
representing spatially locations (pixels) lost, stable and gained for each single distribution model
representing spatially locations (pixels) lost, stable and gained, taking the majoritary value across single distribution models (and representing the percentage of models' agreement)
Please see bm_RangeSize function for more details about the values.
A list containing one or several data.frame and the corresponding
ggplot object representing species range change.
Maya Guéguen, Hélène Blancheteau
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_ModelAnalysis(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot()
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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all') # ---------------------------------------------------------------# # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Compute differences myBiomodRangeSize <- BIOMOD_RangeSize(proj.current = myBiomodProj, proj.future = myBiomodProjectionFuture, metric.binary = "TSS") # Represent main results bm_PlotRangeSize(bm.range = myBiomodRangeSize)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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all') # ---------------------------------------------------------------# # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Compute differences myBiomodRangeSize <- BIOMOD_RangeSize(proj.current = myBiomodProj, proj.future = myBiomodProjectionFuture, metric.binary = "TSS") # Represent main results bm_PlotRangeSize(bm.range = myBiomodRangeSize)
This function represents response curves of species distribution models, from
BIOMOD.models.out or BIOMOD.ensemble.models.out objects that can
be obtained from BIOMOD_Modeling or BIOMOD_EnsembleModeling
functions. Response curves can be represented in either 2 or 3 dimensions (meaning 1 or 2
explanatory variables at a time, see Details).
bm_PlotResponseCurves( bm.out, models.chosen = "all", new.env = get_formal_data(bm.out, "expl.var"), show.variables = get_formal_data(bm.out, "expl.var.names"), fixed.var = "mean", do.bivariate = FALSE, do.plot = TRUE, do.progress = TRUE, ... )bm_PlotResponseCurves( bm.out, models.chosen = "all", new.env = get_formal_data(bm.out, "expl.var"), show.variables = get_formal_data(bm.out, "expl.var.names"), fixed.var = "mean", do.bivariate = FALSE, do.plot = TRUE, do.progress = TRUE, ... )
bm.out |
a |
models.chosen |
a |
new.env |
a |
show.variables |
a |
fixed.var |
a |
do.bivariate |
(optional, default |
do.plot |
(optional, default |
do.progress |
(optional, default |
... |
some additional arguments (see Details) |
This function is an adaptation of the Evaluation Strip method proposed by Elith et al. (2005). To build the predicted response curves :
n-1 variables are set constant to a fixed value determined by the
fixed.var parameter (in the case of categorical variable, the most represented
class is taken)
the remaining variable is made to vary throughout its range given by the new.env
parameter
predicted values are computed with these n-1 fixed variables, and this
studied variable varying
If do.bivariate = TRUE, 2 variables are varying at the same time.
The response curves obtained show the sensibility of the model to the studied variable.
Note that this method does not account for interactions between variables.
... can take the following values :
main : a character corresponding to the graphic title
A list containing a data.frame with variables and predicted values and the
corresponding ggplot object representing response curves.
Damien Georges, Maya Guéguen
Elith J, Ferrier S, Huettmann F, Leathwick JR (2005). The evaluation strip: A new and robust method for plotting predicted responses from species distribution models. Ecological Modelling, 186, 280-289. doi:10.1016/j.ecolmodel.2004.12.007
BIOMOD.models.out, BIOMOD.ensemble.models.out,
BIOMOD_Modeling, BIOMOD_EnsembleModeling
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_ModelAnalysis(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotVarImpBoxplot()
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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Represent response curves mods <- get_built_models(myBiomodModelOut, run = 'RUN1') bm_PlotResponseCurves(bm.out = myBiomodModelOut, models.chosen = mods, fixed.var = 'median') ## fixed.var can also be set to 'min', 'max' or 'mean' # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'min') # Bivariate case (one model) # variables can be selected with argument 'show.variables' # models can be selected with argument 'models.chosen' mods <- get_built_models(myBiomodModelOut, full.name = 'GuloGulo_allData_RUN2_RF') bm_PlotResponseCurves(bm.out = myBiomodModelOut, show.variables = c("bio4","bio12","bio11"), models.chosen = mods, fixed.var = 'median', do.bivariate = TRUE)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) # ---------------------------------------------------------------# file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } # ---------------------------------------------------------------# # Represent response curves mods <- get_built_models(myBiomodModelOut, run = 'RUN1') bm_PlotResponseCurves(bm.out = myBiomodModelOut, models.chosen = mods, fixed.var = 'median') ## fixed.var can also be set to 'min', 'max' or 'mean' # bm_PlotResponseCurves(bm.out = myBiomodModelOut, # models.chosen = mods, # fixed.var = 'min') # Bivariate case (one model) # variables can be selected with argument 'show.variables' # models can be selected with argument 'models.chosen' mods <- get_built_models(myBiomodModelOut, full.name = 'GuloGulo_allData_RUN2_RF') bm_PlotResponseCurves(bm.out = myBiomodModelOut, show.variables = c("bio4","bio12","bio11"), models.chosen = mods, fixed.var = 'median', do.bivariate = TRUE)
This function represents boxplot of variables importance of species distribution
models, from BIOMOD.models.out or BIOMOD.ensemble.models.out
objects that can be obtained from BIOMOD_Modeling or
BIOMOD_EnsembleModeling functions. Scores are represented according to 3
grouping methods (see Details).
bm_PlotVarImpBoxplot( bm.out, group.by = c("run", "expl.var", "algo"), do.plot = TRUE, ... )bm_PlotVarImpBoxplot( bm.out, group.by = c("run", "expl.var", "algo"), do.plot = TRUE, ... )
bm.out |
a |
group.by |
a 3-length |
do.plot |
(optional, default |
... |
some additional arguments (see Details) |
... can take the following values :
main : a character corresponding to the graphic title
A list containing a data.frame with variables importance and the corresponding
ggplot object representing them in boxplot.
Damien Georges, Maya Guéguen
BIOMOD.models.out, BIOMOD.ensemble.models.out,
BIOMOD_Modeling, BIOMOD_EnsembleModeling,
get_variables_importance
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
Other Plot functions:
bm_ModelAnalysis(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves()
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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get variables importance get_variables_importance(myBiomodModelOut) # Represent variables importance bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'algo')) bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'PA')) bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'expl.var', 'PA'))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) # --------------------------------------------------------------- file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS','ROC'), var.import = 3, seed.val = 42) } # --------------------------------------------------------------- # Get variables importance get_variables_importance(myBiomodModelOut) # Represent variables importance bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'algo')) bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('expl.var', 'algo', 'PA')) bm_PlotVarImpBoxplot(bm.out = myBiomodModelOut, group.by = c('algo', 'expl.var', 'PA'))
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, strategy, nb.rep = NULL, nb.absences = NULL, sre.quant = NULL, 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 signature 'ANY,SpatVector' bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table) ## S4 method for signature 'ANY,SpatRaster' bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table) bm_PseudoAbsences_random(resp.var, expl.var, ...) ## S4 method for signature 'ANY,SpatVector' bm_PseudoAbsences_random(resp.var, expl.var, nb.absences, nb.rep, fact.aggr) ## S4 method for signature '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 signature 'ANY,SpatVector' bm_PseudoAbsences_sre(resp.var, expl.var, sre.quant, nb.absences, nb.rep) ## S4 method for signature '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 signature 'ANY,SpatVector' bm_PseudoAbsences_disk( resp.var, expl.var, dist.min, dist.max, nb.absences, nb.rep, fact.aggr ) ## S4 method for signature 'ANY,SpatRaster' bm_PseudoAbsences_disk( resp.var, expl.var, dist.min, dist.max, nb.absences, nb.rep, fact.aggr )bm_PseudoAbsences( resp.var, expl.var, strategy, nb.rep = NULL, nb.absences = NULL, sre.quant = NULL, 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 signature 'ANY,SpatVector' bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table) ## S4 method for signature 'ANY,SpatRaster' bm_PseudoAbsences_user.defined(resp.var, expl.var, user.table) bm_PseudoAbsences_random(resp.var, expl.var, ...) ## S4 method for signature 'ANY,SpatVector' bm_PseudoAbsences_random(resp.var, expl.var, nb.absences, nb.rep, fact.aggr) ## S4 method for signature '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 signature 'ANY,SpatVector' bm_PseudoAbsences_sre(resp.var, expl.var, sre.quant, nb.absences, nb.rep) ## S4 method for signature '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 signature 'ANY,SpatVector' bm_PseudoAbsences_disk( resp.var, expl.var, dist.min, dist.max, nb.absences, nb.rep, fact.aggr ) ## S4 method for signature 'ANY,SpatRaster' bm_PseudoAbsences_disk( resp.var, expl.var, dist.min, dist.max, nb.absences, nb.rep, fact.aggr )
resp.var |
a |
expl.var |
a |
strategy |
a |
nb.rep |
(optional, default |
nb.absences |
(optional, default |
sre.quant |
(optional, default |
dist.min |
(optional, default |
dist.max |
(optional, default |
fact.aggr |
(optional, default |
user.table |
(optional, default |
seed.val |
(optional, default |
... |
(optional, one or several of the listed above arguments depending on the selected method) |
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).
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)
Wilfried Thuiller, Damien Georges
bm_SRE, BIOMOD.formated.data.PA,
BIOMOD_FormatingData
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
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) # --------------------------------------------------------------- # # 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)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) # --------------------------------------------------------------- # # 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)
This function allows to calculate the absolute number of locations (pixels) lost, stable and gained, as well as the corresponding relative proportions, between two (or more) binary projections of (ensemble) species distribution models (which can represent new time scales or environmental scenarios for example).
bm_RangeSize(proj.current, proj.future, ordinal = FALSE) ## S4 method for signature 'data.frame,data.frame' bm_RangeSize(proj.current, proj.future, ordinal = FALSE) ## S4 method for signature 'SpatRaster,SpatRaster' bm_RangeSize(proj.current, proj.future, ordinal = FALSE)bm_RangeSize(proj.current, proj.future, ordinal = FALSE) ## S4 method for signature 'data.frame,data.frame' bm_RangeSize(proj.current, proj.future, ordinal = FALSE) ## S4 method for signature 'SpatRaster,SpatRaster' bm_RangeSize(proj.current, proj.future, ordinal = FALSE)
proj.current |
a |
proj.future |
a |
ordinal |
a |
Note that this function is only relevant to compare binary projections, made on the
same area with the same resolution.
Comparison between proj.current and proj.future depends
on the number of projection in both objects:
| proj.current | proj.future | Comparison |
| ————————- | ———————- | ——————– |
| 1 projection (e.g. data.frame with 1 column, SpatRaster with 1 layer) | 1 projection (e.g. data.frame with 1 column, SpatRaster with 1 layer) | comparison of both projection (e.g. current vs future conditions for the same model ; current vs current condition for two different models) |
| n projections (e.g. data.frame with n column, SpatRaster with n layer) | n projections (e.g. data.frame with n column, SpatRaster with n layer) | comparing projection i in proj.current to projection i in proj.future (e.g. comparing current vs future condition for n models) |
| 1 projection (e.g. data.frame with 1 column, SpatRaster with 1 layer) | n projections (e.g. data.frame with n column, SpatRaster with n layer) | comparing projection in proj.current to each projection in proj.future (e.g. comparing current vs n different future condition (e.g. climate change scenario) for 1 model) |
For binary data,Diff.By.Pixel object is obtained by applying the simple following formula :
For non binary data, Diff.By.Pixel object is obtained by rescaling the two projection to a 0 to 1 scale
and applying the simple following formula :
A list containing two objects :
a data.frame containing the summary of range change for each
comparison
Loss : number of pixels predicted to be lost
Stable_Abs : number of pixels not currently occupied and not predicted to be
Stable_Pres : number of pixels currently occupied and predicted to remain
occupied
Gain : number of pixels predicted to be gained
PercLoss : percentage of pixels currently occupied and predicted to be lost
(Loss / (Loss + Stable_Pres))
PercGain : percentage of pixels predicted to be gained compare to the
number of pixels currently occupied (Gain / (Loss + Stable_Pres))
SpeciesRangeChange : percentage of pixels predicted to change (loss or gain)
compare to the number of pixels currently occupied (PercGain - PercLoss)
CurrentRangeSize : number of pixels currently occupied
FutureRangeSize0Disp : number of pixels predicted to be occupied, assuming
no migration
FutureRangeSize1Disp : number of pixels predicted to be occupied, assuming
migration
an object in the same form than the input data (proj.current and
proj.future) and containing a value for each point/pixel of each comparison among :
-2 : predicted to be lost
-1 : predicted to remain occupied
0 : predicted to remain unoccupied
1 : predicted to be gained
an object in the same form than the input data (proj.current and
proj.future) and containing a value for each point/pixel of each comparison obtain with :
Future - 2* Current for binary data
Future - Current for nonbinary
Wilfried Thuiller, Damien Georges, Bruno Lafourcade
BIOMOD_Projection, BIOMOD_EnsembleForecasting,
bm_PlotRangeSize
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all', build.clamping.mask = TRUE) # --------------------------------------------------------------- # # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Load current and future binary projections CurrentProj <- get_predictions(myBiomodProj, metric.binary = "TSS", model.as.col = TRUE) FutureProj <- get_predictions(myBiomodProjectionFuture, metric.binary = "TSS", model.as.col = TRUE) # Compute differences myBiomodRangeSize <- bm_RangeSize(proj.current = CurrentProj, proj.future = FutureProj) myBiomodRangeSize$Compt.By.Models plot(myBiomodRangeSize$Diff.By.Pixel)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) # --------------------------------------------------------------- # file.out <- paste0(myRespName, "/", myRespName, ".AllModels.models.out") if (file.exists(file.out)) { myBiomodModelOut <- get(load(file.out)) } else { # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # Model single models myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData, modeling.id = 'AllModels', models = c('RF', 'GLM'), CV.strategy = 'random', CV.nb.rep = 2, CV.perc = 0.8, OPT.strategy = 'bigboss', metric.eval = c('TSS', 'ROC'), var.import = 3, seed.val = 42) } models.proj <- get_built_models(myBiomodModelOut, algo = "RF") # Project single models myBiomodProj <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'CurrentRangeSize', new.env = myExpl, models.chosen = models.proj, metric.binary = 'all', build.clamping.mask = TRUE) # --------------------------------------------------------------- # # Load environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12) data(bioclim_future) myExplFuture <- terra::rast(bioclim_future) # Project onto future conditions myBiomodProjectionFuture <- BIOMOD_Projection(bm.mod = myBiomodModelOut, proj.name = 'FutureRangeSize', new.env = myExplFuture, models.chosen = models.proj, metric.binary = 'TSS') # Load current and future binary projections CurrentProj <- get_predictions(myBiomodProj, metric.binary = "TSS", model.as.col = TRUE) FutureProj <- get_predictions(myBiomodProjectionFuture, metric.binary = "TSS", model.as.col = TRUE) # Compute differences myBiomodRangeSize <- bm_RangeSize(proj.current = CurrentProj, proj.future = FutureProj) myBiomodRangeSize$Compt.By.Models plot(myBiomodRangeSize$Diff.By.Pixel)
This internal biomod2 function allows the user to compute all single
species distribution models (asked by the BIOMOD_Modeling function).
bm_RunModelsLoop( bm.format, modeling.id, models, models.pa, calib.lines, bm.options, metric.eval, var.import, weights, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE ) bm_RunModel( model, run.name, dir.name = ".", modeling.id = "", Data, bm.options, calib.lines.vec, eval.data = NULL, metric.eval = c("AUCroc", "TSS", "KAPPA"), var.import = 0, weights.vec, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE )bm_RunModelsLoop( bm.format, modeling.id, models, models.pa, calib.lines, bm.options, metric.eval, var.import, weights, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE ) bm_RunModel( model, run.name, dir.name = ".", modeling.id = "", Data, bm.options, calib.lines.vec, eval.data = NULL, metric.eval = c("AUCroc", "TSS", "KAPPA"), var.import = 0, weights.vec, scale.models = FALSE, nb.cpu = 1, seed.val = NULL, do.progress = TRUE )
bm.format |
a |
modeling.id |
a |
models |
a |
models.pa |
(optional, default |
calib.lines |
a |
bm.options |
a |
metric.eval |
a |
var.import |
(optional, default |
weights |
a |
scale.models |
(optional, default |
nb.cpu |
(optional, default |
seed.val |
(optional, default |
do.progress |
(optional, default |
model |
a |
run.name |
a |
dir.name |
(optional, default |
Data |
a |
calib.lines.vec |
a |
eval.data |
(optional, default |
weights.vec |
a |
A list containing for each model a list containing the following elements :
model : the name of correctly computed model
calib.failure : the name of incorrectly computed model
pred : the prediction outputs for calibration data
pred.eval : the prediction outputs for evaluation data
evaluation : the evaluation outputs returned by the
bm_FindOptimStat function
var.import : the mean of variables importance returned by the
bm_VariablesImportance function
Damien Georges
rpart, prune, gbm,
nnet, earth,
fda, mars, maxnet,
randomForest, xgboost,
bm_ModelingOptions, BIOMOD_Modeling,
bm_MakeFormula, bm_SampleFactorLevels,
bm_FindOptimStat, bm_VariablesImportance
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
This internal biomod2 function allows the user to sample a binary vector
keeping the same proportion of 0 and 1 as the initial vector.
bm_SampleBinaryVector(obs, ratio, as.logical = FALSE, seedval = NULL)bm_SampleBinaryVector(obs, ratio, as.logical = FALSE, seedval = NULL)
obs |
a |
ratio |
a |
as.logical |
(optional, default |
seedval |
(optional, default |
A list containing the following elements :
calibration : elements selected for calibration
validation : elements selected for validation (complementary to the
calibration set)
Damien Georges
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
## Generate a binary vector vec.a <- sample(c(0, 1), 100, replace = TRUE) ## Generate calibration / validation datasets bm_SampleBinaryVector(obs = vec.a, ratio = 0.7)## Generate a binary vector vec.a <- sample(c(0, 1), 100, replace = TRUE) ## Generate calibration / validation datasets bm_SampleBinaryVector(obs = vec.a, ratio = 0.7)
This internal biomod2 function allows the user to sample all levels of all
the factorial variables contained in a data.frame or SpatRaster
object.
bm_SampleFactorLevels(expl.var, mask.out = NULL, mask.in = NULL)bm_SampleFactorLevels(expl.var, mask.out = NULL, mask.in = NULL)
expl.var |
a |
mask.out |
a |
mask.in |
a |
The expl.var, mask.out and mask.in parameters must be coherent in terms of
dimensions :
same number of rows for data.frame objects
same resolution, projection system and number of cells for SpatRaster objects
If mask.in contains several columns (data.frame) or layers
(SpatRaster), then their order matters :
they will be considered successively to sample missing factor levels.
Values in data.frame will be understood as :
FALSE : out of mask
TRUE : in mask
Values in SpatRaster will be understood as :
NA : out of mask
not NA : in mask
A vector of numeric values corresponding to either row (data.frame) or
cell (SpatRaster) numbers, each referring to a single level of a
single factorial variable.
In case no factorial variable is found in the input object, NULL is returned.
Damien Georges
bm_PseudoAbsences, bm_CrossValidation
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_Tuning(),
bm_VariablesImportance()
library(terra) ## Create raster data ras.1 <- ras.2 <- mask.out <- rast(nrows = 10, ncols = 10) ras.1[] <- as.factor(rep(c(1, 2, 3, 4, 5), each = 20)) ras.1 <- as.factor(ras.1) ras.2[] <- rnorm(100) stk <- c(ras.1, ras.2) names(stk) <- c("varFact", "varNorm") ## define a mask for already sampled points mask.out[1:40] <- 1 ## define a list of masks where we want to sample in priority mask.in <- list(ras.1, ras.1) mask.in[[1]][1:80] <- NA ## only level 5 should be sampled in this mask mask.in[[1]][21:80] <- NA ## only levels 1 and 5 should be sampled in this mask ## Sample all factor levels samp1 <- bm_SampleFactorLevels(expl.var = stk, mask.out = mask.out) samp2 <- bm_SampleFactorLevels(expl.var = stk, mask.in = mask.in) samp3 <- bm_SampleFactorLevels(expl.var = stk, mask.out = mask.out, mask.in = mask.in)library(terra) ## Create raster data ras.1 <- ras.2 <- mask.out <- rast(nrows = 10, ncols = 10) ras.1[] <- as.factor(rep(c(1, 2, 3, 4, 5), each = 20)) ras.1 <- as.factor(ras.1) ras.2[] <- rnorm(100) stk <- c(ras.1, ras.2) names(stk) <- c("varFact", "varNorm") ## define a mask for already sampled points mask.out[1:40] <- 1 ## define a list of masks where we want to sample in priority mask.in <- list(ras.1, ras.1) mask.in[[1]][1:80] <- NA ## only level 5 should be sampled in this mask mask.in[[1]][21:80] <- NA ## only levels 1 and 5 should be sampled in this mask ## Sample all factor levels samp1 <- bm_SampleFactorLevels(expl.var = stk, mask.out = mask.out) samp2 <- bm_SampleFactorLevels(expl.var = stk, mask.in = mask.in) samp3 <- bm_SampleFactorLevels(expl.var = stk, mask.out = mask.out, mask.in = mask.in)
This internal biomod2 function allows the user to run a rectilinear surface range envelop (SRE) (equivalent to BIOCLIM) using the extreme percentiles (as recommended by Nix or Busby, see References and Details).
bm_SRE( resp.var = NULL, expl.var = NULL, new.env = NULL, quant = 0.025, do.extrem = FALSE )bm_SRE( resp.var = NULL, expl.var = NULL, new.env = NULL, quant = 0.025, do.extrem = FALSE )
resp.var |
a |
expl.var |
a |
new.env |
a |
quant |
a |
do.extrem |
(optional, default |
Please refer to References to get more information about surface range envelop models.
This method is highly influenced by the extremes of the data input. Whereas a linear model
can discriminate the extreme values from the main tendency, the SRE considers them as
important as any other data point leading to changes in predictions.
The more (non-collinear) variables, the more restrictive the model will be.
Predictions are returned as binary (0 or 1) values, a site being either
potentially suitable for all the variables, or out of bounds for at least one variable and
therefore considered unsuitable.
quant determines the threshold from which the data will be taken into account for
calibration. The default value of 0.05 induces that the 5% most extreme values
will be avoided for each variable on each side of its distribution along the gradient, meaning
that a total of 10% of the data will not be considered.
A vector or a SpatRaster object, containing binary
(0 or 1) values.
Wilfried Thuiller, Bruno Lafourcade, Damien Georges
Nix HA (1986). A biogeographic analysis of Australian elapid snakes. In: Atlas of Elapid Snakes of Australia. (Ed.) R. Longmore, pp. 4-15. Australian Flora and Fauna Series Number 7. Australian Government Publishing Service: Canberra.
Busby J (1991). BIOCLIM - a bioclimate analysis and prediction system. Plant protection quarterly, 6, 8-9.
bm_PseudoAbsences, BIOMOD_FormatingData,
bm_ModelingOptions, bm_Tuning,
bm_RunModelsLoop, BIOMOD_Modeling,
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning(),
bm_VariablesImportance()
library(terra) ## Load real data data(DataSpecies) myResp.r <- as.numeric(DataSpecies[, 'GuloGulo']) data(bioclim_current) myExpl.r <- rast(bioclim_current) myRespXY <- DataSpecies[which(myResp.r == 1), c('X_WGS84', 'Y_WGS84')] myResp.v <- classify(subset(myExpl.r, 1), matrix(c(-Inf, Inf, 0), ncol = 3, byrow = TRUE)) myResp.v[cellFromXY(myResp.v, myRespXY)] <- 1 ## Compute SRE for several quantile values sre.100 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0) sre.095 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0.025) sre.090 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0.05) ## Visualize results res <- c(myResp.v, sre.100, sre.095, sre.090) names(res) <- c("Original distribution", "Full data calibration" , "Over 95 percent", "Over 90 percent") plot(res)library(terra) ## Load real data data(DataSpecies) myResp.r <- as.numeric(DataSpecies[, 'GuloGulo']) data(bioclim_current) myExpl.r <- rast(bioclim_current) myRespXY <- DataSpecies[which(myResp.r == 1), c('X_WGS84', 'Y_WGS84')] myResp.v <- classify(subset(myExpl.r, 1), matrix(c(-Inf, Inf, 0), ncol = 3, byrow = TRUE)) myResp.v[cellFromXY(myResp.v, myRespXY)] <- 1 ## Compute SRE for several quantile values sre.100 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0) sre.095 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0.025) sre.090 <- bm_SRE(resp.var = myResp.v, expl.var = myExpl.r, new.env = myExpl.r, quant = 0.05) ## Visualize results res <- c(myResp.v, sre.100, sre.095, sre.090) names(res) <- c("Original distribution", "Full data calibration" , "Over 95 percent", "Over 90 percent") plot(res)
This internal biomod2 function allows to tune single model parameters and select more efficient ones based on an evaluation metric.
bm_Tuning( model, tuning.fun, do.formula = FALSE, do.stepAIC = FALSE, bm.options, bm.format, calib.lines = NULL, metric.eval = "TSS", metric.AIC = "AIC", weights = NULL, ctrl.train = NULL, params.train = list(ANN.size = c(2, 4, 6, 8), ANN.decay = c(0.01, 0.05, 0.1), ANN.bag = FALSE, DNN.hidden = list(depth = 3, width = 100), DNN.bias = TRUE, DNN.lambda = 0.001, DNN.alpha = 1, DNN.lr = c(1e-04, 0.1), DNN.batchsize = 100, DNN.epochs = 150, FDA.degree = 1:2, FDA.nprune = 2:25, GAM.select = c(TRUE, FALSE), GAM.method = c("GCV.Cp", "GACV.Cp", "REML", "P-REML", "ML", "P-ML"), GAM.span = c(0.3, 0.5, 0.7), GAM.degree = 1, GBM.n.trees = c(500, 1000, 2500), GBM.interaction.depth = seq(2, 8, by = 3), GBM.shrinkage = c(0.001, 0.01, 0.1), GBM.n.minobsinnode = 10, MARS.degree = 1:2, MARS.nprune = 2:max(21, 2 * ncol([email protected]) + 1), MAXENT.algorithm = "maxnet", MAXENT.parallel = TRUE, MAXENT.tune.args = list(rm = seq(0.5, 1, 0.5), fc = c("L")), MAXENT.partitions = "randomkfold", MAXENT.kfolds = 10, MAXENT.user.grp = NULL, RF.mtry = 1:min(10, ncol([email protected])), RFd.mtry = 1:min(10, ncol([email protected])), SRE.quant = c(0, 0.0125, 0.025, 0.05, 0.1), XGBOOST.nrounds = 50, XGBOOST.max_depth = 1, XGBOOST.eta = c(0.3, 0.4), XGBOOST.gamma = 0, XGBOOST.colsample_bytree = c(0.6, 0.8), XGBOOST.min_child_weight = 1, XGBOOST.subsample = 0.5) )bm_Tuning( model, tuning.fun, do.formula = FALSE, do.stepAIC = FALSE, bm.options, bm.format, calib.lines = NULL, metric.eval = "TSS", metric.AIC = "AIC", weights = NULL, ctrl.train = NULL, params.train = list(ANN.size = c(2, 4, 6, 8), ANN.decay = c(0.01, 0.05, 0.1), ANN.bag = FALSE, DNN.hidden = list(depth = 3, width = 100), DNN.bias = TRUE, DNN.lambda = 0.001, DNN.alpha = 1, DNN.lr = c(1e-04, 0.1), DNN.batchsize = 100, DNN.epochs = 150, FDA.degree = 1:2, FDA.nprune = 2:25, GAM.select = c(TRUE, FALSE), GAM.method = c("GCV.Cp", "GACV.Cp", "REML", "P-REML", "ML", "P-ML"), GAM.span = c(0.3, 0.5, 0.7), GAM.degree = 1, GBM.n.trees = c(500, 1000, 2500), GBM.interaction.depth = seq(2, 8, by = 3), GBM.shrinkage = c(0.001, 0.01, 0.1), GBM.n.minobsinnode = 10, MARS.degree = 1:2, MARS.nprune = 2:max(21, 2 * ncol(bm.format@data.env.var) + 1), MAXENT.algorithm = "maxnet", MAXENT.parallel = TRUE, MAXENT.tune.args = list(rm = seq(0.5, 1, 0.5), fc = c("L")), MAXENT.partitions = "randomkfold", MAXENT.kfolds = 10, MAXENT.user.grp = NULL, RF.mtry = 1:min(10, ncol(bm.format@data.env.var)), RFd.mtry = 1:min(10, ncol(bm.format@data.env.var)), SRE.quant = c(0, 0.0125, 0.025, 0.05, 0.1), XGBOOST.nrounds = 50, XGBOOST.max_depth = 1, XGBOOST.eta = c(0.3, 0.4), XGBOOST.gamma = 0, XGBOOST.colsample_bytree = c(0.6, 0.8), XGBOOST.min_child_weight = 1, XGBOOST.subsample = 0.5) )
model |
a |
tuning.fun |
a |
do.formula |
(optional, default |
do.stepAIC |
(optional, default |
bm.options |
a |
bm.format |
a |
calib.lines |
(optional, default |
metric.eval |
a |
metric.AIC |
a |
weights |
(optional, default |
ctrl.train |
(optional, default |
params.train |
a |
Concerning ctrl.train parameter :
Set by default to :
ctrl.train <- caret::trainControl(method = "repeatedcv", repeats = 3, number = 10, summaryFunction = caret::twoClassSummary, classProbs = TRUE, returnData = FALSE)
Concerning params.train parameter :
All elements of the list must have names matching model.parameter_name format,
parameter_name being one of the parameter of the tuning.fun function called by
caret package and that can be found through the getModelInfo
function.
Currently, the available parameters to be tuned are the following :
size, decay, bag
maxdepth
hidden , bias, lambda, alpha, lr, batchsize, 150
degree, nprune
span, degree
select, method
n.trees, interaction.depth, shrinkage, n.minobsinnode
degree, nprune
algorithm,tune.args, parallel, partitions, kfolds,
user.grp
mtry
mtry
quant
nrounds, max_depth, eta, gamma,
colsampl_bytree, min_child_weight, subsample
The expand.grid function is used to build a matrix containing all
combinations of parameters to be tested.
A BIOMOD.models.options object (see bm_ModelingOptions) with
optimized parameters
No tuning for GLM and MAXNET
MAXENT is tuned through ENMevaluate function which is
calling either :
maxnet (by defining MAXENT.algorithm = 'maxnet') (default)
Java version of Maxent defined in dismo package (by defining
MAXENT.algorithm = 'maxent.jar')
DNN is tuned through tune function.
The values include in params.train are the lower or upper range which hyperparameters are sampled.
If there is only one value, the hyperparameter is fixed by biomod2 (inclunding the width and depth of hidden parameters.)
SRE is tuned through bm_SRE function
All other models are tuned through train function
No optimization of formula for DNN, MAXENT, MAXNET, SRE and
XGBOOST
No interaction included in formula for CTA
Variables selection only for GAM.gam and GLM
Frank Breiner, Maya Guéguen, Hélène Blancheteau
trainControl, train,
ENMevaluate,
ModelsTable, BIOMOD.models.options,
bm_ModelingOptions, BIOMOD_Modeling
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
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) # --------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # --------------------------------------------------------------- # # List of all models currently available in `biomod2` (and their related package and function) # Some of them can be tuned through the `train` function of the `caret` package # (and corresponding training function to be used is indicated) data(ModelsTable) ModelsTable allModels <- c('ANN', 'CTA', 'FDA', 'GAM', 'GBM', 'GLM' , 'MARS', 'MAXENT', 'MAXNET', 'RF', 'SRE', 'XGBOOST') # default parameters opt.d <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default') # tune parameters for Random Forest model tuned.rf <- bm_Tuning(model = 'RF', tuning.fun = 'rf', ## see in ModelsTable do.formula = FALSE, bm.options = opt.d@options$RF.binary.randomForest.randomForest, bm.format = myBiomodData) tuned.rf ## Not run: # tune parameters for GAM (from mgcv package) model tuned.gam <- bm_Tuning(model = 'GAM', tuning.fun = 'gam', ## see in ModelsTable do.formula = TRUE, do.stepAIC = TRUE, bm.options = opt.d@options$GAM.binary.mgcv.gam, bm.format = myBiomodData) tuned.gam ## End(Not run)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) # --------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) # --------------------------------------------------------------- # # List of all models currently available in `biomod2` (and their related package and function) # Some of them can be tuned through the `train` function of the `caret` package # (and corresponding training function to be used is indicated) data(ModelsTable) ModelsTable allModels <- c('ANN', 'CTA', 'FDA', 'GAM', 'GBM', 'GLM' , 'MARS', 'MAXENT', 'MAXNET', 'RF', 'SRE', 'XGBOOST') # default parameters opt.d <- bm_ModelingOptions(data.type = 'binary', models = allModels, strategy = 'default') # tune parameters for Random Forest model tuned.rf <- bm_Tuning(model = 'RF', tuning.fun = 'rf', ## see in ModelsTable do.formula = FALSE, bm.options = opt.d@options$RF.binary.randomForest.randomForest, bm.format = myBiomodData) tuned.rf ## Not run: # tune parameters for GAM (from mgcv package) model tuned.gam <- bm_Tuning(model = 'GAM', tuning.fun = 'gam', ## see in ModelsTable do.formula = TRUE, do.stepAIC = TRUE, bm.options = opt.d@options$GAM.binary.mgcv.gam, bm.format = myBiomodData) tuned.gam ## End(Not run)
This internal biomod2 function allows the user to compute a variable importance value for each variable involved in the given model.
bm_VariablesImportance( bm.model, expl.var, variables = NULL, method = "full_rand", nb.rep = 1, seed.val = NULL, do.progress = TRUE, temp.workdir = NULL )bm_VariablesImportance( bm.model, expl.var, variables = NULL, method = "full_rand", nb.rep = 1, seed.val = NULL, do.progress = TRUE, temp.workdir = NULL )
bm.model |
a |
expl.var |
a |
variables |
(optional, default |
method |
a |
nb.rep |
an |
seed.val |
(optional, default |
do.progress |
(optional, default |
temp.workdir |
(optional, default |
For each variable to be evaluated :
shuffle the original variable
compute model prediction with shuffled variable
calculate Pearson's correlation between reference and shuffled predictions
return score as 1 - cor
The highest the value, the less reference and shuffled predictions are correlated, and the
more influence the variable has on the model. A value of 0 assumes no influence of
the variable on the model.
Note that this calculation does not account for variables' interactions.
The same principle is used in randomForest.
A 3 columns data.frame containing variable's importance scores for each
permutation run :
expl.var : the considered explanatory variable (the one permuted)
rand : the ID of the permutation run
var.imp : the variable's importance score
Damien Georges
randomForest,
bm_RunModelsLoop, BIOMOD_Modeling,
BIOMOD_EnsembleModeling, bm_PlotVarImpBoxplot,
get_variables_importance
Other Secondary functions:
bm_BinaryTransformation(),
bm_CrossValidation(),
bm_FindOptimStat(),
bm_MakeFormula(),
bm_ModelAnalysis(),
bm_ModelingOptions(),
bm_PlotEvalBoxplot(),
bm_PlotEvalMean(),
bm_PlotRangeSize(),
bm_PlotResponseCurves(),
bm_PlotVarImpBoxplot(),
bm_PseudoAbsences(),
bm_RangeSize(),
bm_RunModelsLoop(),
bm_SRE(),
bm_SampleBinaryVector(),
bm_SampleFactorLevels(),
bm_Tuning()
## Create simple simulated data myResp.s <- sample(c(0, 1), 20, replace = TRUE) myExpl.s <- data.frame(var1 = sample(c(0, 1), 100, replace = TRUE), var2 = rnorm(100), var3 = 1:100) ## Compute variables importance mod <- glm(var1 ~ var2 + var3, data = myExpl.s) bm_VariablesImportance(bm.model = mod, expl.var = myExpl.s[, c('var2', 'var3')], method = "full_rand", nb.rep = 3)## Create simple simulated data myResp.s <- sample(c(0, 1), 20, replace = TRUE) myExpl.s <- data.frame(var1 = sample(c(0, 1), 100, replace = TRUE), var2 = rnorm(100), var3 = 1:100) ## Compute variables importance mod <- glm(var1 ~ var2 + var3, data = myExpl.s) bm_VariablesImportance(bm.model = mod, expl.var = myExpl.s[, c('var2', 'var3')], method = "full_rand", nb.rep = 3)
A dataset covering all the continent with presence/absence data for 6 mammal species. Presence/absence were derived from range maps downloaded at IUCN.
DataSpeciesDataSpecies
A data.frame object with 2488 rows and 10 variables:
Longitude
Latitude
Presence (1) or Absence (0) for black wildebeest
Presence (1) or Absence (0) for wolverine
Presence (1) or Absence (0) for jaguar
Presence (1) or Absence (0) for Indian flying fox
Presence (1) or Absence (0) for tailless tenrec
Presence (1) or Absence (0) for red fox
A dataset covering France with abundance data for 20 bird species. Data comes from the French Breeding Bird Survey (STOC program) of Vigie-Nature (Fontaine et al. 2020). The original dataset contains 2,948 sites in which bird species have been observed from 2001 to 2024. Original raw data is not provided here, but might be made available on request by contacting Benoît Fontaine (benoit.fontaine [at] mnhn.fr).
DataSTOCDataSTOC
A data.frame object with 2006 rows and 30 columns (10 variables and 20 species):
Observation site ID
yearly average headcounts have been computed over 2 times periods: 2006-2011 and 2012-2017
Longitude
Latitude
annual mean temperature (CHELSA)
annual mean precipitation (CHELSA)
percentage of agricultural habitat cover around each point (European Union’s Copernicus Land Monitoring Service information)
percentage of water habitat cover around each point (European Union’s Copernicus Land Monitoring Service information)
percentage of wetland habitat cover around each point (European Union’s Copernicus Land Monitoring Service information)
Shannon habitat diversity (CORINE)
abundance data for Eurasian skylark
abundance data for Cetti's warbler
abundance data for hawfinch
abundance data for common cuckoo
abundance data for corn bunting
abundance data for yellowhammer
abundance data for European robin
abundance data for Eurasian coot
abundance data for common nightingale
abundance data for house sparrow
abundance data for grey partridge
abundance data for coal tit
abundance data for western Bonelli's warbler
abundance data for willow warbler
abundance data for goldcrest
abundance data for European serin
abundance data for Eurasian nuthatch
abundance data for Eurasian collared dove
abundance data for Sardinian warbler
abundance data for song thrush
STOC EPS - Vigie-Nature (2025). French Breeding Bird Monitoring Scheme. Muséum National d’Histoire Naturelle (MNHN) - Office Français pour la Biodiversité (OFB) - Ligue pour la Protection des Oiseaux (LPO).
Fontaine B, Moussy C, Chiffard Carricaburu J, Dupuis J, Corolleur E, Schmaltz L, Lorrillière R, Loïs G, Gaudard C (2020). Suivi des oiseaux communs en France 1989-2019 : 30 ans de suivis participatifs. MNHN - Centre d'Ecologie et des Sciences de la Conservation, LPO BirdLife France - Service Connaissance, Ministère de la Transition écologique et solidaire. 46 pp.
Brun P, Zimmermann NE, Hari C, Pellissier L, Karger DN (2022). CHELSA-BIOCLIM+ A novel set of global climate-related predictors at kilometre-resolution. EnviDat. doi:10.16904/envidat.332
CORINE Land Cover 2018 (raster 100 m), Europe, 6-yearly - version 2020_20u1, May 2020. European Environment Agency. doi:10.2909/960998c1-1870-4e82-8051-6485205ebbac
biomod2_model objectsThese functions allow the user to easily retrieve single models (formal or scaled)
from biomod2_model objects from the modeling step.
## S4 method for signature 'biomod2_model' get_formal_model(object) ## S4 method for signature 'biomod2_model' get_scaling_model(object)## S4 method for signature 'biomod2_model' get_formal_model(object) ## S4 method for signature 'biomod2_model' get_scaling_model(object)
object |
a |
get_formal_modelan object from the model slot of a
biomod2_model object
get_scaling_modelan object from the scaling_model slot of a
biomod2_model object
Damien Georges
Other Toolbox functions:
getters.out,
load_stored_object(),
predict.bm,
predict.em,
predict2.bm,
predict2.em,
setters
BIOMOD.models.out,
BIOMOD.projection.out or BIOMOD.ensemble.models.out objectsThese functions allow the user to easily retrieve informations stored in the different biomod2 objects from the different modeling steps, such as modeling options and formated data, models used or not, predictions, evaluations, variables importance.
## S4 method for signature 'BIOMOD.formated.data' get_species_data(obj) ## S4 method for signature 'BIOMOD.formated.data.PA' get_species_data(obj) ## S4 method for signature 'BIOMOD.formated.data' get_eval_data(obj) ## S4 method for signature 'BIOMOD.models.out' get_options(obj) ## S4 method for signature 'BIOMOD.models.out' get_calib_lines(obj, as.data.frame = FALSE, PA = NULL, run = NULL) ## S4 method for signature 'BIOMOD.models.out' get_formal_data(obj, subinfo = NULL) ## S4 method for signature 'BIOMOD.models.out' get_predictions( obj, evaluation = FALSE, full.name = NULL, PA = NULL, run = NULL, algo = NULL, model.as.col = FALSE ) ## S4 method for signature 'BIOMOD.models.out' get_built_models(obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL) ## S4 method for signature 'BIOMOD.models.out' get_evaluations( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, metric.eval = NULL ) ## S4 method for signature 'BIOMOD.models.out' get_variables_importance( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, expl.var = NULL ) ## S4 method for signature 'BIOMOD.projection.out' get_projected_models( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL ) ## S4 method for signature 'BIOMOD.projection.out' free(obj) ## S4 method for signature 'BIOMOD.projection.out' get_predictions( obj, metric.binary = NULL, metric.filter = NULL, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, model.as.col = FALSE, ... ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_formal_data(obj, subinfo = NULL) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_built_models( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_kept_models(obj) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_predictions( obj, evaluation = FALSE, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, model.as.col = FALSE ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_evaluations( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, metric.eval = NULL ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_variables_importance( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, expl.var = NULL )## S4 method for signature 'BIOMOD.formated.data' get_species_data(obj) ## S4 method for signature 'BIOMOD.formated.data.PA' get_species_data(obj) ## S4 method for signature 'BIOMOD.formated.data' get_eval_data(obj) ## S4 method for signature 'BIOMOD.models.out' get_options(obj) ## S4 method for signature 'BIOMOD.models.out' get_calib_lines(obj, as.data.frame = FALSE, PA = NULL, run = NULL) ## S4 method for signature 'BIOMOD.models.out' get_formal_data(obj, subinfo = NULL) ## S4 method for signature 'BIOMOD.models.out' get_predictions( obj, evaluation = FALSE, full.name = NULL, PA = NULL, run = NULL, algo = NULL, model.as.col = FALSE ) ## S4 method for signature 'BIOMOD.models.out' get_built_models(obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL) ## S4 method for signature 'BIOMOD.models.out' get_evaluations( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, metric.eval = NULL ) ## S4 method for signature 'BIOMOD.models.out' get_variables_importance( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, expl.var = NULL ) ## S4 method for signature 'BIOMOD.projection.out' get_projected_models( obj, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL ) ## S4 method for signature 'BIOMOD.projection.out' free(obj) ## S4 method for signature 'BIOMOD.projection.out' get_predictions( obj, metric.binary = NULL, metric.filter = NULL, full.name = NULL, PA = NULL, run = NULL, algo = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, model.as.col = FALSE, ... ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_formal_data(obj, subinfo = NULL) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_built_models( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_kept_models(obj) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_predictions( obj, evaluation = FALSE, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, model.as.col = FALSE ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_evaluations( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, metric.eval = NULL ) ## S4 method for signature 'BIOMOD.ensemble.models.out' get_variables_importance( obj, full.name = NULL, merged.by.algo = NULL, merged.by.run = NULL, merged.by.PA = NULL, filtered.by = NULL, algo = NULL, expl.var = NULL )
obj |
a |
as.data.frame |
a |
PA |
(optional, default |
run |
(optional, default |
subinfo |
a |
evaluation |
a |
full.name |
(optional, default |
algo |
(optional, default |
model.as.col |
(optional, default |
metric.eval |
(optional, default |
expl.var |
(optional, default |
merged.by.algo |
(optional, default |
merged.by.run |
(optional, default |
merged.by.PA |
(optional, default |
filtered.by |
(optional, default |
metric.binary |
(optional, default |
metric.filter |
(optional, default |
... |
(optional, one or several of the following arguments depending on the selected function) |
get_species_dataa data.frame combining data.species,
coord, data.env.var (and PA.table) slots of
BIOMOD.formated.data (or BIOMOD.formated.data.PA) object
get_eval_dataa data.frame combining eval.data.species,
eval.coord, eval.data.env.var slots of
BIOMOD.formated.data or BIOMOD.formated.data.PA object
get_optionsa
BIOMOD.stored.options-class object from the
models.options slot of a BIOMOD.models.out-class
object
get_calib_linesa
BIOMOD.stored.data.frame-class object from the calib.lines
slot of a BIOMOD.models.out object
get_projected_modelsa vector from the
models.projected slot of a BIOMOD.projection.out
object
get_predictionsa BIOMOD.stored.data object
from the proj.out slot of a BIOMOD.models.out,
BIOMOD.projection.out or
BIOMOD.ensemble.models.out object
get_kept_modelsa vector containing names of the kept
models of a BIOMOD.ensemble.models.out object
get_formal_datadepending on the subinfo parameter :
NULLa BIOMOD.stored.formated.data-class (or
BIOMOD.stored.models.out-class) object from the
formated.input.data (or models.out) slot of a
BIOMOD.models.out (or
BIOMOD.ensemble.models.out) object
expl.var.namesa vector from the
expl.var.names slot of a BIOMOD.models.out or
BIOMOD.ensemble.models.out object
resp.vara vector from the data.species slot
of the formated.input.data slot of a
BIOMOD.models.out or
BIOMOD.ensemble.models.out object
expl.vara data.frame from the data.env.var
slot of the formated.input.data slot of a
BIOMOD.models.out or
BIOMOD.ensemble.models.out object
MinMaxa list of minimum and maximum values (or
levels if factorial) of variable contained in the data.env.var
slot of the formated.input.data slot of a
BIOMOD.models.out or
BIOMOD.ensemble.models.out object
eval.resp.vara vector from the
eval.data.species slot of the formated.input.data slot of
a BIOMOD.models.out or
BIOMOD.ensemble.models.out object
eval.expl.vara data.frame from the
eval.data.env.var slot of the formated.input.data slot of
a BIOMOD.models.out or
BIOMOD.ensemble.models.out object
get_built_modelsa vector from the
models.computed slot (or em.computed) of a
BIOMOD.models.out (or
BIOMOD.ensemble.models.out) object
get_evaluationsa data.frame from the models.evaluation
slot (or model_evaluation of each model in em.computed) of a
BIOMOD.models.out (or BIOMOD.ensemble.models.out)
object. Contains evaluation metric for different models and dataset.
Evaluation metric are calculated on the calibrating data (column calibration),
on the cross-validation data (column validation) or on the evaluation data
(column evaluation).
For cross-validation data, see CV.[...]
parameters in BIOMOD_Modeling function ; for evaluation data, see
eval.[...] parameters in BIOMOD_FormatingData.
get_variables_importancea
BIOMOD.stored.data.frame-class from
the variables.importance slot (or model_variables_importance
of each model in em.models) of a BIOMOD.models.out
(or BIOMOD.ensemble.models.out) object
Damien Georges
BIOMOD.models.out, BIOMOD.projection.out,
BIOMOD.ensemble.models.out
Other Toolbox functions:
getters.bm,
load_stored_object(),
predict.bm,
predict.em,
predict2.bm,
predict2.em,
setters
BIOMOD.stored.data objectsThis functions allow the user to load BIOMOD.stored.data objects
into memory.
load_stored_object(obj, ...) ## S4 method for signature 'BIOMOD.stored.data' load_stored_object(obj, layer = 1) ## S4 method for signature 'BIOMOD.stored.SpatRaster' load_stored_object(obj, layer = 1)load_stored_object(obj, ...) ## S4 method for signature 'BIOMOD.stored.data' load_stored_object(obj, layer = 1) ## S4 method for signature 'BIOMOD.stored.SpatRaster' load_stored_object(obj, layer = 1)
obj |
a |
... |
additional arguments |
layer |
an |
Damien Georges
Other Toolbox functions:
getters.bm,
getters.out,
predict.bm,
predict.em,
predict2.bm,
predict2.em,
setters
A data.frame containing for each single model available in biomod2
the package and functions to be called.
ModelsTableModelsTable
A data.frame object with 12 rows and 5 variables:
all single models that can be computed in biomod2
data type associated to the models
R package used
function used in the R package
function called by caret for the tuning
All single models available are the following :
ANN (nnet)
CTA (rpart)
DNN (cito)
FDA (fda)
GBM (gbm)
GLM (glm)
MARS (earth)
MAXENT (see Maxent website)
MAXNET (maxnet)
RF (randomForest)
RFd (randomForest downsampled)
SRE (bm_SRE)
XGBOOST (xgboost)
A data.frame containing ODMAP (Overview, Data, Model, Assessment, Prediction)
protocol components.
ODMAPODMAP
A data.frame object with 84 rows and 4 variables:
Overview, Data, Model, Assessment or Prediction step
corresponding field
corresponding field
to be filled with BIOMOD_Report function
A BIOMOD.models.options object containing for each single model available in
biomod2 the parameter values pre-defined by biomod2 team.
OptionsBigbossOptionsBigboss
A BIOMOD.models.options object with some changed values :
ANN.nnet.nnetsize = 5
decay = 0.1
trace = FALSE
rang = 0.1
maxit = 200
CTA.rpart.rpartcontrol = list(xval = 5, minbucket = 5, minsplit = 5, cp = 0.001, maxdepth = 10)
cost = NULL
DNN.cito.dnnbatchsize = 100L
epochs = 150L
hidden = c(100L, 100L)
lr = 0.05
optimizer = "adam"
lambda = 0.001
alpha = 1.0
validation = 0.2
lr_scheduler = config_lr_scheduler("reduce_on_plateau", patience = 7)
early_stopping = 14
FDA.mda.fdaGAM.gam.gamGAM.mgcv.bamGAM.mgcv.gammethod = 'GCV.Cp'
control = list(epsilon = 1e-06, trace = FALSE, maxit = 100)
GBM.gbm.gbmn.trees = 2500
interaction.depth = 7
n.minobsinnode = 5
shrinkage = 0.001
cv.folds = 3
keep.data = FALSE
n.cores = 1
GLM.stats.glmmustart = 0.5
control = glm.control(maxit = 50)
MARS.earth.earthncross = 0
nk = NULL
penalty = 2
thresh = 0.001
nprune = NULL
pmethod = 'backward'
MAXENT.MAXENT.MAXENTpath_to_maxent.jar = '.'
RF.randomForest.randomForestntree = 500
mtry = 2
sampsize = NULL
nodesize = 5
maxnodes = NULL
RFd.randomForest.randomForesttype = 'classification'
ntree = 500
mtry = 2
strata = factor(c(0, 1))
sampsize = NULL
nodesize = 5
maxnodes = NULL
SRE.biomod2.bm_SREdo.extrem = TRUE
XGBOOST.xgboost.xgb_trainparams = list(max_depth = 2, eta = 1, nthread = 2)
nrounds = 4
plot method for BIOMOD.formated.data and
BIOMOD.formated.data.PA object classPlot the spatial distribution of presences, absences and
pseudo-absences among the different potential dataset (calibration,
validation and evaluation). Available only if coordinates were given to
BIOMOD_FormatingData.
## S4 method for signature 'BIOMOD.formated.data,missing' plot( x, calib.lines = NULL, PA, run, plot.type, point.size = 1.5, plot.output, plot.valid = TRUE, plot.eval = TRUE, do.plot = TRUE, has.mask = FALSE, has.mask.eval = FALSE )## S4 method for signature 'BIOMOD.formated.data,missing' plot( x, calib.lines = NULL, PA, run, plot.type, point.size = 1.5, plot.output, plot.valid = TRUE, plot.eval = TRUE, do.plot = TRUE, has.mask = FALSE, has.mask.eval = FALSE )
x |
a |
calib.lines |
(optional, default |
PA |
(optional, default |
run |
(optional, default |
plot.type |
a |
point.size |
(optional, default |
plot.output |
a |
plot.valid |
(optional, default |
plot.eval |
(optional, default |
do.plot |
(optional, default |
has.mask |
optional, default |
has.mask.eval |
(optional, default |
a list with the data used to generate the plot and a
ggplot2 object
Rémi Lemaire-Patin, Hélène Blancheteau
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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData plot(myBiomodData)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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData plot(myBiomodData)
biomod2_model objectsThis function allows the user to predict single models from
biomod2_model on (new) explanatory variables.
## S4 method for signature 'biomod2_model' predict(object, newdata, ...)## S4 method for signature 'biomod2_model' predict(object, newdata, ...)
object |
a |
newdata |
a |
... |
(optional) |
Damien Georges
Other Toolbox functions:
getters.bm,
getters.out,
load_stored_object(),
predict.em,
predict2.bm,
predict2.em,
setters
biomod2_ensemble_model objectsThis function allows the user to predict single models from
biomod2_ensemble_model on (new) explanatory variables.
object |
a |
newdata |
a |
... |
(optional) |
Damien Georges
Other Toolbox functions:
getters.bm,
getters.out,
load_stored_object(),
predict.bm,
predict2.bm,
predict2.em,
setters
This function allow the user to change the folder where the modelling of biomod2 have been done.
set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.models.out' set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.ensemble.models.out' set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.projection.out' set_new_dirname(obj, new.dir.name)set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.models.out' set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.ensemble.models.out' set_new_dirname(obj, new.dir.name) ## S4 method for signature 'BIOMOD.projection.out' set_new_dirname(obj, new.dir.name)
obj |
a |
new.dir.name |
a |
Hélène Blancheteau
BIOMOD.models.out, BIOMOD.projection.out,
BIOMOD.ensemble.models.out
Other Toolbox functions:
getters.bm,
getters.out,
load_stored_object(),
predict.bm,
predict.em,
predict2.bm,
predict2.em
summary method for BIOMOD.formated.data object classSummarize the number of presences, absences and pseudo-absences among the different potential dataset (calibration, validation and evaluation).
## S4 method for signature 'BIOMOD.formated.data' summary(object, calib.lines = NULL)## S4 method for signature 'BIOMOD.formated.data' summary(object, calib.lines = NULL)
object |
a |
calib.lines |
(optional, default |
a data.frame
Rémi Lemaire-Patin
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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData summary(myBiomodData)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) ## ----------------------------------------------------------------------- # # Format Data with true absences myBiomodData <- BIOMOD_FormatingData(resp.name = myRespName, resp.var = myResp, resp.xy = myRespXY, expl.var = myExpl) myBiomodData summary(myBiomodData)