R/BIOMOD_LoadModels.R
BIOMOD_LoadModels.RdThis 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
)a BIOMOD.models.out or BIOMOD.ensemble.models.out
object that can be obtained with the BIOMOD_Modeling or
BIOMOD_EnsembleModeling functions
(optional, default NULL)
A vector containing model names to be kept, must be either all or a
sub-selection of model names that can be obtained with the get_built_models
function applied to bm.out
(optional, default NULL)
A vector containing pseudo-absence set to be loaded, must be among PA1,
PA2, ..., allData
(optional, default NULL)
A vector containing repetition set to be loaded, must be among RUN1,
RUN2, ..., allRun
(optional, default NULL)
A character containing algorithm to be loaded, must be either ANN, CTA,
FDA, GAM, GBM, GLM, MARS, MAXENT, MAXNET,
RF, RFd, SRE, XGBOOST
(optional, default NULL)
A vector containing merged pseudo-absence set to be loaded, must be among PA1,
PA2, ..., mergedData
(optional, default NULL)
A vector containing merged repetition set to be loaded, must be among RUN1,
RUN2, ..., mergedRun
(optional, default NULL)
A character containing merged algorithm to be loaded, must be among ANN,
CTA, FDA, GAM, GBM, GLM, MARS, MAXENT,
MAXNET, RF, RFd, SRE, XGBOOST, mergedAlgo
(optional, default NULL)
A vector containing evaluation metric selected to filter single models to build the
ensemble models, must be among AUCroc, AUCprg, TSS, KAPPA, ACCURACY,
BIAS, POD, FAR, POFD, SR, CSI, ETS,
OR, ORSS, BOYCE, MPA (binary data),
RMSE, MAE, MSE, Rsquared, Rsquared_aj, Max_error
(abundance / count / relative data),
Accuracy, Recall, Precision, F1 (ordinal data)
A vector containing the names of the loaded models.
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).
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)
DONTSHOW({
myExtent <- terra::ext(0,30,45,70)
myExpl <- terra::crop(myExpl, myExtent)
})
# ---------------------------------------------------------------
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')