# Environemental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, bio_11 & bio_12)
myExpl = raster:::stack(system.file("external/climat/current/bio3.grd",package="biomod2"),
system.file("external/climat/current/bio4.grd",package="biomod2"),
system.file("external/climat/current/bio7.grd",package="biomod2"),
system.file("external/climat/current/bio11.grd",package="biomod2"),
system.file("external/climat/current/bio12.grd",package="biomod2"))
# species occurances
species_occ <- read.csv(system.file("external/species/species_occ.csv",package="biomod2"))
# we consider only presences of MyocastorCoypus species
myRespName <- 'MyocastorCoypus'
myRespCoord <- species_occ[which(!is.na(species_occ[,myRespName])),c('x','y')]
# we build a raster layer based on environmental rasters for our response variable
myResp <- reclassify(subset(myExpl,1,drop=TRUE), c(-Inf,Inf,0))
myResp[cellFromXY(myResp,myRespCoord)] <- 1
# Compute some SRE for several quantile values
g <- sre(Response = myResp, Explanatory = myExpl, NewData=myExpl, Quant=0)
gg <- sre(Response = myResp, Explanatory = myExpl, NewData=myExpl, Quant=0.025)
ggg <- sre(Response = myResp, Explanatory = myExpl, NewData=myExpl, Quant=0.05)
# visualise results
par(mfrow=c(2,2),mar=c(6, 5, 5, 3))
plot(myResp, main=paste(myRespName,"original distrib."))
plot(g, main="full data calibration")
plot(gg, main="Perc025")
plot(ggg, main="Perc05")
Run the code above in your browser using DataLab