if (FALSE) {
##' species occurrences
DataSpecies <-
read.csv(
system.file("external/species/mammals_table.csv", package="biomod2"),
row.names = 1
)
head(DataSpecies)
##' 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 <-
raster::stack(
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 <-
BIOMOD_FormatingData(
resp.var = myResp,
expl.var = myExpl,
resp.xy = myRespXY,
resp.name = myRespName
)
##' 2. Defining Models Options using default options.
myBiomodOption <- BIOMOD_ModelingOptions()
##' 3. Doing Modelisation
myBiomodModelOut <-
BIOMOD_Modeling(
myBiomodData,
models = c('GLM','RF'),
models.options = myBiomodOption,
NbRunEval = 2,
DataSplit = 80,
VarImport = 0,
models.eval.meth = c('TSS','ROC'),
do.full.models = FALSE,
modeling.id = "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 <-
response.plot2(
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 <-
response.plot2(
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
dim(myRespPlot2D)
dimnames(myRespPlot2D)
dim(myRespPlot3D)
dimnames(myRespPlot3D)
}
Run the code above in your browser using DataLab