library(terra)
## Load real data
data(DataSpecies)
myResp.r <- as.numeric(DataSpecies[, 'GuloGulo'])
data(bioclim_current)
myExpl.r <- rast(bioclim_current)
myRespXY <- DataSpecies[which(myResp.r == 1), c('X_WGS84', 'Y_WGS84')]
myResp.v <- classify(subset(myExpl.r, 1),
matrix(c(-Inf, Inf, 0), ncol = 3, byrow = TRUE))
myResp.v[cellFromXY(myResp.v, myRespXY)] <- 1
## Compute SRE for several quantile values
sre.100 <- bm_SRE(resp.var = myResp.v,
expl.var = myExpl.r,
new.env = myExpl.r,
quant = 0)
sre.095 <- bm_SRE(resp.var = myResp.v,
expl.var = myExpl.r,
new.env = myExpl.r,
quant = 0.025)
sre.090 <- bm_SRE(resp.var = myResp.v,
expl.var = myExpl.r,
new.env = myExpl.r,
quant = 0.05)
## Visualize results
res <- c(myResp.v, sre.100, sre.095, sre.090)
names(res) <- c("Original distribution", "Full data calibration"
, "Over 95 percent", "Over 90 percent")
plot(res)
Run the code above in your browser using DataLab