Learn R Programming

biomod2 (version 4.1-2)

BIOMOD_PresenceOnly: Evaluate models with presence-only metrics

Description

This function computes presence-only evaluation metrics (Boyce index and Minimal Predicted Area) for BIOMOD.models.out or BIOMOD.ensemble.models.out objects that can be obtained with the BIOMOD_Modeling or BIOMOD_EnsembleModeling functions.

Usage

BIOMOD_PresenceOnly(
  bm.mod = NULL,
  bm.em = NULL,
  bg.env = NULL,
  perc = 0.9,
  save.output = TRUE
)

Value

A data.frame containing evaluation scores both for the evaluation metrics used in the BIOMOD_Modeling function and additional Boyce index and Minimal Predicted Area.

Arguments

bm.mod

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

bm.em

a BIOMOD.ensemble.models.out object returned by the BIOMOD_EnsembleModeling function

bg.env

(optional, default NULL)
A matrix, data.frame or RasterStack object containing values of environmental variables extracted from the background (if presences are to be compared to background instead of absences or pseudo-absences selected for modeling)

perc

a numeric between 0 and 1 corresponding to the percentage of correctly classified presences for Minimal Predicted Area (see ecospat.mpa() in ecospat)

save.output

(optional, default TRUE)
A logical value defining whether the output is to be saved within the .BIOMOD_DATA folder or not

Author

Frank Breiner, Maya Gueguen

Details

em.by parameter of BIOMOD_EnsembleModeling must have been set to PA_dataset+repet in order to have an ensemble for each RUN of the NbRunEval parameter of the BIOMOD_Modeling function for evaluation.

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 do not converge.

References

  • Engler, R., Guisan, A., and 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.

  • Hirzel, A. H., Le Lay, G., Helfer, V., Randin, C., and Guisan, A. 2006. Evaluating the ability of habitat suitability models to predict species presences. Ecological Modelling, 199(2), 142-152.

See Also

ecospat.boyce() and ecospat.mpa() in ecospat, BIOMOD.models.out, BIOMOD_Modeling, BIOMOD.ensemble.models.out, BIOMOD_EnsembleModeling

Other Main functions: BIOMOD_CrossValidation(), BIOMOD_EnsembleForecasting(), BIOMOD_EnsembleModeling(), BIOMOD_FormatingData(), BIOMOD_LoadModels(), BIOMOD_ModelingOptions(), BIOMOD_Modeling(), BIOMOD_Projection(), BIOMOD_RangeSize(), BIOMOD_Tuning()

Examples

Run this code

# Load species occurrences (6 species available)
myFile <- system.file('external/species/mammals_table.csv', package = 'biomod2')
DataSpecies <- read.csv(myFile, row.names = 1)
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)
myFiles <- paste0('external/bioclim/current/bio', c(3, 4, 7, 11, 12), '.grd')
myExpl <- raster::stack(system.file(myFiles, package = 'biomod2'))

# \dontshow{
myExtent <- raster::extent(0,30,45,70)
myExpl <- raster::stack(raster::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.var = myResp,
                                       expl.var = myExpl,
                                       resp.xy = myRespXY,
                                       resp.name = myRespName)

  # Create default modeling options
  myBiomodOptions <- BIOMOD_ModelingOptions()

  # Model single models
  myBiomodModelOut <- BIOMOD_Modeling(bm.format = myBiomodData,
                                      modeling.id = 'AllModels',
                                      models = c('RF', 'GLM'),
                                      bm.options = myBiomodOptions,
                                      nb.rep = 2,
                                      data.split.perc = 80,
                                      metric.eval = c('TSS','ROC'),
                                      var.import = 3,
                                      do.full.models = FALSE,
                                      seed.val = 42)
}


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',
                                        metric.select = c('TSS'),
                                        metric.select.thresh = c(0.7),
                                        metric.eval = c('TSS', 'ROC'),
                                        var.import = 3,
                                        prob.mean = TRUE,
                                        prob.median = FALSE,
                                        prob.cv = FALSE,
                                        prob.ci = FALSE,
                                        prob.ci.alpha = 0.05,
                                        committee.averaging = TRUE,
                                        prob.mean.weight = FALSE,
                                        prob.mean.weight.decay = 'proportional',
                                        seed.val = 42)
}


# ---------------------------------------------------------------
# Evaluate models with Boyce index and MPA
myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM)
myBiomodPO

# Evaluate models with Boyce index and MPA (using background data)
myBiomodPO <- BIOMOD_PresenceOnly(bm.mod = myBiomodModelOut,
                                  bm.em = myBiomodEM, 
                                  bg.env = myExpl)
myBiomodPO


Run the code above in your browser using DataLab