response.plot2 {biomod2}R Documentation

Function for for plotting predicted responses from species distribution models in 2 or 3 dimensions


Adaptation of the Evaluation Strip method proposed by Elith et al.(2005). This function enables to plot the response curves of a model independently of the algorithm used for building the model. It therefore permits a direct comparison of predicted responses from the different statistical approaches on the same data.


  show.variables = seq(1:ncol(Data)),
  do.bivariate = FALSE,
  fixed.var.metric = "mean",
  save.file = "no",
  name = "response_curve",
  ImageSize = 480,
  plot = TRUE,



a character vector specifying the models for which the response curves have to be plotted. Compatible with GAM, GBM, GLM, ANN, CTA, RF, FDA, MARS and MAXENT.


a dataframe containing the variables for which the response curves have to be plotted. They must have the same names as the ones used to calibrate the model. RasterStack are also supported.


the names or the column numbers of 'Data' for selecting the variables to be plotted. By default all columns are taken


'logical', if FALSE (default), the predicted response curves are plotted for every singe variable independently (2 dimension). If TRUE, the predicted response curves are represented in 3 dimentions for all pairs of variables


either 'mean' (default), 'median', 'min' or 'max' specifying the statistic used to fix as constant the remaining variables when the predicted response is estimated for one of the variables


can be set to "pdf", "jpeg" or "tiff" to save the plot. Pdf options can be changed by setting the default values of pdf.options().


the name of the file produced if save.file is different to "no" (extensions are already included)


the size of the image in pixels if save.file is different to "no". Affects "jpeg" and "tiff" outputs only. Default if 480 pixels which is the R default.


if TRUE (the default) then a plot is produced


further arguments : - data_species : vector containing data species occurrences. Have to match with Data. If given, the statistic used to fix variables value will be calculated only over presences points. (Considered only if Data is under table format) - col : vector of colors to be used (only for univariate case) - lty : vector of lines types to be used - main : character, the title of the graph (default one based on first model class is automatically produced if not referred) - display_title : logical, display or not graph title - legend : logical, add legend to plot (only for univariate case)


For building the predicted response curves, n-1 variables are set constant to a fixed value (mean, median, min or max i.e fixed.var.metric arg) and only the remaining one (resp. 2 for 3D response plot) is varying across its whole range (given by Data). n the case of categorical variable, the most represented class is taken. The variations observed and the curve thus obtained shows the sensibility of the model to that specific variable. This method does not account for interactions between variables. In the evaluation strip initially proposed by Elith et al. 2005 the remaining variables are set to the mean.


a 4 dimentions array is returned. It contains the necessary outputs to produce the plots. This is useful to make your own custom response plot graphics.

Array returned structure :

- First dimension: the dimension of the predictions - Second dimension: 2 or 3 columns: The first one (resp. the first two) is (are) the explanatory variable(s) to plot, the last one, the probability of occurrence - Third dimension: The set of environmental variables for which the response.plot was asked to run. - Fourth dimension:the selected models


Wilfried Thuiller, Damien Georges


Elith, J., Ferrier, S., Huettmann, FALSE. & Leathwick, J. R. 2005 The evaluation strip: A new and robust method for plotting predicted responses from species distribution models. Ecological Modelling 186, 280-289.

See Also



## Not run: 
##' species occurrences
DataSpecies <- 
    system.file("external/species/mammals_table.csv", package="biomod2"), 
    row.names = 1
##' the name of studied species
myRespName <- 'VulpesVulpes'
##' the presence/absences data for our species 
myResp <- as.numeric(DataSpecies[, myRespName])
##' the XY coordinates of species data
myRespXY <- DataSpecies[, c("X_WGS84", "Y_WGS84")]

myExpl <- 
    system.file("external/bioclim/current/bio3.grd", package = "biomod2"),
    system.file("external/bioclim/current/bio4.grd", package = "biomod2"),
    system.file("external/bioclim/current/bio7.grd", package = "biomod2"),
    system.file("external/bioclim/current/bio11.grd", package = "biomod2"),
    system.file("external/bioclim/current/bio12.grd", package = "biomod2")

##' 1. Formatting Data
myBiomodData <- 
    resp.var = myResp,
    expl.var = myExpl,
    resp.xy = myRespXY, = myRespName

##' 2. Defining Models Options using default options.
myBiomodOption <- BIOMOD_ModelingOptions()

##' 3. Doing Modelisation
myBiomodModelOut <- 
    models = c('GLM','RF'),
    models.options = myBiomodOption,
    NbRunEval = 2,
    DataSplit = 80,
    VarImport = 0,
    models.eval.meth = c('TSS','ROC'),
    do.full.models = FALSE, = "test"
##' 4. Plot response curves
##' 4.1 Load the models for which we want to extract the predicted
##' response curves
myGLMs <- BIOMOD_LoadModels(myBiomodModelOut, models = 'GLM')
##' 4.2 plot 2D response plots
myRespPlot2D <- 
    models = myGLMs,
    Data = get_formal_data(myBiomodModelOut, 'expl.var'),
    show.variables = get_formal_data(myBiomodModelOut,'expl.var.names'),
    do.bivariate = FALSE,
    fixed.var.metric = 'median',
    col = c("blue", "red"),
    legend = TRUE,
    data_species = get_formal_data(myBiomodModelOut, 'resp.var')
##' 4.2 plot 3D response plots
###' here only for a lone model (i.e "VulpesVulpes_PA1_AllData_GLM")
myRespPlot3D <- 
  models = myGLMs[1],
  Data = get_formal_data(myBiomodModelOut, 'expl.var'), 
  show.variables = get_formal_data(myBiomodModelOut, 'expl.var.names'),
  do.bivariate = TRUE,
  fixed.var.metric = 'median',
  data_species = get_formal_data(myBiomodModelOut, 'resp.var'),
  display_title = FALSE
##' all the values used to produce this plot are stored into the
##' returned object you can redo plots by yourself and customised 
##' them

## End(Not run)

[Package biomod2 version 3.5.1 Index]