View source: R/bm_ModelAnalysis.R
bm_ModelAnalysis | R Documentation |
This function return several graphs to help analyse the single models.
bm_ModelAnalysis(
bm.mod,
models.chosen = "all",
do.plot = TRUE,
color.by = "full.name"
)
bm.mod |
a |
models.chosen |
a |
do.plot |
a |
color.by |
a |
All the plots will be made for all the models, independently to the different models assumptions. It is up to the user to interpret the graphs in the light of the model assumptions.
Plot A: residuals ~ observations number. This plot helps to detect one or several outliers. The x-axis only helps to find the outlier number.
Plot B and C: These are two representation of the distribution of the residuals. If your residuals must follow a normal distribution, the points should follow the black line in the Q-Q plot and present a gaussian distribution on the histogram.
Plot D residuals ~ fitted values. This plot helps to detect an heteroscedasticity of the residuals.
Plot E : a plot of the different Rsquared values available (Rsquared, Rsquared_aj). An big gap between the calibration and validation values can be the sign of an overfitting.
A list with:
a dataframe with the observation data, the fitted values and the residuals for all models
a dataframe with the compilation of the R scores
A to E plots (see details)
Hélène Blancheteau
library(terra)
# Load species occurrences (6 species available)
data(DataSpecies)
head(DataSpecies)
# Select the name of the studied species
myRespName <- 'VulpesVulpes'
# 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)
# Transform binary data as count data
poissonDistri <- rpois(sum(myResp), 10)
myResp[myResp == 1] <- poissonDistri
# ---------------------------------------------------------------
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,
data.type = 'count')
# Model single models
myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData,
modeling.id = 'AllModels',
models = c('GAM', 'GLM', 'MARS'),
CV.strategy = 'random',
CV.nb.rep = 2,
CV.perc = 0.8,
OPT.strategy = 'bigboss',
metric.eval = c('Rsquared', 'Rsquared_aj'),
seed.val = 42)
}
# ---------------------------------------------------------------
# bm_ModelAnalysis
analysis <- bm_ModelAnalysis(myBiomodModelOut, color.by = "RUN")
plot(analysis$plotA)
unlink(myRespName, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.