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
)a BIOMOD.models.out object returned by the
BIOMOD_Modeling function
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.mod
a character corresponding to the way plots will be colored, must be
among full.name, PA, run or algo
(optional, default TRUE)
A logical value defining whether the plot is to be rendered or not
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.
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 not the all plots are made for all models, independently to the different models assumptions. It is up to the user to interpret the graphics.
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)
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)
}
# ---------------------------------------------------------------#
# Explore single models
myBiomodAnalysis <- bm_ModelAnalysis(bm.mod = myBiomodModelOut, color.by = "run")
plot(myBiomodAnalysis$plot.outliers)