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
)

Arguments

bm.mod

a BIOMOD.models.out object returned by the BIOMOD_Modeling function

models.chosen

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

color.by

a character corresponding to the way plots will be colored, must be among full.name, PA, run or algo

do.plot

(optional, default TRUE)
A logical value defining whether the plot is to be rendered or not

Value

A list containing :

  1. a data.frame with variables, predicted values and model residuals

  2. a data.frame with the R score values

  3. 5 ggplot objects (from A to E) representing the different analyses.

Details

5 plots can be obtained with this function :

residuals ~ observations number

to detect outliers. The x-axis only helps to find the outlier number.

residuals Q-Q plot

to check if residuals follow a normal distribution. Points should follow the black line.

residuals histogram

to check if residuals follow a normal distribution. Histogram should represent a gaussian distribution.

residuals ~ fitted values

to detect an heteroscedasticity of the residuals. It corresponds to the Tukey-Anscombe plot.

R scores

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.

Author

Hélène Blancheteau

Examples

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)