1 Packages needed

library(BiodiversityR)
library(raster)
library(rgdal)
library(dismo)
library(terra)
library(ggmap)
library(ggspatial)
library(ggforce)

2 Introduction

The main objectives of this document were to:

  • Showcase new options of BiodiversityR to work with the terra package (these options were introduced in version 14.1 of the package).
  • Showcase some of the more recent methods for species distribution modelling pipelines that were introduced in newer versions of BiodiversityR than the version that was described by Kindt 2018. These newer methods include methods of spatial and environmental thinning, spatial folding and an a posteriori distance constraining method.

Another objective was to compare execution speeds between the raster and terra packages (see here for an alternative example).

In addition, this document illustrates some of the methods used to create a climate change atlas for Africa.

3 Environmental data

The example shown here builds on the examples provided in the documentation for BiodiversityR (e.g., ensemble.raster) and previously provided in the dismo package (a modified set of tutorials for is available now via rspatial.org, e.g. Species distribution modelling: environmental data).

3.1 Load the example environmental data

predictor.files <- list.files(path=paste(system.file(package="dismo"), '/ex', sep=''),
    pattern='grd', full.names=TRUE)
predictors.raster <- stack(predictor.files)
predictors.raster
## class      : RasterStack 
## dimensions : 192, 186, 35712, 9  (nrow, ncol, ncell, nlayers)
## resolution : 0.5, 0.5  (x, y)
## extent     : -125, -32, -56, 40  (xmin, xmax, ymin, ymax)
## crs        : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs 
## names      : bio1, bio12, bio16, bio17, bio5, bio6, bio7, bio8, biome 
## min values :  -23,     0,     0,     0,   61, -212,   60,  -66,     1 
## max values :  289,  7682,  2458,  1496,  422,  242,  461,  323,    14

3.2 Convert to the geotiff format

Especially to load the environmental data into terra, the raster layers are converted to the geotiff format:

for (i in 1:length(names(predictors.raster))) {
  raster.focal <- predictors.raster[[i]]
  raster::writeRaster(raster.focal,
                      filename=paste0(names(raster.focal), ".tif"),
                      overwrite=TRUE)
}

These geotiff files can now be used to create the raster::rasterStack

predictor.files <- list.files(getwd(),pattern=".tif", full.names=TRUE)
predictor.files <- predictor.files[grepl(pattern= "bio", x=predictor.files)]
predictors.raster <- raster::stack(predictor.files)
predictors.raster
## class      : RasterStack 
## dimensions : 192, 186, 35712, 9  (nrow, ncol, ncell, nlayers)
## resolution : 0.5, 0.5  (x, y)
## extent     : -125, -32, -56, 40  (xmin, xmax, ymin, ymax)
## crs        : +proj=longlat +datum=WGS84 +no_defs 
## names      : bio1, bio12, bio16, bio17, bio5, bio6, bio7, bio8, biome 
## min values :  -23,     0,     0,     0,   61, -212,   60,  -66,     1 
## max values :  289,  7682,  2458,  1496,  422,  242,  461,  323,    14

The same files can be used to create the SpatRaster object for terra

predictors.terra <- terra::rast(predictor.files)
predictors.terra
## class       : SpatRaster 
## dimensions  : 192, 186, 9  (nrow, ncol, nlyr)
## resolution  : 0.5, 0.5  (x, y)
## extent      : -125, -32, -56, 40  (xmin, xmax, ymin, ymax)
## coord. ref. : lon/lat WGS 84 (EPSG:4326) 
## sources     : bio1.tif  
##               bio12.tif  
##               bio16.tif  
##               ... and 6 more source(s)
## names       : bio1, bio12, bio16, bio17, bio5, bio6, ... 
## min values  :  -23,     0,     0,     0,   61, -212, ... 
## max values  :  289,  7682,  2458,  1496,  422,  242, ...

3.3 Less-correlated environmental data

Based on an earlier Variance Inflation Factor analysis (VIF), four bioclimatic variables (BIO5, the maximum temperature of the warmest month; BIO6, the minimum temperature of the coldest month; BIO16, the precipitation of the wettest quarter; and BIO17, the precipitation of the driest quarter) are selected that have VIF < 5.

predictors.raster <- raster::subset(predictors.raster, 
                                    subset=c("bio5", "bio6", "bio16", "bio17"))
predictors.raster
## class      : RasterStack 
## dimensions : 192, 186, 35712, 4  (nrow, ncol, ncell, nlayers)
## resolution : 0.5, 0.5  (x, y)
## extent     : -125, -32, -56, 40  (xmin, xmax, ymin, ymax)
## crs        : +proj=longlat +datum=WGS84 +no_defs 
## names      : bio5, bio6, bio16, bio17 
## min values :   61, -212,     0,     0 
## max values :  422,  242,  2458,  1496
predictors.raster@title <- "base"

VIF.recheck <- BiodiversityR::ensemble.VIF(predictors.raster)
## Warning in dismo::randomPoints(x[[1]], n = an, p = NULL, excludep = F):
## generated random points = 0.9775 times requested number
## 
## Selection of explanatory variables based on the Variance Explanation Factor
## Data obtained from  9775 point locations
## If some variables have VIF > VIF.max, then the variable with largest VIF is excluded
## The procedure stops when all variables have VIF <= VIF.max
## 
## Variance inflation (package: car)
##     bio5     bio6    bio16    bio17 
## 1.267673 2.394820 2.520957 1.358457 
## 
## VIF directly calculated from linear model with focal numeric variable as response
##    bio16     bio6    bio17     bio5 
## 2.520957 2.394820 1.358457 1.267673 
## 
## 
## Summary of VIF selection process:
##            bio5    bio6    bio16    bio17
## step_1 1.267673 2.39482 2.520957 1.358457
## 
## Final selection of variables:
## [1] "bio16" "bio6"  "bio17" "bio5"

The same subset is created with terra

predictors.terra <- terra::subset(predictors.terra, 
                                  subset=c("bio5", "bio6", "bio16", "bio17"))
predictors.terra
## class       : SpatRaster 
## dimensions  : 192, 186, 4  (nrow, ncol, nlyr)
## resolution  : 0.5, 0.5  (x, y)
## extent      : -125, -32, -56, 40  (xmin, xmax, ymin, ymax)
## coord. ref. : lon/lat WGS 84 (EPSG:4326) 
## sources     : bio5.tif  
##               bio6.tif  
##               bio16.tif  
##               ... and 1 more source(s)
## names       : bio5, bio6, bio16, bio17 
## min values  :   61, -212,     0,     0 
## max values  :  422,  242,  2458,  1496

4 Occurrence observations and background locations

The dismo package contains presence observations of Bradypus variegatus, the brown-throated three-toed sloth (See also here or here).

presence_file <- paste(system.file(package="dismo"), '/ex/bradypus.csv', sep='')
pres <- read.table(presence_file, header=TRUE, sep=',')[,-1]
summary(pres)
##       lon              lat         
##  Min.   :-85.93   Min.   :-23.450  
##  1st Qu.:-79.20   1st Qu.: -2.896  
##  Median :-75.08   Median :  4.817  
##  Mean   :-71.79   Mean   :  2.449  
##  3rd Qu.:-65.51   3rd Qu.:  9.150  
##  Max.   :-40.07   Max.   : 13.950

4.1 Environmental thinning

Environmental thinning is a method to reduce bias in presence observations. The algorithms in BiodiversityR are similar to spatial thinning, but require a target final number of records instead of a target minimum geographical distance as in spatial thinning.

To obtain the target final number of records, first spatial thinning is done using a commonly used minimum distance of 10 km (but see Castellanos et al. 2019).

pres.spat <- BiodiversityR::ensemble.spatialThin(x=pres,
                                                 thin.km=10.0)
## Warning in .couldBeLonLat(x, warnings = warnings): CRS is NA. Assuming it is
## longitude/latitude
## Spatially thinned point location data set obtained for target minimum distance of 10
## number of locations:  108 
## minimum distance:  13413.9512933096

Environmental thinning is done with the target of the same number of records:

pres.env <- BiodiversityR::ensemble.environmentalThin(x=pres,
                                                      predictors.stack=predictors.raster,
                                                      thin.n=nrow(pres.spat))
## 
## Percentage of variance of the selected axes (1 to 4) of principal components analysis: 100
## Environmentally thinned point location data set obtained with first algorithm
## number of locations:  108 
## minimum distance:  0 
## 
## Environmentally thinned point location data set obtained with second algorithm
## number of locations:  108 
## minimum distance:  0

As it happens, the minimum environmental distance is zero for the environmentally-thinned data set. Hence the target is lowered further to 90:

pres.env <- BiodiversityR::ensemble.environmentalThin(x=pres,
                                                      predictors.stack=predictors.raster,
                                                      thin.n=90)
## 
## Percentage of variance of the selected axes (1 to 4) of principal components analysis: 100
## Environmentally thinned point location data set obtained with first algorithm
## number of locations:  90 
## minimum distance:  0.0472273 
## 
## Environmentally thinned point location data set obtained with second algorithm
## number of locations:  89 
## minimum distance:  0.0479645

Since the environmental distance is larger than zero, we are certain that there is only one presence observation per raster cell (such condition has been used in several studies). At the same time, locations are further than 10 km apart.

pres.env.test <- BiodiversityR::ensemble.spatialThin(x=pres.env, thin.km=10)
## Warning in .couldBeLonLat(x, warnings = warnings): CRS is NA. Assuming it is
## longitude/latitude
## WARNING: thinning parameter smaller or equal to minimum distance among locations 
## therefore all locations selected

The results of the thinning process can be visualized as follows.

pres.removed <- pres[(rownames(pres) %in% rownames(pres.env)) == FALSE, ]
bbox_study <- c(left=as.numeric(ext(predictors.raster)$xmin),
                bottom=as.numeric(ext(predictors.raster)$ymin),
                right=as.numeric(ext(predictors.raster)$xmax),
                top=as.numeric(ext(predictors.raster)$ymax))

stamen_study <- get_stamenmap(bbox_study, zoom=4, force=TRUE,
                              maptype="terrain-background")

stamen_map <- ggmap(stamen_study)

bbox_study2 <- c(left=min(pres$lon-5),
                 bottom=min(pres$lat-5),
                 right=max(pres$lon+8),
                 top=max(pres$lat+5))

stamen_study2 <- get_stamenmap(bbox_study2, zoom=5, force=TRUE,
                               maptype="terrain-background")

stamen_map2 <- ggmap(stamen_study2)
map_study <- stamen_map +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=pres.env,
             aes(x=lon, y=lat),
             colour="black", size=1.5, shape=21, fill="green") +
  geom_point(data=pres.removed,
             aes(x=lon, y=lat),
             colour="red", size=2.5, shape=4) +
  theme(axis.title = element_blank())

map_study

map_study2 <- stamen_map2 +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=pres.env,
             aes(x=lon, y=lat),
             colour="black", size=2.0, shape=21, fill="green") +
  geom_point(data=pres.removed,
             aes(x=lon, y=lat),
             colour="red", alpha=0.5, size=3.0, shape=4, stroke=2) +
  theme(axis.title = element_blank())

map_study2

4.2 Background observations

Background observations are selected within circular neighbourhoods of 500 km. This can be done via dismo::circles.

circles.model <- dismo::circles(p=pres.env,
                                d=500000,
                                lonlat=TRUE)
## Loading required namespace: rgeos
circles.predicted <- predict(circles.model, 
                             predictors.raster[[1]])

The circular neighbourhoods include areas from the ocean.

circles.data <- as.data.frame(circles.predicted, 
                              xy=TRUE, 
                              na.rm=TRUE)

map_study2 <- stamen_map2 +
  geom_contour_filled(data=circles.data,
             aes(x=x, y=y, z=layer),
             colour="black", alpha=0.4, show.legend=FALSE) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=pres.env,
             aes(x=lon, y=lat),
             colour="black", size=2.0, shape=21, fill="red") +
  theme(axis.title = element_blank())

map_study2

Background locations are selected that satisfy two criteria: (i) to be within the circular neighbourhoods; and (ii) to be in terrestrial locations. The final number of background locations is 10 times larger than the number of occurrence records as used in several studies.

background1 <- dismo::randomPoints(mask=circles.predicted,
                                   n=2000,
                                   p=pres.env,
                                   excludep=TRUE)

time1 <- Sys.time() # compare afterwards with terra::extract
background1.data <- raster::extract(predictors.raster, y=background1)
time2 <- Sys.time()
time.raster <- time2-time1
time.raster
## Time difference of 1.073587 secs
background2 <- background1[complete.cases(background1.data), ]
background3 <- background2[sample(nrow(background2),
                                  size=10*nrow(pres.env)), ]
background3 <- data.frame(background3)
nrow(background3)
## [1] 890
nrow(background3) / nrow(pres.env)
## [1] 10
names(background3) <- c("lon", "lat")

The following script compares the time required for extraction by terra with the time for raster:

time1 <- Sys.time()
background1.data <- terra::extract(predictors.terra, y=background1)
time2 <- Sys.time()
time.terra <- time2-time1
time.terra
## Time difference of 0.01894999 secs
time.terra - time.raster
## Time difference of -1.054637 secs
as.numeric(time.terra) / as.numeric(time.raster)
## [1] 0.01765109

We have achieved our goal now of selecting the background locations.

terrestrial.raster <- predictors.raster[[1]] < Inf
names(terrestrial.raster) <- "terrestrial"
terrestrial.data <- as.data.frame(terrestrial.raster,
                           xy=TRUE,
                           na.rm=TRUE)
terrestrial.data$terrestrial <- as.numeric(terrestrial.data$terrestrial)

map_study <- stamen_map +
  geom_contour_filled(data=terrestrial.data,
              aes(x=x, y=y, z=terrestrial),
              alpha=0.0, colour="black", show.legend=FALSE) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=background3,
             aes(x=lon, y=lat),
             colour="black", size=1, shape=21, fill="red") +
  theme(axis.title = element_blank())

map_study

bio5.data <- as.data.frame(predictors.raster[["bio5"]],
                           xy=TRUE,
                           na.rm=TRUE)
bio5.data$bio5 <- bio5.data$bio5 / 10

map_study2 <- stamen_map2 +
  geom_contour_filled(data=terrestrial.data,
              aes(x=x, y=y, z=terrestrial),
              alpha=0.0, colour="black", show.legend=FALSE) +
  geom_contour_filled(data=bio5.data,
              aes(x=x, y=y, z=bio5),
              alpha=0.5, colour=NA, show.legend=TRUE) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=background3,
             aes(x=lon, y=lat),
             colour="black", size=1.5, shape=21, fill="red") +
  theme(axis.title = element_blank())
  
map_study2
## Warning: Removed 4288 rows containing non-finite values (stat_contour_filled).

## Warning: Removed 4288 rows containing non-finite values (stat_contour_filled).

bio5.rast <- terra::crop(predictors.terra[["bio5"]]/10,
                         y=c(bbox_study2["left"], bbox_study2["right"],
                             bbox_study2["bottom"], bbox_study2["top"]))

terra::plot(bio5.rast)
points(background3, cex=0.8, pch=21, bg="red")

4.3 Spatial folding

Now that we have occurrence and background locations, these data are divided in four spatial folds that will be used in a 4-fold cross-validation procedure afterwards (see Valavi et al. 2018: BOX 1) for more details). Ideally, spatial folding is done with an equal-area projection such as Mollweide’s. However, using the function with latitude-longitude data will still achieve the main goal of creating spatial folds where auto-correlation between calibration and evaluation data was reduced.

The spatial folding is done via BiodiversityR::ensemble.spatialBlock, a function that uses functions from the blockCV package internally.

locations.folded <- BiodiversityR::ensemble.spatialBlock(x=predictors.raster,
                                                         p=pres.env,
                                                         a=background3,
                                                         theRange=500000,
                                                         return.object=TRUE)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## The best folds was in iteration 5:
##   train_0 train_1 test_0 test_1
## 1     655      72    235     17
## 2     678      67    212     22
## 3     677      63    213     26
## 4     660      65    230     24
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

The result includes the assignment to the spatial fold for the presence observations (‘groupp’) and the background locations (‘groupa’).

pres.folded <- data.frame(pres.env, 
                          fold=as.character(locations.folded$k$groupp))
background.folded <- data.frame(background3, 
                                fold=as.character(locations.folded$k$groupa))

map_study2 <- stamen_map2 +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=pres.folded,
             aes(x=lon, y=lat, fill=fold),
             colour="black", size=2, shape=21) +
  theme(axis.title = element_blank())
  
map_study2

map_study2 <- stamen_map2 +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_point(data=background.folded,
             aes(x=lon, y=lat, fill=fold),
             colour="black", size=1.2, shape=21) +
  theme(axis.title = element_blank())
  
map_study2

5 Calibration of the ensemble model

We now have processed all the data required for species distribution modelling. The functions of BiodiversityR::ensemble.calibrate.weights and BiodiversityR::ensemble.calibrate.models calibrate an ensemble model where

Although we are using a terra::SpatRaster as input, internally the functions will use a raster::rasterStack object. This is for several reasons, such as compatibility with dismo::prepareData and various data checking protocols, typically for categorical environmental variables. Note further that model calibrations are done internally via data.frames.

The textual output from the functions is quite substantial. With argument SINK=FALSE, a user can opt to capture this output in a text file.

5.1 Step 1: determine weights with ensemble.calibrate.weights

# step 1: determine weights through 4-fold cross-validation
ensemble.calibrate.step1 <- ensemble.calibrate.weights(
    x=predictors.terra, p=pres.env, a=background3, 
    k=locations.folded$k, 
    SINK=FALSE, species.name="Bradypus",
    MAXENT=0, MAXNET=1, MAXLIKE=1, GBM=0, GBMSTEP=1, RF=1, CF=0,
    GLM=1, GLMSTEP=1, GAM=1, GAMSTEP=1, MGCV=1, MGCVFIX=0, 
    EARTH=1, RPART=1, NNET=1, FDA=1, SVM=1, SVME=1, GLMNET=1,
    BIOCLIM.O=0, BIOCLIM=1, DOMAIN=1, MAHAL=1, MAHAL01=0,
    ENSEMBLE.tune=TRUE, PROBIT=TRUE,
    ENSEMBLE.best=0, ENSEMBLE.exponent=c(1, 1.5, 2),
    ENSEMBLE.min=0.55,
    Yweights="BIOMOD",
    PLOTS=FALSE, formulae.defaults=TRUE)
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## 
## 
## Bradypus 4-FOLD CROSS-VALIDATION RUN: 1
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## Loading required namespace: maxnet
## Loading required namespace: maxlike
## Loading required namespace: glmnet
## 
## Spatial sorting bias (dismo package, no bias=1, extreme bias=0): 0.90874897983056
## 
## Summary of Training data set used for calibrations (rows: 727)
##        pb               bio5          bio6           bio16          bio17     
##  Min.   :0.00000   Min.   :100   Min.   :-91.0   Min.   :   9   Min.   :   0  
##  1st Qu.:0.00000   1st Qu.:309   1st Qu.:163.0   1st Qu.: 706   1st Qu.:  75  
##  Median :0.00000   Median :322   Median :195.0   Median : 866   Median : 149  
##  Mean   :0.09904   Mean   :311   Mean   :175.1   Mean   : 859   Mean   : 207  
##  3rd Qu.:0.00000   3rd Qu.:331   3rd Qu.:210.0   3rd Qu.:1000   3rd Qu.: 277  
##  Max.   :1.00000   Max.   :361   Max.   :232.0   Max.   :2426   Max.   :1496  
## 
## 'data.frame':    727 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  299 313 288 279 325 313 290 330 313 262 ...
##  $ bio6 : num  217 192 176 171 224 219 171 214 174 143 ...
##  $ bio16: num  1663 885 1481 859 1250 ...
##  $ bio17: num  957 9 180 403 136 95 365 140 75 256 ...
## 
## Summary of Testing data set used for evaluations (rows: 252)
##        pb               bio5            bio6            bio16       
##  Min.   :0.00000   Min.   :129.0   Min.   :-124.0   Min.   :   5.0  
##  1st Qu.:0.00000   1st Qu.:289.2   1st Qu.: 116.5   1st Qu.: 460.2  
##  Median :0.00000   Median :313.5   Median : 164.0   Median : 701.5  
##  Mean   :0.06746   Mean   :301.5   Mean   : 155.1   Mean   : 709.4  
##  3rd Qu.:0.00000   3rd Qu.:327.2   3rd Qu.: 208.2   3rd Qu.: 923.8  
##  Max.   :1.00000   Max.   :356.0   Max.   : 236.0   Max.   :2458.0  
##      bio17        
##  Min.   :   0.00  
##  1st Qu.:  63.25  
##  Median : 162.50  
##  Mean   : 207.94  
##  3rd Qu.: 281.00  
##  Max.   :1267.00  
## 
## 'data.frame':    252 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 320 259 329 327 319 317 315 324 333 ...
##  $ bio6 : num  165 214 86 150 220 205 197 204 212 219 ...
##  $ bio16: num  540 872 650 1547 807 ...
##  $ bio17: num  130 498 114 373 281 405 137 398 122 196 ...
## Warning in dismo::randomPoints(x[[1]], n = MAXENT.an, p = p, excludep = T):
## generated random points = 0.9703 times requested number
## 
## Summary of Training data set used for calibration of MAXENT or MAXLIKE model (rows: 9775, presence locations: 72)
##       bio5            bio6             bio16            bio17       
##  Min.   : 61.0   Min.   :-212.00   Min.   :   0.0   Min.   :   0.0  
##  1st Qu.:298.0   1st Qu.:  10.00   1st Qu.: 282.0   1st Qu.:  30.0  
##  Median :320.0   Median : 113.00   Median : 485.0   Median :  84.0  
##  Mean   :305.4   Mean   :  93.78   Mean   : 543.5   Mean   : 138.4  
##  3rd Qu.:334.0   3rd Qu.: 183.00   3rd Qu.: 810.0   3rd Qu.: 213.0  
##  Max.   :422.0   Max.   : 242.00   Max.   :2458.0   Max.   :1496.0  
## 
## 1. Maximum entropy algorithm (package: maxnet)
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 810.353565634884
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7761026 
## cor            : 0.3273995 
## max TPR+TNR at : 0.5968193 
## 
## Threshold (method: spec_sens) 
## [1] 0.5968193
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6440551 
## cor            : 0.09098566 
## max TPR+TNR at : 0.3010584 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.5968193 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.64405507  0.39649562  0.91535290 -0.01076345 -0.01898515  0.82352941 
##   MCR.fixed     AUCdiff 
##  0.23015873  0.13204756 
## 
## 2. Maxlike algorithm (package: maxlike)
## 
## Evaluation with calibration data of other algorithms
## 
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 913.643577279535
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7255301 
## cor            : 0.2941045 
## max TPR+TNR at : 0.5168992 
## 
## Threshold (method: spec_sens) 
## [1] 0.5168992
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6640801 
## cor            : 0.1019187 
## max TPR+TNR at : 0.3561894 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.51689922 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.66408010  0.36245307  0.90729450 -0.03554443 -0.07083267  0.88235294 
##   MCR.fixed     AUCdiff 
##  0.20238095  0.06145001 
## 
## 3. gbm step algorithm (package: dismo)
## Loading required namespace: gbm
## 
##  
##  GBM STEP - version 2.9 
##  
## Performing cross-validation optimisation of a boosted regression tree model 
## for pb and using a family of bernoulli 
## Using 727 observations and 4 predictors 
## creating 10 initial models of 50 trees 
## 
##  folds are stratified by prevalence 
## total mean deviance =  0.2746 
## tolerance is fixed at  3e-04 
## now adding trees... 
## restart model with a smaller learning rate or smaller step size...
##  WARNING: stepwise GBM calibration failed 
##  
## 
## 4. Random forest algorithm (package: randomForest)
## Warning in randomForest.default(m, y, ...): The response has five or fewer
## unique values. Are you sure you want to do regression?
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.47218569343473e-07
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5425532 
## cor            : 0.1763381 
## max TPR+TNR at : 0.8729978 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.54255319 0.10488110 0.35143911 0.05031289 0.25887968 0.94117647 0.07142857 
##    AUCdiff 
## 0.45744681 
## 
## 5. Generalized Linear Model
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 818.057018379001
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7699109 
## cor            : 0.3115877 
## max TPR+TNR at : 0.5698892 
## 
## Threshold (method: spec_sens) 
## [1] 0.5698892
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5814768 
## cor            : 0.07092405 
## max TPR+TNR at : 0.281454 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.56988919 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.58147685  0.37096370  0.84790124 -0.04906133 -0.08349516  0.82352941 
##   MCR.fixed     AUCdiff 
##  0.26587302  0.18843410 
## 
## 6. Stepwise Generalized Linear Model
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## stepwise GLM formula
## 
## pb ~ bio5 + bio6 + I(bio6^2) + I(bio16^3)
## <environment: 0x000000004ad6a178>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 841.080941714844
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7618109 
## cor            : 0.2881113 
## max TPR+TNR at : 0.5691456 
## 
## Threshold (method: spec_sens) 
## [1] 0.5691456
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6465582 
## cor            : 0.131868 
## max TPR+TNR at : 0.2500704 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.56914559 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.64655820 0.37521902 0.87657208 0.04305382 0.06705590 0.70588235 0.28174603 
##    AUCdiff 
## 0.11525266 
## 
## 7. Generalized Additive Model (package: gam)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 877.967517353067
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7427057 
## cor            : 0.2505 
## max TPR+TNR at : 0.5342755 
## 
## Threshold (method: spec_sens) 
## [1] 0.5342755
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6285357 
## cor            : 0.1266171 
## max TPR+TNR at : 0.1953774 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53427549 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.6285357  0.3872340  0.9143817  0.1294118  0.1857547  0.4705882  0.4047619 
##    AUCdiff 
##  0.1141700 
## 
## 8. Stepwise Generalized Additive Model (package: gam)
## 
## stepwise GAM formula (gam package)
## 
## pb ~ bio5 + bio6 + bio16
## <environment: 0x000000004ad6a178>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 878.112645734822
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7427693 
## cor            : 0.2503052 
## max TPR+TNR at : 0.6354886 
## 
## Threshold (method: spec_sens) 
## [1] 0.6354886
## 
## Evaluation with test data
## 
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6285357 
## cor            : 0.1253948 
## max TPR+TNR at : 0.19578 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.63548855 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.62853567  0.38723404  0.91438172 -0.06107635 -0.11708358  0.88235294 
##   MCR.fixed     AUCdiff 
##  0.22619048  0.11423363 
## 
## 9. Generalized Additive Model (package: mgcv)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 830.18526389636
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7710984 
## cor            : 0.2998366 
## max TPR+TNR at : 0.5586143 
## 
## Threshold (method: spec_sens) 
## [1] 0.5586143
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6463079 
## cor            : 0.1321264 
## max TPR+TNR at : 0.3819409 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.55861432 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.64630788 0.37171464 0.86901765 0.09336671 0.14140873 0.64705882 0.28571429 
##    AUCdiff 
## 0.12479050 
## 
## 10. Multivariate Adaptive Regression Splines (package: earth)
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 789.149434644353
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7905428 
## cor            : 0.4148765 
## max TPR+TNR at : 0.4002572 
## 
## Threshold (method: spec_sens) 
## [1] 0.4002572
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5809762 
## cor            : -0.004648332 
## max TPR+TNR at : 0.3437202 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.40025722 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5809762  0.3171464  0.4569574  0.1421777  0.2039194  0.4705882  0.3928571 
##    AUCdiff 
##  0.2095666 
## 
## 11. Recursive Partitioning And Regression Trees (package: rpart)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 383.097236405293
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.9516858 
## cor            : 0.6332442 
## max TPR+TNR at : 0.3869225 
## 
## Threshold (method: spec_sens) 
## [1] 0.3869225
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.514393 
## cor            : 0.02300777 
## max TPR+TNR at : 0.6322127 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.38692246 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.51439299 0.05581977 0.08740705 0.04730914 0.07381353 0.70588235 0.27777778 
##    AUCdiff 
## 0.43729276 
## 
## 12. Artificial Neural Network (package: nnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 839.071584061446
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7303223 
## cor            : 0.2664291 
## max TPR+TNR at : 0.3051363 
## 
## Threshold (method: spec_sens) 
## [1] 0.3051363
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.653567 
## cor            : 0.130834 
## max TPR+TNR at : 0.114852 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.30513632 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.65356696 0.34117647 0.84385692 0.23354193 0.33302030 0.29411765 0.46031746 
##    AUCdiff 
## 0.07675535 
## 
## 13. Flexible Discriminant Analysis (package: mda)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 895.183093283968
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7908185 
## cor            : 0.3654456 
## max TPR+TNR at : 0.401715 
## 
## Threshold (method: spec_sens) 
## [1] 0.401715
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5341677 
## cor            : -0.0232612 
## max TPR+TNR at : 0.3836274 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.40171501 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5341677  0.1667084  0.7992177  0.0718398  0.1074428  0.2941176  0.6111111 
##    AUCdiff 
##  0.2566508 
## 
## 14. Support Vector Machines (package: kernlab)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 790.938342680976
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.8600933 
## cor            : 0.5333724 
## max TPR+TNR at : 0.4093749 
## 
## Threshold (method: spec_sens) 
## [1] 0.4093749
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5737171 
## cor            : 0.008223083 
## max TPR+TNR at : 0.4021395 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.40937489 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.57371715  0.25056320  0.84790124 -0.02578223 -0.03802222  0.64705882 
##   MCR.fixed     AUCdiff 
##  0.39682540  0.28637615 
## 
## 15. Support Vector Machines (package: e1071)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 964.314040105321
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.65 
## cor            : 0.1988407 
## max TPR+TNR at : 0.4955357 
## 
## Threshold (method: spec_sens) 
## [1] 0.4955357
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5479349 
## cor            : 0.05130369 
## max TPR+TNR at : 0.4649156 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.49553573 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.54793492  0.21852315  0.79209113 -0.04205257 -0.06349733  0.70588235 
##   MCR.fixed     AUCdiff 
##  0.36111111  0.10206508 
## 
## 16. GLM with lasso or elasticnet regularization (package: glmnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 877.546679196532
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7410941 
## cor            : 0.251283 
## max TPR+TNR at : 0.650828 
## 
## Threshold (method: spec_sens) 
## [1] 0.650828
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6305382 
## cor            : 0.1300351 
## max TPR+TNR at : 0.1970352 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.650828 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.63053817  0.38297872  0.91340066 -0.07734668 -0.18377162  0.94117647 
##   MCR.fixed     AUCdiff 
##  0.19047619  0.11055597 
## 
## 17. BIOCLIM algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1007.82790472318
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.4786047 
## cor            : 0.001946175 
## max TPR+TNR at : 0.4993677 
## 
## Threshold (method: spec_sens) 
## [1] 0.4993677
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.3411765 
## cor            : -0.1564191 
## max TPR+TNR at : 0.4966514 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.49936771 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.34117647  0.04255319  0.73607814 -0.19899875 -0.29695474  0.41176471 
##   MCR.fixed     AUCdiff 
##  0.76190476  0.13742828 
## 
## 18. DOMAIN algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 999.58464877763
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.4988656 
## cor            : 0.05757225 
## max TPR+TNR at : 0.432291 
## 
## Threshold (method: spec_sens) 
## [1] 0.432291
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.7132666 
## cor            : 0.1563618 
## max TPR+TNR at : 0.4991378 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.43229097 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7132666  0.3894869  0.8203711  0.2015019  0.3315675  0.1176471  0.6428571 
##    AUCdiff 
## -0.2144010 
## 
## 19. Mahalanobis algorithm (package: dismo)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.53446070318809e-07
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## Warning in cor(x, y): the standard deviation is zero
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.5 
## cor            : NA 
## max TPR+TNR at : -1e-04 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##        0.5        0.0        0.0         NA         NA         NA         NA 
##    AUCdiff 
##        0.5 
## 
## Weights tuned by ensemble.strategy function
## Warning in cor(x, y): the standard deviation is zero
## 
## Ensemble tuning result: best=0, exponent=1, min=0.55
## 
## Weights corresponding to best strategy
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.084838  0.087475  0.000000  0.000000  0.000000  0.000000  0.076595 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.085167  0.082793  0.082793  0.085134  0.000000  0.076529  0.000000  0.086091 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.075572  0.000000  0.083057  0.000000  0.000000  0.093955  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Minimum input weight is 0.05
## 
## Weights for ensemble forecasting
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.084838  0.087475  0.000000  0.000000  0.000000  0.000000  0.076595 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.085167  0.082793  0.082793  0.085134  0.000000  0.076529  0.000000  0.086091 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.075572  0.000000  0.083057  0.000000  0.000000  0.093955  0.000000 
##   MAHAL01 
##  0.000000 
## 
## 
## 20. Ensemble algorithm
## 
## Ensemble evaluation with calibration data
## 
## Residual deviance (dismo package): 814.016303514773
## Residual deviance if all predictions were 0.0990371389270977 (prevalence): 469.587018513245
## Residual deviance for worst possible predictions: 30131.6285639694
## 
## class          : ModelEvaluation 
## n presences    : 72 
## n absences     : 655 
## AUC            : 0.7863232 
## cor            : 0.3421811 
## max TPR+TNR at : 0.5622454 
## 
## Threshold (method: spec_sens) 
## [1] 0.5622454
## 
## Ensemble evaluation with testing data
## 
## class          : ModelEvaluation 
## n presences    : 17 
## n absences     : 235 
## AUC            : 0.6342929 
## cor            : 0.1228349 
## max TPR+TNR at : 0.3676449 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.56224541 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.63429287  0.40926158  0.89007354 -0.07809762 -0.14627994  0.88235294 
##   MCR.fixed     AUCdiff 
##  0.24206349  0.15203029 
## 
## 
## 
## finished model calibrations (function ensemble.calibrate.models)
## 
## Bradypus 4-FOLD CROSS-VALIDATION RUN: 2
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## 
## 
## 
## Spatial sorting bias (dismo package, no bias=1, extreme bias=0): 1.17257977087104
## 
## Summary of Training data set used for calibrations (rows: 745)
##        pb               bio5            bio6            bio16       
##  Min.   :0.00000   Min.   :100.0   Min.   :-124.0   Min.   :   5.0  
##  1st Qu.:0.00000   1st Qu.:300.0   1st Qu.: 139.0   1st Qu.: 587.0  
##  Median :0.00000   Median :319.0   Median : 194.0   Median : 827.0  
##  Mean   :0.08993   Mean   :306.4   Mean   : 166.3   Mean   : 806.9  
##  3rd Qu.:0.00000   3rd Qu.:329.0   3rd Qu.: 209.0   3rd Qu.: 984.0  
##  Max.   :1.00000   Max.   :361.0   Max.   : 236.0   Max.   :2458.0  
##      bio17       
##  Min.   :   0.0  
##  1st Qu.:  77.0  
##  Median : 164.0  
##  Mean   : 222.7  
##  3rd Qu.: 297.0  
##  Max.   :1496.0  
## 
## 'data.frame':    745 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 299 320 288 279 259 325 313 290 330 ...
##  $ bio6 : num  165 217 214 176 171 86 224 219 171 214 ...
##  $ bio16: num  540 1663 872 1481 859 ...
##  $ bio17: num  130 957 498 180 403 114 136 95 365 140 ...
## 
## Summary of Testing data set used for evaluations (rows: 234)
##        pb               bio5            bio6           bio16       
##  Min.   :0.00000   Min.   :135.0   Min.   : 27.0   Min.   :  31.0  
##  1st Qu.:0.00000   1st Qu.:315.2   1st Qu.:169.2   1st Qu.: 749.2  
##  Median :0.00000   Median :324.0   Median :187.5   Median : 861.5  
##  Mean   :0.09402   Mean   :315.7   Mean   :181.5   Mean   : 863.9  
##  3rd Qu.:0.00000   3rd Qu.:335.0   3rd Qu.:213.0   3rd Qu.: 980.5  
##  Max.   :1.00000   Max.   :355.0   Max.   :231.0   Max.   :1918.0  
##      bio17      
##  Min.   :  0.0  
##  1st Qu.: 66.0  
##  Median :106.5  
##  Mean   :157.9  
##  3rd Qu.:228.8  
##  Max.   :636.0  
## 
## 'data.frame':    234 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 338 283 316 307 329 325 247 299 277 ...
##  $ bio6 : num  192 191 156 202 202 227 187 125 204 160 ...
##  $ bio16: num  885 724 710 1295 1689 ...
##  $ bio17: num  9 62 32 359 268 230 256 182 488 300 ...
## Warning in dismo::randomPoints(x[[1]], n = MAXENT.an, p = p, excludep = T):
## generated random points = 0.9708 times requested number
## 
## Summary of Training data set used for calibration of MAXENT or MAXLIKE model (rows: 9775, presence locations: 67)
##       bio5            bio6             bio16            bio17       
##  Min.   : 61.0   Min.   :-212.00   Min.   :   0.0   Min.   :   0.0  
##  1st Qu.:298.0   1st Qu.:  10.00   1st Qu.: 282.0   1st Qu.:  30.0  
##  Median :320.0   Median : 113.00   Median : 485.0   Median :  84.0  
##  Mean   :305.4   Mean   :  93.78   Mean   : 543.5   Mean   : 138.4  
##  3rd Qu.:334.0   3rd Qu.: 183.00   3rd Qu.: 810.0   3rd Qu.: 213.0  
##  Max.   :422.0   Max.   : 242.00   Max.   :2458.0   Max.   :1496.0  
## 
## 1. Maximum entropy algorithm (package: maxnet)
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 887.954197573271
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.7282173 
## cor            : 0.2408048 
## max TPR+TNR at : 0.586652 
## 
## Threshold (method: spec_sens) 
## [1] 0.586652
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.80253 
## cor            : 0.3225988 
## max TPR+TNR at : 0.6164318 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.58665199 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.8025300  0.5686106  0.8287093  0.5403087  0.7054136  0.3181818  0.1581197 
##    AUCdiff 
## -0.0743127 
## 
## 2. Maxlike algorithm (package: maxlike)
## 
## Evaluation with calibration data of other algorithms
## 
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 993.753405152312
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6835733 
## cor            : 0.1929479 
## max TPR+TNR at : 0.4882751 
## 
## Threshold (method: spec_sens) 
## [1] 0.4882751
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7941681 
## cor            : 0.3394392 
## max TPR+TNR at : 0.4897413 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.48827509 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7941681  0.5274443  0.8964823  0.5227273  0.6803717  0.2272727  0.2478632 
##    AUCdiff 
## -0.1105948 
## 
## 3. gbm step algorithm (package: dismo)
## 
##  
##  GBM STEP - version 2.9 
##  
## Performing cross-validation optimisation of a boosted regression tree model 
## for pb and using a family of bernoulli 
## Using 745 observations and 4 predictors 
## creating 10 initial models of 50 trees 
## 
##  folds are stratified by prevalence 
## total mean deviance =  0.2493 
## tolerance is fixed at  2e-04 
## now adding trees... 
## restart model with a smaller learning rate or smaller step size...
##  WARNING: stepwise GBM calibration failed 
##  
## 
## 4. Random forest algorithm (package: randomForest)
## Warning in randomForest.default(m, y, ...): The response has five or fewer
## unique values. Are you sure you want to do regression?
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.50373088877729e-07
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.5114708 
## cor            : 0.1192836 
## max TPR+TNR at : 0.9998989 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.51147084 0.04545455 0.74091072 0.00000000 0.00000000 1.00000000 0.09401709 
##    AUCdiff 
## 0.48852916 
## 
## 5. Generalized Linear Model 
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 909.670711695597
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.7013164 
## cor            : 0.2178289 
## max TPR+TNR at : 0.4034717 
## 
## Threshold (method: spec_sens) 
## [1] 0.4034717
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8357633 
## cor            : 0.3643765 
## max TPR+TNR at : 0.7016582 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.40347171 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.83576329  0.54373928  0.90520013  0.39794168  0.62095754  0.04545455 
##   MCR.fixed     AUCdiff 
##  0.50854701 -0.13444687 
## 
## 6. Stepwise Generalized Linear Model 
## 
## stepwise GLM formula
## 
## pb ~ bio5 + bio6 + I(bio6^2)
## <environment: 0x000000004b3bc0e8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 934.608894815869
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6973099 
## cor            : 0.1916387 
## max TPR+TNR at : 0.5592964 
## 
## Threshold (method: spec_sens) 
## [1] 0.5592964
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8527015 
## cor            : 0.3383829 
## max TPR+TNR at : 0.6022867 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.55929641 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.8527015  0.6123499  0.9131911  0.5681818  0.7271311  0.1818182  0.2435897 
##    AUCdiff 
## -0.1553916 
## 
## 7. Generalized Additive Model (package: gam)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 940.720579644944
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6853564 
## cor            : 0.1881575 
## max TPR+TNR at : 0.3154525 
## 
## Threshold (method: spec_sens) 
## [1] 0.3154525
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8012436 
## cor            : 0.3020441 
## max TPR+TNR at : 0.5654921 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.31545246 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.8012436  0.5634648  0.8897287  0.2452830  0.8745791  0.0000000  0.6837607 
##    AUCdiff 
## -0.1158872 
## 
## 8. Stepwise Generalized Additive Model (package: gam)
## 
## stepwise GAM formula (gam package)
## 
## pb ~ bio5 + bio6 + bio16
## <environment: 0x000000004b3bc0e8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 941.996507292629
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.687822 
## cor            : 0.1867966 
## max TPR+TNR at : 0.5770362 
## 
## Threshold (method: spec_sens) 
## [1] 0.5770362
## 
## Evaluation with test data
## 
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7980274 
## cor            : 0.3006403 
## max TPR+TNR at : 0.5404848 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.57703622 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7980274  0.5445969  0.8897287  0.4506861  0.6032662  0.3181818  0.2393162 
##    AUCdiff 
## -0.1102055 
## 
## 9. Generalized Additive Model (package: mgcv)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 925.703736383427
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6913662 
## cor            : 0.201325 
## max TPR+TNR at : 0.3447495 
## 
## Threshold (method: spec_sens) 
## [1] 0.3447495
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8724271 
## cor            : 0.3745163 
## max TPR+TNR at : 0.6039599 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.34474953 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.8724271  0.6406518  0.8964823  0.2877358  0.8883184  0.0000000  0.6452991 
##    AUCdiff 
## -0.1810609 
## 
## 10. Multivariate Adaptive Regression Splines (package: earth)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 890.175400741442
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.751574 
## cor            : 0.3410029 
## max TPR+TNR at : 0.4286573 
## 
## Threshold (method: spec_sens) 
## [1] 0.4286573
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7673671 
## cor            : 0.3380852 
## max TPR+TNR at : 0.4356227 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.42865731 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.76736707  0.45411664  0.88395713  0.42581475  0.58458807  0.40909091 
##   MCR.fixed     AUCdiff 
##  0.18803419 -0.01579308 
## 
## 11. Recursive Partitioning And Regression Trees (package: rpart)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 419.809907163418
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.9431933 
## cor            : 0.5927605 
## max TPR+TNR at : 0.4228508 
## 
## Threshold (method: spec_sens) 
## [1] 0.4228508
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.6345412 
## cor            : 0.1767789 
## max TPR+TNR at : 0.8866764 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.42285076 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.6345412  0.2834477  0.4618964  0.2422813  0.3546877  0.5454545  0.2435897 
##    AUCdiff 
##  0.3086522 
## 
## 12. Artificial Neural Network (package: nnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 861.608375324027
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.7171003 
## cor            : 0.2695254 
## max TPR+TNR at : 0.5937862 
## 
## Threshold (method: spec_sens) 
## [1] 0.5937862
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7630789 
## cor            : 0.294166 
## max TPR+TNR at : 0.4710291 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.59378615 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.76307890  0.50728988  0.67134584  0.47298456  0.64618342  0.40909091 
##   MCR.fixed     AUCdiff 
##  0.14529915 -0.04597856 
## 
## 13. Flexible Discriminant Analysis (package: mda)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 974.221827969245
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.7061705 
## cor            : 0.2363254 
## max TPR+TNR at : 0.4727197 
## 
## Threshold (method: spec_sens) 
## [1] 0.4727197
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8548456 
## cor            : 0.4047673 
## max TPR+TNR at : 0.477276 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.47271968 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.85484563  0.65909091  0.90031619  0.63550600  0.79803084  0.09090909 
##   MCR.fixed     AUCdiff 
##  0.25641026 -0.14867515 
## 
## 14. Support Vector Machines (package: kernlab)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 794.155748556476
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.8643068 
## cor            : 0.473817 
## max TPR+TNR at : 0.4635516 
## 
## Threshold (method: spec_sens) 
## [1] 0.4635516
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7609348 
## cor            : 0.2910384 
## max TPR+TNR at : 0.4534362 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.46355164 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7609348  0.4661235  0.7963307  0.3722127  0.5107510  0.3636364  0.2735043 
##    AUCdiff 
##  0.1033720 
## 
## 15. Support Vector Machines (package: e1071)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1001.91342977735
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6215383 
## cor            : 0.1339396 
## max TPR+TNR at : 0.5008647 
## 
## Threshold (method: spec_sens) 
## [1] 0.5008647
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.5278731 
## cor            : 0.06680905 
## max TPR+TNR at : 0.5036022 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.50086465 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.52787307 0.20154374 0.79343155 0.06003431 0.08803740 0.59090909 0.37179487 
##    AUCdiff 
## 0.09366526 
## 
## 16. GLM with lasso or elasticnet regularization (package: glmnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 941.269223186775
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.6836393 
## cor            : 0.1866121 
## max TPR+TNR at : 0.3577482 
## 
## Threshold (method: spec_sens) 
## [1] 0.3577482
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.7864494 
## cor            : 0.2927883 
## max TPR+TNR at : 0.5598341 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.35774816 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7864494  0.5351630  0.8951694  0.2830189  0.8868868  0.0000000  0.6495726 
##    AUCdiff 
## -0.1028101 
## 
## 17. BIOCLIM algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1028.75749516216
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.5857659 
## cor            : 0.04174247 
## max TPR+TNR at : 0.4829592 
## 
## Threshold (method: spec_sens) 
## [1] 0.4829592
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.4978559 
## cor            : -0.04159028 
## max TPR+TNR at : 0.4734203 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.48295923 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.49785592  0.10463122  0.21905731 -0.02186964 -0.03158758  0.54545455 
##   MCR.fixed     AUCdiff 
##  0.48290598  0.08790994 
## 
## 18. DOMAIN algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1002.92985658073
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.576465 
## cor            : 0.1041596 
## max TPR+TNR at : 0.4646825 
## 
## Threshold (method: spec_sens) 
## [1] 0.4646825
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.4003002 
## cor            : -0.0167175 
## max TPR+TNR at : 0.3361813 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.46468254 corresponding to highest sum of sensitivity and specificity
##          AUC          TSS         SEDI    TSS.fixed   SEDI.fixed    FNR.fixed 
##  0.400300172  0.061320755  0.763201704 -0.009005146 -0.018148529  0.136363636 
##    MCR.fixed      AUCdiff 
##  0.803418803  0.176164849 
## 
## 19. Mahalanobis algorithm (package: dismo)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.57354013844622e-07
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## Warning in cor(x, y): the standard deviation is zero
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.5 
## cor            : NA 
## max TPR+TNR at : -1e-04 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##        0.5        0.0        0.0         NA         NA         NA         NA 
##    AUCdiff 
##        0.5 
## 
## Weights tuned by ensemble.strategy function
## Warning in cor(x, y): the standard deviation is zero
## 
## Ensemble tuning result: best=0, exponent=1, min=0.55
## 
## Weights corresponding to best strategy
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.077734  0.076924  0.000000  0.000000  0.000000  0.000000  0.080953 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.082593  0.077609  0.077298  0.084504  0.000000  0.074328  0.061462  0.073913 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.082801  0.073705  0.000000  0.076176  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Minimum input weight is 0.05
## 
## Weights for ensemble forecasting
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.077734  0.076924  0.000000  0.000000  0.000000  0.000000  0.080953 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.082593  0.077609  0.077298  0.084504  0.000000  0.074328  0.061462  0.073913 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.082801  0.073705  0.000000  0.076176  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## 
## 20. Ensemble algorithm
## 
## Ensemble evaluation with calibration data
## 
## Residual deviance (dismo package): 827.882018690103
## Residual deviance if all predictions were 0.0899328859060403 (prevalence): 450.549951939978
## Residual deviance for worst possible predictions: 30877.6661354005
## 
## class          : ModelEvaluation 
## n presences    : 67 
## n absences     : 678 
## AUC            : 0.821622 
## cor            : 0.3381637 
## max TPR+TNR at : 0.5275438 
## 
## Threshold (method: spec_sens) 
## [1] 0.5275438
## 
## Ensemble evaluation with testing data
## 
## class          : ModelEvaluation 
## n presences    : 22 
## n absences     : 212 
## AUC            : 0.8331904 
## cor            : 0.3708871 
## max TPR+TNR at : 0.5314427 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.52754379 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.83319039  0.57161235  0.90755188  0.56217839  0.72279342  0.27272727 
##   MCR.fixed     AUCdiff 
##  0.17521368 -0.01156842 
## 
## 
## 
## finished model calibrations (function ensemble.calibrate.models)
## 
## Bradypus 4-FOLD CROSS-VALIDATION RUN: 3
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## 
## 
## 
## Spatial sorting bias (dismo package, no bias=1, extreme bias=0): 0.842627345826849
## 
## Summary of Training data set used for calibrations (rows: 740)
##        pb               bio5            bio6            bio16       
##  Min.   :0.00000   Min.   :100.0   Min.   :-124.0   Min.   :   5.0  
##  1st Qu.:0.00000   1st Qu.:302.8   1st Qu.: 141.8   1st Qu.: 612.0  
##  Median :0.00000   Median :320.0   Median : 185.0   Median : 840.5  
##  Mean   :0.08514   Mean   :306.7   Mean   : 164.9   Mean   : 816.2  
##  3rd Qu.:0.00000   3rd Qu.:331.0   3rd Qu.: 210.0   3rd Qu.: 986.2  
##  Max.   :1.00000   Max.   :361.0   Max.   : 236.0   Max.   :2458.0  
##      bio17       
##  Min.   :   0.0  
##  1st Qu.:  66.0  
##  Median : 141.0  
##  Mean   : 195.1  
##  3rd Qu.: 267.2  
##  Max.   :1496.0  
## 
## 'data.frame':    740 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 313 320 279 259 313 290 262 329 317 ...
##  $ bio6 : num  165 192 214 171 86 219 171 143 150 150 ...
##  $ bio16: num  540 885 872 859 650 ...
##  $ bio17: num  130 9 498 403 114 95 365 256 373 146 ...
## 
## Summary of Testing data set used for evaluations (rows: 239)
##        pb              bio5            bio6           bio16       
##  Min.   :0.0000   Min.   :154.0   Min.   :-37.0   Min.   : 199.0  
##  1st Qu.:0.0000   1st Qu.:307.0   1st Qu.:183.0   1st Qu.: 690.0  
##  Median :0.0000   Median :321.0   Median :202.0   Median : 852.0  
##  Mean   :0.1088   Mean   :314.3   Mean   :185.6   Mean   : 833.8  
##  3rd Qu.:0.0000   3rd Qu.:328.0   3rd Qu.:209.0   3rd Qu.: 957.5  
##  Max.   :1.0000   Max.   :348.0   Max.   :232.0   Max.   :1663.0  
##      bio17      
##  Min.   :  4.0  
##  1st Qu.: 90.0  
##  Median :180.0  
##  Mean   :244.7  
##  3rd Qu.:375.5  
##  Max.   :957.0  
## 
## 'data.frame':    239 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  299 288 325 330 313 325 330 299 313 337 ...
##  $ bio6 : num  217 176 224 214 174 185 222 195 200 199 ...
##  $ bio16: num  1663 1481 1250 1286 631 ...
##  $ bio17: num  957 180 136 140 75 90 25 234 419 88 ...
## Warning in dismo::randomPoints(x[[1]], n = MAXENT.an, p = p, excludep = T):
## generated random points = 0.9712 times requested number
## 
## Summary of Training data set used for calibration of MAXENT or MAXLIKE model (rows: 9775, presence locations: 63)
##       bio5            bio6             bio16            bio17       
##  Min.   : 61.0   Min.   :-212.00   Min.   :   0.0   Min.   :   0.0  
##  1st Qu.:298.0   1st Qu.:  10.00   1st Qu.: 282.0   1st Qu.:  30.0  
##  Median :320.0   Median : 113.00   Median : 485.0   Median :  84.0  
##  Mean   :305.4   Mean   :  93.78   Mean   : 543.5   Mean   : 138.4  
##  3rd Qu.:334.0   3rd Qu.: 183.00   3rd Qu.: 810.0   3rd Qu.: 213.0  
##  Max.   :422.0   Max.   : 242.00   Max.   :2458.0   Max.   :1496.0  
## 
## 1. Maximum entropy algorithm (package: maxnet)
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 802.821077781712
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7982931 
## cor            : 0.3237546 
## max TPR+TNR at : 0.5658755 
## 
## Threshold (method: spec_sens) 
## [1] 0.5658755
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.531961 
## cor            : 0.06306388 
## max TPR+TNR at : 0.7257242 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.56587553 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.53196100 0.17912604 0.72872461 0.07385338 0.11177212 0.65384615 0.31380753 
##    AUCdiff 
## 0.26633213 
## 
## 2. Maxlike algorithm (package: maxlike)
## 
## Evaluation with calibration data of other algorithms
## 
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 929.60311120486
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7614358 
## cor            : 0.2760683 
## max TPR+TNR at : 0.4914776 
## 
## Threshold (method: spec_sens) 
## [1] 0.4914776
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5724088 
## cor            : 0.1958101 
## max TPR+TNR at : 0.6499242 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.49147756 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5724088  0.2316721  0.8335890  0.1198989  0.1906978  0.6923077  0.2426778 
##    AUCdiff 
##  0.1890270 
## 
## 3. gbm step algorithm (package: dismo)
## 
##  
##  GBM STEP - version 2.9 
##  
## Performing cross-validation optimisation of a boosted regression tree model 
## for pb and using a family of bernoulli 
## Using 740 observations and 4 predictors 
## creating 10 initial models of 50 trees 
## 
##  folds are stratified by prevalence 
## total mean deviance =  0.236 
## tolerance is fixed at  2e-04 
## now adding trees... 
## restart model with a smaller learning rate or smaller step size...
##  WARNING: stepwise GBM calibration failed 
##  
## 
## 4. Random forest algorithm (package: randomForest)
## Warning in randomForest.default(m, y, ...): The response has five or fewer
## unique values. Are you sure you want to do regression?
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.50165013321675e-07
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5169736 
## cor            : -0.04390413 
## max TPR+TNR at : 0.00307755 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##          AUC          TSS         SEDI    TSS.fixed   SEDI.fixed    FNR.fixed 
##  0.516973637  0.014987360  0.071996282 -0.009389671 -0.632441754  1.000000000 
##    MCR.fixed      AUCdiff 
##  0.117154812  0.483026363 
## 
## 5. Generalized Linear Model
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 796.228853889476
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.8065462 
## cor            : 0.3182476 
## max TPR+TNR at : 0.5316307 
## 
## Threshold (method: spec_sens) 
## [1] 0.5316307
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.4779704 
## cor            : -0.00692887 
## max TPR+TNR at : 0.713937 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53163068 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.47797039  0.15565186  0.78047577 -0.07349224 -0.11146003  0.73076923 
##   MCR.fixed     AUCdiff 
##  0.38493724  0.32857577 
## 
## 6. Stepwise Generalized Linear Model 
## 
## stepwise GLM formula
## 
## pb ~ bio5 + bio6 + I(bio5^2) + bio16 + bio17
## <environment: 0x000000004d3a62a8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 822.472268151552
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7882816 
## cor            : 0.3032926 
## max TPR+TNR at : 0.6132218 
## 
## Threshold (method: spec_sens) 
## [1] 0.6132218
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5312387 
## cor            : 0.06788657 
## max TPR+TNR at : 0.7017544 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.61322183 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5312387  0.2372698  0.7804758  0.1011195  0.1594035  0.6923077  0.2594142 
##    AUCdiff 
##  0.2570429 
## 
## 7. Generalized Additive Model (package: gam)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 866.29322066876
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7668753 
## cor            : 0.2602017 
## max TPR+TNR at : 0.5932387 
## 
## Threshold (method: spec_sens) 
## [1] 0.5932387
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.56645 
## cor            : 0.1016259 
## max TPR+TNR at : 0.7303006 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.59323873 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5664500  0.2128927  0.8069838  0.1058144  0.1671631  0.6923077  0.2552301 
##    AUCdiff 
##  0.2004254 
## 
## 8. Stepwise Generalized Additive Model (package: gam)
## 
## stepwise GAM formula (gam package)
## 
## pb ~ bio5 + bio6 + bio16 + bio17
## <environment: 0x000000004d3a62a8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 866.29322066876
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7668753 
## cor            : 0.2602017 
## max TPR+TNR at : 0.5932387 
## 
## Threshold (method: spec_sens) 
## [1] 0.5932387
## 
## Evaluation with test data
## 
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.56645 
## cor            : 0.1016259 
## max TPR+TNR at : 0.7303006 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.59323873 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5664500  0.2128927  0.8069838  0.1058144  0.1671631  0.6923077  0.2552301 
##    AUCdiff 
##  0.2004254 
## 
## 9. Generalized Additive Model (package: mgcv)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 823.028252749141
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7890788 
## cor            : 0.3030359 
## max TPR+TNR at : 0.6042554 
## 
## Threshold (method: spec_sens) 
## [1] 0.6042554
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5379198 
## cor            : 0.07761415 
## max TPR+TNR at : 0.7103794 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.60425537 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5379198  0.2372698  0.7287246  0.1011195  0.1594035  0.6923077  0.2594142 
##    AUCdiff 
##  0.2511590 
## 
## 10. Multivariate Adaptive Regression Splines (package: earth)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 753.628641779813
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.839019 
## cor            : 0.4551793 
## max TPR+TNR at : 0.3623802 
## 
## Threshold (method: spec_sens) 
## [1] 0.3623802
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5 
## cor            : 0.03926457 
## max TPR+TNR at : 0.5110298 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.36238015 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.50000000  0.10310581  0.78331857 -0.07818707 -0.11837077  0.73076923 
##   MCR.fixed     AUCdiff 
##  0.38912134  0.33901901 
## 
## 11. Recursive Partitioning And Regression Trees (package: rpart)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 412.90198831772
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.9470001 
## cor            : 0.5859154 
## max TPR+TNR at : 0.6009785 
## 
## Threshold (method: spec_sens) 
## [1] 0.6009785
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.498104 
## cor            : -0.002555194 
## max TPR+TNR at : 0.8530224 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.60097853 corresponding to highest sum of sensitivity and specificity
##          AUC          TSS         SEDI    TSS.fixed   SEDI.fixed    FNR.fixed 
##  0.498104009  0.036475262  0.108674568 -0.008667389 -0.014045459  0.769230769 
##    MCR.fixed      AUCdiff 
##  0.297071130  0.448896062 
## 
## 12. Artificial Neural Network (package: nnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 809.956373242648
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.756688 
## cor            : 0.2844542 
## max TPR+TNR at : 0.5077943 
## 
## Threshold (method: spec_sens) 
## [1] 0.5077943
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5556157 
## cor            : 0.09164944 
## max TPR+TNR at : 0.8006881 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.50779433 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.55561575 0.16504153 0.79596185 0.09407728 0.15132417 0.19230769 0.65690377 
##    AUCdiff 
## 0.20107226 
## 
## 13. Flexible Discriminant Analysis (package: mda)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 896.621819740008
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7922323 
## cor            : 0.3175591 
## max TPR+TNR at : 0.5099754 
## 
## Threshold (method: spec_sens) 
## [1] 0.5099754
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5301553 
## cor            : 0.1805512 
## max TPR+TNR at : 0.475419 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.50997536 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5301553  0.2118093  0.8355336  0.1527627  0.2473863  0.6923077  0.2133891 
##    AUCdiff 
##  0.2620770 
## 
## 14. Support Vector Machines (package: kernlab)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 699.539516013172
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.9041758 
## cor            : 0.537472 
## max TPR+TNR at : 0.4256343 
## 
## Threshold (method: spec_sens) 
## [1] 0.4256343
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5807151 
## cor            : 0.09811431 
## max TPR+TNR at : 0.3719518 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.42563432 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5807151  0.2388949  0.3378437  0.1921271  0.2918722  0.6153846  0.2384937 
##    AUCdiff 
##  0.3234607 
## 
## 15. Support Vector Machines (package: e1071)
## 
## Evaluation with calibration data
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1002.22246540568
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.6487069 
## cor            : 0.1789129 
## max TPR+TNR at : 0.4991169 
## 
## Threshold (method: spec_sens) 
## [1] 0.4991169
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.4989166 
## cor            : -0.07071331 
## max TPR+TNR at : 0.5047683 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.49911689 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.49891658 0.13308053 0.72872461 0.09172987 0.14400206 0.69230769 0.26778243 
##    AUCdiff 
## 0.14979037 
## 
## 16. GLM with lasso or elasticnet regularization (package: glmnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 867.464894583059
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.7631943 
## cor            : 0.258269 
## max TPR+TNR at : 0.600829 
## 
## Threshold (method: spec_sens) 
## [1] 0.600829
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5789094 
## cor            : 0.1145682 
## max TPR+TNR at : 0.727108 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.60082897 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5789094  0.2316721  0.8198018  0.1152040  0.1828084  0.6923077  0.2468619 
##    AUCdiff 
##  0.1842849 
## 
## 17. BIOCLIM algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1004.73229412919
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.6316968 
## cor            : 0.09746284 
## max TPR+TNR at : 0.4752876 
## 
## Threshold (method: spec_sens) 
## [1] 0.4752876
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.4818527 
## cor            : -0.05530067 
## max TPR+TNR at : 0.4506361 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.47528764 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.48185265  0.12405200  0.22109315 -0.02112676 -0.03047799  0.50000000 
##   MCR.fixed     AUCdiff 
##  0.51882845  0.14984414 
## 
## 18. DOMAIN algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1004.77707127747
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.5844177 
## cor            : 0.0857572 
## max TPR+TNR at : 0.4889108 
## 
## Threshold (method: spec_sens) 
## [1] 0.4889108
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.4693933 
## cor            : 0.07715664 
## max TPR+TNR at : 0.4229344 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.48891082 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.46939328 0.15023474 0.83358896 0.06301914 0.12128650 0.11538462 0.74476987 
##    AUCdiff 
## 0.11502443 
## 
## 19. Mahalanobis algorithm (package: dismo)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.52508588659615e-07
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## Warning in cor(x, y): the standard deviation is zero
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.5 
## cor            : NA 
## max TPR+TNR at : -1e-04 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##        0.5        0.0        0.0         NA         NA         NA         NA 
##    AUCdiff 
##        0.5 
## 
## Weights tuned by ensemble.strategy function
## Warning in cor(x, y): the standard deviation is zero
## 
## Ensemble tuning result: best=0, exponent=1, min=0.55
## 
## Weights corresponding to best strategy
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.000000  0.167344  0.000000  0.000000  0.000000  0.000000  0.000000 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.000000  0.165602  0.165602  0.000000  0.000000  0.000000  0.000000  0.162435 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.169772  0.000000  0.169245  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Minimum input weight is 0.05
## 
## Weights for ensemble forecasting
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.000000  0.167344  0.000000  0.000000  0.000000  0.000000  0.000000 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.000000  0.165602  0.165602  0.000000  0.000000  0.000000  0.000000  0.162435 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.169772  0.000000  0.169245  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## 
## 20. Ensemble algorithm
## 
## Ensemble evaluation with calibration data
## 
## Residual deviance (dismo package): 775.606005937507
## Residual deviance if all predictions were 0.0851351351351351 (prevalence): 430.880396524805
## Residual deviance for worst possible predictions: 30670.4334769744
## 
## class          : ModelEvaluation 
## n presences    : 63 
## n absences     : 677 
## AUC            : 0.8384563 
## cor            : 0.3729042 
## max TPR+TNR at : 0.484606 
## 
## Threshold (method: spec_sens) 
## [1] 0.484606
## 
## Ensemble evaluation with testing data
## 
## class          : ModelEvaluation 
## n presences    : 26 
## n absences     : 213 
## AUC            : 0.570242 
## cor            : 0.1524545 
## max TPR+TNR at : 0.6027442 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.48460604 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.57024196 0.20819791 0.84094707 0.06067172 0.08977417 0.61538462 0.35564854 
##    AUCdiff 
## 0.26821434 
## 
## 
## 
## finished model calibrations (function ensemble.calibrate.models)
## 
## Bradypus 4-FOLD CROSS-VALIDATION RUN: 4
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## 
## 
## 
## Spatial sorting bias (dismo package, no bias=1, extreme bias=0): 0.695237438026846
## 
## Summary of Training data set used for calibrations (rows: 725)
##        pb               bio5            bio6            bio16       
##  Min.   :0.00000   Min.   :129.0   Min.   :-124.0   Min.   :   5.0  
##  1st Qu.:0.00000   1st Qu.:305.0   1st Qu.: 148.0   1st Qu.: 636.0  
##  Median :0.00000   Median :320.0   Median : 194.0   Median : 831.0  
##  Mean   :0.08966   Mean   :310.3   Mean   : 173.7   Mean   : 800.3  
##  3rd Qu.:0.00000   3rd Qu.:330.0   3rd Qu.: 209.0   3rd Qu.: 956.0  
##  Max.   :1.00000   Max.   :356.0   Max.   : 236.0   Max.   :2458.0  
##      bio17       
##  Min.   :   0.0  
##  1st Qu.:  73.0  
##  Median : 148.0  
##  Mean   : 203.9  
##  3rd Qu.: 281.0  
##  Max.   :1267.0  
## 
## 'data.frame':    725 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 299 313 320 288 259 325 330 313 329 ...
##  $ bio6 : num  165 217 192 214 176 86 224 214 174 150 ...
##  $ bio16: num  540 1663 885 872 1481 ...
##  $ bio17: num  130 957 9 498 180 114 136 140 75 373 ...
## 
## Summary of Testing data set used for evaluations (rows: 254)
##        pb               bio5            bio6           bio16       
##  Min.   :0.00000   Min.   :100.0   Min.   :-91.0   Min.   :   9.0  
##  1st Qu.:0.00000   1st Qu.:301.2   1st Qu.:146.5   1st Qu.: 655.5  
##  Median :0.00000   Median :320.5   Median :188.0   Median : 878.0  
##  Mean   :0.09449   Mean   :303.7   Mean   :159.4   Mean   : 878.3  
##  3rd Qu.:0.00000   3rd Qu.:330.8   3rd Qu.:209.0   3rd Qu.:1071.8  
##  Max.   :1.00000   Max.   :361.0   Max.   :227.0   Max.   :2426.0  
##      bio17        
##  Min.   :   0.00  
##  1st Qu.:  75.25  
##  Median : 154.50  
##  Mean   : 216.76  
##  3rd Qu.: 271.25  
##  Max.   :1496.00  
## 
## 'data.frame':    254 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  279 313 290 262 317 342 312 306 206 343 ...
##  $ bio6 : num  171 219 171 143 150 227 218 220 91 218 ...
##  $ bio16: num  859 776 1364 657 516 ...
##  $ bio17: num  403 95 365 256 146 ...
## Warning in dismo::randomPoints(x[[1]], n = MAXENT.an, p = p, excludep = T):
## generated random points = 0.971 times requested number
## 
## Summary of Training data set used for calibration of MAXENT or MAXLIKE model (rows: 9775, presence locations: 65)
##       bio5            bio6             bio16            bio17       
##  Min.   : 61.0   Min.   :-212.00   Min.   :   0.0   Min.   :   0.0  
##  1st Qu.:298.0   1st Qu.:  10.00   1st Qu.: 282.0   1st Qu.:  30.0  
##  Median :320.0   Median : 113.00   Median : 485.0   Median :  84.0  
##  Mean   :305.4   Mean   :  93.78   Mean   : 543.5   Mean   : 138.4  
##  3rd Qu.:334.0   3rd Qu.: 183.00   3rd Qu.: 810.0   3rd Qu.: 213.0  
##  Max.   :422.0   Max.   : 242.00   Max.   :2458.0   Max.   :1496.0  
## 
## 1. Maximum entropy algorithm (package: maxnet)
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 867.768092383069
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7335897 
## cor            : 0.2525935 
## max TPR+TNR at : 0.4326564 
## 
## Threshold (method: spec_sens) 
## [1] 0.4326564
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7586957 
## cor            : 0.2775998 
## max TPR+TNR at : 0.6226345 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.4326564 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.75869565  0.45797101  0.89685576  0.33260870  0.46377217  0.25000000 
##   MCR.fixed     AUCdiff 
##  0.40157480 -0.02510591 
## 
## 2. Maxlike algorithm (package: maxlike)
## 
## Evaluation with calibration data of other algorithms
## 
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 932.808377914518
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.5859441 
## cor            : 0.1480042 
## max TPR+TNR at : 0.5349816 
## 
## Threshold (method: spec_sens) 
## [1] 0.5349816
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.570471 
## cor            : 0.09477008 
## max TPR+TNR at : 0.5561236 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53498155 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.57047101 0.13405797 0.25718087 0.12971014 0.25040817 0.08333333 0.72047244 
##    AUCdiff 
## 0.01547304 
## 
## 3. gbm step algorithm (package: dismo)
## 
##  
##  GBM STEP - version 2.9 
##  
## Performing cross-validation optimisation of a boosted regression tree model 
## for pb and using a family of bernoulli 
## Using 725 observations and 4 predictors 
## creating 10 initial models of 50 trees 
## 
##  folds are stratified by prevalence 
## total mean deviance =  0.2486 
## tolerance is fixed at  2e-04 
## now adding trees... 
## restart model with a smaller learning rate or smaller step size...
##  WARNING: stepwise GBM calibration failed 
##  
## 
## 4. Random forest algorithm (package: randomForest)
## Warning in randomForest.default(m, y, ...): The response has five or fewer
## unique values. Are you sure you want to do regression?
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.46379108841946e-07
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.5946558 
## cor            : 0.2129202 
## max TPR+TNR at : 0.6629506 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5946558  0.1978261  0.3847637  0.1188406  0.2728944  0.8333333  0.1220472 
##    AUCdiff 
##  0.4053442 
## 
## 5. Generalized Linear Model 
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 839.621084229499
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7576457 
## cor            : 0.2670098 
## max TPR+TNR at : 0.4686543 
## 
## Threshold (method: spec_sens) 
## [1] 0.4686543
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7382246 
## cor            : 0.2649512 
## max TPR+TNR at : 0.6071378 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.46865433 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.73822464 0.45543478 0.86431705 0.38659420 0.52693685 0.29166667 0.31889764 
##    AUCdiff 
## 0.01942105 
## 
## 6. Stepwise Generalized Linear Model
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## stepwise GLM formula
## 
## pb ~ bio5 + bio6 + I(bio6^2) + I(bio16^3)
## <environment: 0x000000004f99d8c8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 866.706955981839
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.728648 
## cor            : 0.2408675 
## max TPR+TNR at : 0.3705048 
## 
## Threshold (method: spec_sens) 
## [1] 0.3705048
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7588768 
## cor            : 0.2704996 
## max TPR+TNR at : 0.6196669 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.37050484 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.75887681  0.46666667  0.88542059  0.28985507  0.42609834  0.16666667 
##   MCR.fixed     AUCdiff 
##  0.50787402 -0.03022879 
## 
## 7. Generalized Additive Model (package: gam)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 903.089519706755
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7047786 
## cor            : 0.204619 
## max TPR+TNR at : 0.5355097 
## 
## Threshold (method: spec_sens) 
## [1] 0.5355097
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.761413 
## cor            : 0.2487601 
## max TPR+TNR at : 0.6137515 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53550974 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.76141304  0.49094203  0.86925680  0.32137681  0.44679707  0.29166667 
##   MCR.fixed     AUCdiff 
##  0.37795276 -0.05663449 
## 
## 8. Stepwise Generalized Additive Model (package: gam)
## 
## stepwise GAM formula (gam package)
## 
## pb ~ bio5 + bio6 + bio16
## <environment: 0x000000004f99d8c8>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 903.086795666291
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7054312 
## cor            : 0.2047085 
## max TPR+TNR at : 0.5655216 
## 
## Threshold (method: spec_sens) 
## [1] 0.5655216
## 
## Evaluation with test data
## 
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7530797 
## cor            : 0.2463228 
## max TPR+TNR at : 0.6120017 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.5655216 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.75307971  0.48224638  0.87084687  0.37789855  0.51646240  0.29166667 
##   MCR.fixed     AUCdiff 
##  0.32677165 -0.04764847 
## 
## 9. Generalized Additive Model (package: mgcv)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 872.151367357043
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7258042 
## cor            : 0.2342837 
## max TPR+TNR at : 0.6002864 
## 
## Threshold (method: spec_sens) 
## [1] 0.6002864
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7693841 
## cor            : 0.2790214 
## max TPR+TNR at : 0.6585876 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.60028637 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.76938406  0.51449275  0.88268071  0.46666667  0.62321071  0.33333333 
##   MCR.fixed     AUCdiff 
##  0.21259843 -0.04357986 
## 
## 10. Multivariate Adaptive Regression Splines (package: earth)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 840.74096069155
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7735664 
## cor            : 0.3555165 
## max TPR+TNR at : 0.4071935 
## 
## Threshold (method: spec_sens) 
## [1] 0.4071935
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.6391304 
## cor            : 0.2407123 
## max TPR+TNR at : 0.4886197 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.4071935 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.6391304  0.4094203  0.5647615  0.2746377  0.3861714  0.4166667  0.3188976 
##    AUCdiff 
##  0.1344360 
## 
## 11. Recursive Partitioning And Regression Trees (package: rpart)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 366.276240346612
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.9562704 
## cor            : 0.6316701 
## max TPR+TNR at : 0.3852339 
## 
## Threshold (method: spec_sens) 
## [1] 0.3852339
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7024457 
## cor            : 0.2968233 
## max TPR+TNR at : 0.8857795 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.3852339 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7024457  0.4068841  0.5720772  0.3746377  0.5191483  0.4166667  0.2283465 
##    AUCdiff 
##  0.2538247 
## 
## 12. Artificial Neural Network (package: nnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 775.50008060589
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7874825 
## cor            : 0.3189295 
## max TPR+TNR at : 0.5574258 
## 
## Threshold (method: spec_sens) 
## [1] 0.5574258
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.6874094 
## cor            : 0.1934902 
## max TPR+TNR at : 0.2250329 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.55742577 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.6874094  0.3829710  0.8273314  0.3275362  0.4534930  0.3333333  0.3385827 
##    AUCdiff 
##  0.1000731 
## 
## 13. Flexible Discriminant Analysis (package: mda)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 921.390497585945
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7300117 
## cor            : 0.2818226 
## max TPR+TNR at : 0.4366517 
## 
## Threshold (method: spec_sens) 
## [1] 0.4366517
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7615942 
## cor            : 0.263003 
## max TPR+TNR at : 0.4719267 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.43665172 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.76159420  0.47173913  0.88542059  0.33949275  0.47749450  0.20833333 
##   MCR.fixed     AUCdiff 
##  0.42913386 -0.03158255 
## 
## 14. Support Vector Machines (package: kernlab)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 821.866089659255
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.8251282 
## cor            : 0.456279 
## max TPR+TNR at : 0.4477463 
## 
## Threshold (method: spec_sens) 
## [1] 0.4477463
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.5436594 
## cor            : 0.1410411 
## max TPR+TNR at : 0.7998089 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.44774629 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.5436594  0.2463768  0.6275115  0.1141304  0.1713446  0.6250000  0.2952756 
##    AUCdiff 
##  0.2814688 
## 
## 15. Support Vector Machines (package: e1071)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 897.822217238415
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.6359207 
## cor            : 0.229579 
## max TPR+TNR at : 0.5038073 
## 
## Threshold (method: spec_sens) 
## [1] 0.5038073
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.6463768 
## cor            : 0.1377122 
## max TPR+TNR at : 0.4936102 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.50380725 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.64637681  0.33115942  0.79377061  0.26449275  0.39892232  0.58333333 
##   MCR.fixed     AUCdiff 
##  0.19291339 -0.01045607 
## 
## 16. GLM with lasso or elasticnet regularization (package: glmnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 901.904847405156
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.7054079 
## cor            : 0.2063895 
## max TPR+TNR at : 0.5370758 
## 
## Threshold (method: spec_sens) 
## [1] 0.5370758
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7485507 
## cor            : 0.2369807 
## max TPR+TNR at : 0.6008599 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53707577 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7485507  0.4300725  0.8769500  0.2909420  0.4081622  0.2916667  0.4055118 
##    AUCdiff 
## -0.0431428 
## 
## 17. BIOCLIM algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1000.30321802655
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.5765851 
## cor            : 0.04621061 
## max TPR+TNR at : 0.462113 
## 
## Threshold (method: spec_sens) 
## [1] 0.462113
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.5355072 
## cor            : -0.00194189 
## max TPR+TNR at : 0.4802703 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.46211303 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.53550725 0.19963768 0.28766451 0.05181159 0.07809484 0.29166667 0.62204724 
##    AUCdiff 
## 0.04107784 
## 
## 18. DOMAIN algorithm (package: dismo)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 987.8561745041
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.5357925 
## cor            : 0.07980759 
## max TPR+TNR at : 0.4904946 
## 
## Threshold (method: spec_sens) 
## [1] 0.4904946
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.5595109 
## cor            : 0.04760795 
## max TPR+TNR at : 0.4958753 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.49049463 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.55951087  0.20471014  0.30553916  0.18731884  0.28189634  0.20833333 
##   MCR.fixed     AUCdiff 
##  0.56692913 -0.02371833 
## 
## 19. Mahalanobis algorithm (package: dismo)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1.48760412888086e-07
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 1 
## cor            : 1 
## max TPR+TNR at : 0.9999 
## 
## Threshold (method: spec_sens) 
## [1] 0.9999
## 
## Evaluation with test data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.4978261 
## cor            : -0.02030867 
## max TPR+TNR at : -1e-04 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.9999 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.4978261  0.0000000  0.0000000         NA         NA         NA         NA 
##    AUCdiff 
##  0.5021739 
## 
## Weights tuned by ensemble.strategy function
## Ensemble tuning result: best=0, exponent=1, min=0.55
## 
## Weights corresponding to best strategy
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.072604  0.054591  0.000000  0.000000  0.056906  0.000000  0.070645 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.072621  0.072864  0.072066  0.073627  0.000000  0.061162  0.067221  0.065782 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.072881  0.000000  0.061855  0.071633  0.000000  0.000000  0.053543  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Minimum input weight is 0.05
## 
## Weights for ensemble forecasting
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.072604  0.054591  0.000000  0.000000  0.056906  0.000000  0.070645 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.072621  0.072864  0.072066  0.073627  0.000000  0.061162  0.067221  0.065782 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.072881  0.000000  0.061855  0.071633  0.000000  0.000000  0.053543  0.000000 
##   MAHAL01 
##  0.000000 
## 
## 
## 20. Ensemble algorithm
## 
## Ensemble evaluation with calibration data
## 
## Residual deviance (dismo package): 724.548171211191
## Residual deviance if all predictions were 0.0896551724137931 (prevalence): 437.521972225824
## Residual deviance for worst possible predictions: 30048.7355009044
## 
## class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 660 
## AUC            : 0.9105594 
## cor            : 0.4465545 
## max TPR+TNR at : 0.5373193 
## 
## Threshold (method: spec_sens) 
## [1] 0.5373193
## 
## Ensemble evaluation with testing data
## 
## class          : ModelEvaluation 
## n presences    : 24 
## n absences     : 230 
## AUC            : 0.7625 
## cor            : 0.2814218 
## max TPR+TNR at : 0.5275096 
## 
## Results with ensemble.evaluate
## 
## Calculated fixed threshold of 0.53731932 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7625000  0.4797101  0.8626104  0.4050725  0.5590635  0.4166667  0.2007874 
##    AUCdiff 
##  0.1480594 
## 
## 
## 
## finished model calibrations (function ensemble.calibrate.models)
## 
## Results of ensemble.calibrate.weights sorted by average AUC for tests T_1 to T_4
## 
## columns T_1 to T_4 show the AUC for each 4-fold cross-validation run
## column MEAN.T shows the mean of the AUC
## 
## columns S_1 to S_4 show the weights for the ensemble model with best AUC
## column MEAN shows the mean of these weights
## 
##                 T_1       T_2       T_3       T_4    MEAN.T      S_1      S_2
## MGCV      0.6463079 0.8724271 0.5379198 0.7693841 0.7065097 0.085134 0.084504
## ENSEMBLE  0.6342929 0.8331904 0.5702420 0.7625000 0.7000563 0.000000 0.000000
## GLMSTEP   0.6465582 0.8527015 0.5312387 0.7588768 0.6973438 0.085167 0.082593
## GAM       0.6285357 0.8012436 0.5664500 0.7614130 0.6894106 0.082793 0.077609
## GAMSTEP   0.6285357 0.7980274 0.5664500 0.7530797 0.6865232 0.082793 0.077298
## GLMNET    0.6305382 0.7864494 0.5789094 0.7485507 0.6861119 0.083057 0.076176
## MAXNET    0.6440551 0.8025300 0.5319610 0.7586957 0.6843104 0.084838 0.077734
## FDA       0.5341677 0.8548456 0.5301553 0.7615942 0.6701907 0.000000 0.082801
## NNET      0.6535670 0.7630789 0.5556157 0.6874094 0.6649178 0.086091 0.073913
## GLM       0.5814768 0.8357633 0.4779704 0.7382246 0.6583588 0.076595 0.080953
## MAXLIKE   0.6640801 0.7941681 0.5724088 0.5704710 0.6502820 0.087475 0.076924
## EARTH     0.5809762 0.7673671 0.5000000 0.6391304 0.6218684 0.076529 0.074328
## SVM       0.5737171 0.7609348 0.5807151 0.5436594 0.6147566 0.075572 0.073705
## RPART     0.5143930 0.6345412 0.4981040 0.7024457 0.5873710 0.000000 0.061462
## SVME      0.5479349 0.5278731 0.4989166 0.6463768 0.5552753 0.000000 0.000000
## RF        0.5425532 0.5114708 0.5169736 0.5946558 0.5414134 0.000000 0.000000
## DOMAIN    0.7132666 0.4003002 0.4693933 0.5595109 0.5356177 0.093955 0.000000
## MAHAL     0.5000000 0.5000000 0.5000000 0.4978261 0.4994565 0.000000 0.000000
## BIOCLIM   0.3411765 0.4978559 0.4818527 0.5355072 0.4640981 0.000000 0.000000
## MAXENT    0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## GBM       0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## GBMSTEP   0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## CF        0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## MGCVFIX   0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## BIOCLIM.O 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
## MAHAL01   0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.000000
##                S_3      S_4       MEAN
## MGCV      0.000000 0.073627 0.06081625
## ENSEMBLE  0.000000 0.000000 0.00000000
## GLMSTEP   0.000000 0.072621 0.06009525
## GAM       0.165602 0.072864 0.09971700
## GAMSTEP   0.165602 0.072066 0.09943975
## GLMNET    0.169245 0.071633 0.10002775
## MAXNET    0.000000 0.072604 0.05879400
## FDA       0.000000 0.072881 0.03892050
## NNET      0.162435 0.065782 0.09705525
## GLM       0.000000 0.070645 0.05704825
## MAXLIKE   0.167344 0.054591 0.09658350
## EARTH     0.000000 0.061162 0.05300475
## SVM       0.169772 0.000000 0.07976225
## RPART     0.000000 0.067221 0.03217075
## SVME      0.000000 0.061855 0.01546375
## RF        0.000000 0.056906 0.01422650
## DOMAIN    0.000000 0.053543 0.03687450
## MAHAL     0.000000 0.000000 0.00000000
## BIOCLIM   0.000000 0.000000 0.00000000
## MAXENT    0.000000 0.000000 0.00000000
## GBM       0.000000 0.000000 0.00000000
## GBMSTEP   0.000000 0.000000 0.00000000
## CF        0.000000 0.000000 0.00000000
## MGCVFIX   0.000000 0.000000 0.00000000
## BIOCLIM.O 0.000000 0.000000 0.00000000
## MAHAL01   0.000000 0.000000 0.00000000
## 
## input weights for ensemble modelling based on MEAN column
##     MAXENT     MAXNET    MAXLIKE        GBM    GBMSTEP         RF         CF 
## 0.00000000 0.05879400 0.09658350 0.00000000 0.00000000 0.01422650 0.00000000 
##        GLM    GLMSTEP        GAM    GAMSTEP       MGCV    MGCVFIX      EARTH 
## 0.05704825 0.06009525 0.09971700 0.09943975 0.06081625 0.00000000 0.05300475 
##      RPART       NNET        FDA        SVM       SVME     GLMNET  BIOCLIM.O 
## 0.03217075 0.09705525 0.03892050 0.07976225 0.01546375 0.10002775 0.00000000 
##    BIOCLIM     DOMAIN      MAHAL    MAHAL01 
## 0.00000000 0.03687450 0.00000000 0.00000000 
## 
## Minimum input weight is 0.05
## 
## final suggested weights for ensemble forecasting
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.068180  0.112001  0.000000  0.000000  0.000000  0.000000  0.066154 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.069688  0.115634  0.115314  0.070523  0.000000  0.061466  0.000000  0.112548 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.092495  0.000000  0.115996  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Results with final weights for ensemble.evaluate for k = 1
## 
## Calculated fixed threshold of 0.57071186 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.63229036  0.40926158  0.89255731 -0.06107635 -0.11708358  0.88235294 
##   MCR.fixed     AUCdiff 
##  0.22619048  0.15462652 
## 
## Results with final weights for ensemble.evaluate for k = 2
## 
## Calculated fixed threshold of 0.53830718 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.83276158  0.56389365  0.90755188  0.47898799  0.63603359  0.31818182 
##   MCR.fixed     AUCdiff 
##  0.21367521 -0.09153409 
## 
## Results with final weights for ensemble.evaluate for k = 3
## 
## Calculated fixed threshold of 0.48838875 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
## 0.549295775 0.208197905 0.810367962 0.007222824 0.010988901 0.692307692 
##   MCR.fixed     AUCdiff 
## 0.343096234 0.285995309 
## 
## Results with final weights for ensemble.evaluate for k = 4
## 
## Calculated fixed threshold of 0.52718177 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
##  0.7490942  0.4224638  0.8572931  0.3884058  0.5294495  0.3333333  0.2834646 
##    AUCdiff 
##  0.0176657 
## 
## AUC for ensemble models based on suggested input weights (using presence and background data sets generated for 4-fold cross-validations)
##       T_1       T_2       T_3       T_4    MEAN.T 
## 0.6322904 0.8327616 0.5492958 0.7490942 0.6908605 
## 
## (Results with input weights inferred from MEAN.T column with similar procedures
## parameters for weighting of MEAN.T: ENSEMBLE.min=0.55, ENSEMBLE.best=0 and ENSEMBLE.exponent=1
## 
## Final suggested weights with this alternative procedure
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.074599  0.070889  0.000000  0.000000  0.000000  0.000000  0.071770 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.076019  0.075155  0.074840  0.077019  0.000000  0.067792  0.064031  0.072485 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.073059  0.067016  0.060532  0.074795  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## Results with alternative final weights for ensemble.evaluate for k = 1
## 
## Calculated fixed threshold of 0.51199886 corresponding to highest sum of sensitivity and specificity
##         AUC         TSS        SEDI   TSS.fixed  SEDI.fixed   FNR.fixed 
##  0.63354193  0.39649562  0.89132354 -0.06182728 -0.10409658  0.82352941 
##   MCR.fixed     AUCdiff 
##  0.27777778  0.20948182 
## 
## Results with alternative final weights for ensemble.evaluate for k = 2
## 
## Calculated fixed threshold of 0.5288244 corresponding to highest sum of sensitivity and specificity
##          AUC          TSS         SEDI    TSS.fixed   SEDI.fixed    FNR.fixed 
##  0.830831904  0.571612350  0.906383207  0.571612350  0.732573581  0.272727273 
##    MCR.fixed      AUCdiff 
##  0.166666667 -0.003112096 
## 
## Results with alternative final weights for ensemble.evaluate for k = 3
## 
## Calculated fixed threshold of 0.48860383 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.54153124 0.16413868 0.79979377 0.06915854 0.10453850 0.65384615 0.31799163 
##    AUCdiff 
## 0.33103916 
## 
## Results with alternative final weights for ensemble.evaluate for k = 4
## 
## Calculated fixed threshold of 0.50430734 corresponding to highest sum of sensitivity and specificity
##        AUC        TSS       SEDI  TSS.fixed SEDI.fixed  FNR.fixed  MCR.fixed 
## 0.75525362 0.46666667 0.85729307 0.39710145 0.54007748 0.33333333 0.27559055 
##    AUCdiff 
## 0.08532913 
## 
## AUC for ensemble models based on alternative input weights
##       T_1       T_2       T_3       T_4    MEAN.T 
## 0.6335419 0.8308319 0.5415312 0.7552536 0.6902897 
## )

5.2 Step 2: Calibrate models with all available observations

# step 1 generated the weights for each algorithm
model.weights <- ensemble.calibrate.step1$output.weights
model.weights
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.068180  0.112001  0.000000  0.000000  0.000000  0.000000  0.066154 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.069688  0.115634  0.115314  0.070523  0.000000  0.061466  0.000000  0.112548 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.092495  0.000000  0.115996  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000
x.batch <- ensemble.calibrate.step1$x
p.batch <- ensemble.calibrate.step1$p
a.batch <- ensemble.calibrate.step1$a

# step 2: calibrate models with all available presence locations
# weights determined in step 1 calculate ensemble in step 2
ensemble.calibrate.step2 <- ensemble.calibrate.models(
    x=x.batch, p=p.batch, a=a.batch, 
    SINK=FALSE, species.name="Bradypus",
    models.keep=TRUE,
    input.weights=model.weights,
    ENSEMBLE.tune=FALSE, PROBIT=TRUE,
    Yweights="BIOMOD",
    PLOTS=FALSE, formulae.defaults=TRUE)
## 
## NOTE: raster procedures will be done via the raster package, not terra
## This also allows usage of dismo::prepareData internally.
## 
## 
## 
## Summary of Training data set used for calibrations (rows: 979)
##        pb               bio5            bio6            bio16       
##  Min.   :0.00000   Min.   :100.0   Min.   :-124.0   Min.   :   5.0  
##  1st Qu.:0.00000   1st Qu.:305.0   1st Qu.: 147.5   1st Qu.: 642.0  
##  Median :0.00000   Median :320.0   Median : 192.0   Median : 844.0  
##  Mean   :0.09091   Mean   :308.6   Mean   : 170.0   Mean   : 820.5  
##  3rd Qu.:0.00000   3rd Qu.:330.0   3rd Qu.: 209.0   3rd Qu.: 982.5  
##  Max.   :1.00000   Max.   :361.0   Max.   : 236.0   Max.   :2458.0  
##      bio17       
##  Min.   :   0.0  
##  1st Qu.:  73.0  
##  Median : 150.0  
##  Mean   : 207.2  
##  3rd Qu.: 278.5  
##  Max.   :1496.0  
## 
## 'data.frame':    979 obs. of  5 variables:
##  $ pb   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ bio5 : num  313 299 313 320 288 279 259 325 313 290 ...
##  $ bio6 : num  165 217 192 214 176 171 86 224 219 171 ...
##  $ bio16: num  540 1663 885 872 1481 ...
##  $ bio17: num  130 957 9 498 180 403 114 136 95 365 ...
## 
## (no tests with separate data set)
## Warning in dismo::randomPoints(x[[1]], n = MAXENT.an, p = p, excludep = T):
## generated random points = 0.9686 times requested number
## 
## Summary of Training data set used for calibration of MAXENT or MAXLIKE model (rows: 9775, presence locations: 89)
##       bio5            bio6             bio16            bio17       
##  Min.   : 61.0   Min.   :-212.00   Min.   :   0.0   Min.   :   0.0  
##  1st Qu.:298.0   1st Qu.:  10.00   1st Qu.: 282.0   1st Qu.:  30.0  
##  Median :320.0   Median : 113.00   Median : 485.0   Median :  84.0  
##  Mean   :305.4   Mean   :  93.78   Mean   : 543.5   Mean   : 138.4  
##  3rd Qu.:334.0   3rd Qu.: 183.00   3rd Qu.: 810.0   3rd Qu.: 213.0  
##  Max.   :422.0   Max.   : 242.00   Max.   :2458.0   Max.   :1496.0  
## 
## 1. Maximum entropy algorithm (package: maxnet)
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 1146.12219550971
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7455877 
## cor            : 0.2703016 
## max TPR+TNR at : 0.6645901 
## 
## Threshold (method: spec_sens) 
## [1] 0.6645901
## 
## 2. Maxlike algorithm (package: maxlike)
## 
## Evaluation with calibration data of other algorithms
## 
## (Predictions transformed with probit link)
## Residual deviance (dismo package): 1265.48841598
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.715743 
## cor            : 0.2474918 
## max TPR+TNR at : 0.4934578 
## 
## Threshold (method: spec_sens) 
## [1] 0.4934578
## 
## 3. Generalized Linear Model 
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1149.23971586817
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7424694 
## cor            : 0.2601261 
## max TPR+TNR at : 0.594881 
## 
## Threshold (method: spec_sens) 
## [1] 0.594881
## 
## 4. Stepwise Generalized Linear Model
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## 
## stepwise GLM formula
## 
## pb ~ bio5 + bio6 + I(bio6^2) + I(bio16^3)
## <environment: 0x000000004cdb9e70>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1164.16687946911
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7398056 
## cor            : 0.2493777 
## max TPR+TNR at : 0.5406602 
## 
## Threshold (method: spec_sens) 
## [1] 0.5406602
## 
## 5. Generalized Additive Model (package: gam)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1203.31241809497
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.720048 
## cor            : 0.2201817 
## max TPR+TNR at : 0.4969979 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969979
## 
## 6. Stepwise Generalized Additive Model (package: gam)
## 
## stepwise GAM formula (gam package)
## 
## pb ~ bio5 + bio6 + bio16 + bio17
## <environment: 0x000000004cdb9e70>
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1203.31241809497
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.720048 
## cor            : 0.2201817 
## max TPR+TNR at : 0.4969979 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969979
## 
## 7. Generalized Additive Model (package: mgcv)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1162.43961901589
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7400707 
## cor            : 0.2507201 
## max TPR+TNR at : 0.6144972 
## 
## Threshold (method: spec_sens) 
## [1] 0.6144972
## 
## 8. Multivariate Adaptive Regression Splines (package: earth)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1152.92310191641
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7613306 
## cor            : 0.3437994 
## max TPR+TNR at : 0.4436354 
## 
## Threshold (method: spec_sens) 
## [1] 0.4436354
## 
## 9. Artificial Neural Network (package: nnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1193.05559343905
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.6959475 
## cor            : 0.2065151 
## max TPR+TNR at : 0.5145522 
## 
## Threshold (method: spec_sens) 
## [1] 0.5145522
## 
## 10. Support Vector Machines (package: kernlab)
## 
## Evaluation with calibration data
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1156.47612774477
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.8561419 
## cor            : 0.4741619 
## max TPR+TNR at : 0.4374135 
## 
## Threshold (method: spec_sens) 
## [1] 0.4374135
## 
## 11. GLM with lasso or elasticnet regularization (package: glmnet)
## 
## Evaluation with calibration data
## (Predictions transformed with probit link)
## 
## Residual deviance (dismo package): 1202.96841615351
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7194041 
## cor            : 0.220191 
## max TPR+TNR at : 0.5772913 
## 
## Threshold (method: spec_sens) 
## [1] 0.5772913
## 
## Ensemble weights based directly on input weights scaled to sum up to 1
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
##  0.000000  0.068180  0.112001  0.000000  0.000000  0.000000  0.000000  0.066154 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
##  0.069688  0.115634  0.115314  0.070523  0.000000  0.061466  0.000000  0.112548 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
##  0.000000  0.092495  0.000000  0.115996  0.000000  0.000000  0.000000  0.000000 
##   MAHAL01 
##  0.000000 
## 
## 
## 12. Ensemble algorithm
## 
## Ensemble evaluation with calibration data
## 
## Residual deviance (dismo package): 1143.91836273516
## Residual deviance if all predictions were 0.0909090909090909 (prevalence): 596.477478609808
## Residual deviance for worst possible predictions: 40576.1545590829
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.747898 
## cor            : 0.278103 
## max TPR+TNR at : 0.4482945 
## 
## Threshold (method: spec_sens) 
## [1] 0.4482945
## 
## 
## 
## finished model calibrations (function ensemble.calibrate.models)

6 Model projections

6.1 Model projections with the terra package

time1 <- Sys.time()
ensemble.terra.results <- ensemble.terra(xn=predictors.terra, 
    models.list=ensemble.calibrate.step2$models, 
    input.weights=model.weights,
    SINK=FALSE, evaluate=TRUE,
    RASTER.species.name="Bradypus_terra", RASTER.stack.name="base")
## 
## Start of predictions for organism: Bradypus_terra
## Predictions for SpatRaster: base
## ensemble raster layers will be saved in folder E:/Roeland/R/BiodiversityR/terra//ensembles
## 
## 
## 1. Maximum entropy algorithm (package: maxnet)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7455561 
## cor            : 0.2702589 
## max TPR+TNR at : 0.6639 
## 
## Threshold (method: spec_sens) 
## [1] 0.6639
## 
## 2. Maxlike algorithm (package: maxlike)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7155978 
## cor            : 0.2473861 
## max TPR+TNR at : 0.4929 
## 
## Threshold (method: spec_sens) 
## [1] 0.4929
## 
## 3. Generalized Linear Model 
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7424378 
## cor            : 0.2601328 
## max TPR+TNR at : 0.5939 
## 
## Threshold (method: spec_sens) 
## [1] 0.5939
## 
## 4. Stepwise Generalized Linear Model 
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7398687 
## cor            : 0.2493617 
## max TPR+TNR at : 0.5399 
## 
## Threshold (method: spec_sens) 
## [1] 0.5399
## 
## 5. Generalized Additive Model (package: gam)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7199722 
## cor            : 0.2201493 
## max TPR+TNR at : 0.4969 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969
## 
## 6. Stepwise Generalized Additive Model (package: gam)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7199722 
## cor            : 0.2201493 
## max TPR+TNR at : 0.4969 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969
## 
## 7. Generalized Additive Model (package: mgcv)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7401717 
## cor            : 0.2507587 
## max TPR+TNR at : 0.6139 
## 
## Threshold (method: spec_sens) 
## [1] 0.6139
## 
## 8. Multivariate Adaptive Regression Splines (package: earth)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7613748 
## cor            : 0.3437384 
## max TPR+TNR at : 0.4429 
## 
## Threshold (method: spec_sens) 
## [1] 0.4429
## 
## 9. Artificial Neural Network (package: nnet)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.6958654 
## cor            : 0.2065121 
## max TPR+TNR at : 0.5139 
## 
## Threshold (method: spec_sens) 
## [1] 0.5139
## 
## 10. Support Vector Machines (package: kernlab)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.8560535 
## cor            : 0.4742447 
## max TPR+TNR at : 0.4369 
## 
## Threshold (method: spec_sens) 
## [1] 0.4369
## 
## 11. GLM with lasso or elasticnet regularization (package: glmnet)
## Probit transformation
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7195367 
## cor            : 0.2202156 
## max TPR+TNR at : 0.5769 
## 
## Threshold (method: spec_sens) 
## [1] 0.5769
## 
## submodel thresholds for absence-presence used: 
## (thresholds recalculated from raster layers)
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
## 0.0000000 0.6639000 0.4929000 0.0000000 0.0000000 0.0000000 0.0000000 0.5939000 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
## 0.5399000 0.4969000 0.4969000 0.6139000 0.0000000 0.4429000 0.0000000 0.5139000 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
## 0.0000000 0.4369000 0.0000000 0.5769000 0.0000000 0.0000000 0.0000000 0.0000000 
##   MAHAL01  ENSEMBLE 
## 0.0000000 0.4482945 
## 
## 
## 12. Ensemble algorithm
## 
## Evaluation of created ensemble raster layer (ensembles//suitability//Bradypus_terra_base.tif) at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7478791 
## cor            : 0.2780881 
## max TPR+TNR at : 0.4539 
## 
## Threshold (method: spec_sens) 
## [1] 0.4539
## 
## End of modelling for organism: Bradypus_terra
## 
## Predictions were made for RasterStack: base
time2 <- Sys.time()
time.terra <- time2 - time1
time.terra
## Time difference of 5.038899 secs

6.2 Model projections with the raster package

time1 <- Sys.time()
ensemble.raster.results <- ensemble.raster(xn=predictors.raster, 
    models.list=ensemble.calibrate.step2$models, 
    input.weights=model.weights,
    SINK=FALSE, evaluate=TRUE,
    RASTER.format="GTiff",
    RASTER.species.name="Bradypus_raster", RASTER.stack.name="base")
## 
## Start of predictions for organism: Bradypus_raster
## Predictions for RasterStack: base
## ensemble raster layers will be saved in folder E:/Roeland/R/BiodiversityR/terra//ensembles
## 
## 
## 1. Maximum entropy algorithm (package: maxnet)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7455561 
## cor            : 0.2702589 
## max TPR+TNR at : 0.6639 
## 
## Threshold (method: spec_sens) 
## [1] 0.6639
## 
## 2. Maxlike algorithm (package: maxlike)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7155978 
## cor            : 0.2473861 
## max TPR+TNR at : 0.4929 
## 
## Threshold (method: spec_sens) 
## [1] 0.4929
## 
## 3. Generalized Linear Model 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7424378 
## cor            : 0.2601328 
## max TPR+TNR at : 0.5939 
## 
## Threshold (method: spec_sens) 
## [1] 0.5939
## 
## 4. Stepwise Generalized Linear Model 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7398687 
## cor            : 0.2493617 
## max TPR+TNR at : 0.5399 
## 
## Threshold (method: spec_sens) 
## [1] 0.5399
## 
## 5. Generalized Additive Model (package: gam)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7199722 
## cor            : 0.2201493 
## max TPR+TNR at : 0.4969 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969
## 
## 6. Stepwise Generalized Additive Model (package: gam)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7199722 
## cor            : 0.2201493 
## max TPR+TNR at : 0.4969 
## 
## Threshold (method: spec_sens) 
## [1] 0.4969
## 
## 7. Generalized Additive Model (package: mgcv)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7401717 
## cor            : 0.2507587 
## max TPR+TNR at : 0.6139 
## 
## Threshold (method: spec_sens) 
## [1] 0.6139
## 
## 8. Multivariate Adaptive Regression Splines (package: earth)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7613748 
## cor            : 0.3437384 
## max TPR+TNR at : 0.4429 
## 
## Threshold (method: spec_sens) 
## [1] 0.4429
## 
## 9. Artificial Neural Network (package: nnet)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.6958654 
## cor            : 0.2065121 
## max TPR+TNR at : 0.5139 
## 
## Threshold (method: spec_sens) 
## [1] 0.5139
## 
## 10. Support Vector Machines (package: kernlab)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.8560535 
## cor            : 0.4742447 
## max TPR+TNR at : 0.4369 
## 
## Threshold (method: spec_sens) 
## [1] 0.4369
## 
## 11. GLM with lasso or elasticnet regularization (package: glmnet)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## Probit transformation
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7195367 
## cor            : 0.2202156 
## max TPR+TNR at : 0.5769 
## 
## Threshold (method: spec_sens) 
## [1] 0.5769
## 
## submodel thresholds for absence-presence used: 
## (thresholds recalculated from raster layers)
##    MAXENT    MAXNET   MAXLIKE       GBM   GBMSTEP        RF        CF       GLM 
## 0.0000000 0.6639000 0.4929000 0.0000000 0.0000000 0.0000000 0.0000000 0.5939000 
##   GLMSTEP       GAM   GAMSTEP      MGCV   MGCVFIX     EARTH     RPART      NNET 
## 0.5399000 0.4969000 0.4969000 0.6139000 0.0000000 0.4429000 0.0000000 0.5139000 
##       FDA       SVM      SVME    GLMNET BIOCLIM.O   BIOCLIM    DOMAIN     MAHAL 
## 0.0000000 0.4369000 0.0000000 0.5769000 0.0000000 0.0000000 0.0000000 0.0000000 
##   MAHAL01  ENSEMBLE 
## 0.0000000 0.4482945 
## 
## 
## 12. Ensemble algorithm
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## Evaluation of created ensemble raster layer (ensembles//suitability//Bradypus_raster_base) at locations p and a
## 
## class          : ModelEvaluation 
## n presences    : 89 
## n absences     : 890 
## AUC            : 0.7478791 
## cor            : 0.2780881 
## max TPR+TNR at : 0.4539 
## 
## Threshold (method: spec_sens) 
## [1] 0.4539
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==================                                                    |  25%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |====================================================                  |  75%
  |                                                                            
  |======================================================================| 100%
## 
## 
## End of modelling for organism: Bradypus_raster
## 
## Predictions were made for RasterStack: base
time2 <- Sys.time()
time.raster <- time2 - time1
time.raster
## Time difference of 1.001704 mins

6.3 Comparison of processing times between terra and raster

time.terra - time.raster
## Time difference of -55.06332 secs
as.numeric(time.terra) / as.numeric(time.raster)
## [1] 5.030329

7 Mapping

7.1 Suitability map

In the ‘suitability’ folder, a suitability map with the weighted average suitability from the different algorithms is available.

suit.file <- paste0(getwd(), "//ensembles//suitability//Bradypus_terra_base.tif")
suit.raster <- terra::rast(suit.file)/1000
plot(suit.raster)

Areas above the absence-presence threshold can be highlighted with the following procedure. At the same time, areas below the threshold with a sensitivity (true positive rate) above 0.90 are shown.

pres.file <- paste0(getwd(), "//ensembles//presence//Bradypus_terra_base.tif")
pres.raster <- terra::rast(pres.file)
plot(pres.raster)

suit.raster.masked <- terra::mask(suit.raster,
                                  mask=pres.raster,
                                  maskvalue=0,
                                  updatevalue=NA) # calculate quantiles first
breaks1 <- quantile(as.data.frame(suit.raster.masked,
                                  xy=FALSE, na.rm=TRUE)[, 1])

p_values <- terra::extract(suit.raster, y=pres.env)[, 2]
a_values <- terra::extract(suit.raster, y=background3)[, 2]
breaks2 <- dismo::threshold(dismo::evaluate(p=p_values, a=a_values),
                            stat="sensitivity",
                            sensitivity=0.90)

breaks1 <- c(0.0, breaks2, breaks1)

suit.classified <- terra::classify(suit.raster, 
                                   rcl=as.matrix(breaks1),
                                   include.lowest=TRUE)

plot.colours <- RColorBrewer::brewer.pal(length(breaks1), "Greens")
plot.colours[1] <- "grey60"
plot.colours[2] <- "#D8B365"

plot(suit.classified, col=plot.colours)

suit.zoomed <- terra::crop(suit.classified,
                         y=c(bbox_study2["left"], bbox_study2["right"],
                             bbox_study2["bottom"], bbox_study2["top"]))

plot(suit.zoomed, col=plot.colours)

Country boundaries will be added that were downloaded as 1:10 million Admin 0 vector data from Natural Earth.

countries.file <- "C:\\Roeland_GIS\\Natural Earth NE\\ne_10m_admin_0_FrenchSplit.shp"
countries.poly <- sf::st_read(countries.file, crs=4326)
## Reading layer `ne_10m_admin_0_FrenchSplit' from data source `C:\Roeland_GIS\Natural Earth NE\ne_10m_admin_0_FrenchSplit.shp' using driver `ESRI Shapefile'
## Simple feature collection with 275 features and 188 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
## geographic CRS: WGS 84

To map via ggplot2, using geom_contour_filled is an appropriate method to match the projection system.

suit.data <- as.data.frame(suit.raster,
                           xy=TRUE,
                           na.rm=TRUE)
names(suit.data)[3] <- "suitability"

map_study <- ggplot() +
  geom_contour_filled(data=suit.data,
              aes(x=x, y=y, z=suitability),
              alpha=0.8, colour=NA, breaks=breaks1, show.legend=TRUE) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_sf(data=countries.poly,
          colour=alpha("grey50", alpha=0.5), fill=NA, size=0.4, alpha=0.3) +
  annotation_north_arrow(location="tr",
                         height=unit(1, "cm"),
                         width=unit(1, "cm")) +
  scale_fill_manual(values=plot.colours) +
  labs(fill="suitability") +
  theme(axis.title = element_blank(),
        panel.background = element_rect(fill="light steel blue"),
        legend.position=c(0.9, 0.8)) +
  coord_sf(xlim=c(bbox_study["left"], bbox_study["right"]),
           ylim=c(bbox_study["bottom"], bbox_study["top"]),
           crs=4326, expand=FALSE)
  
map_study

suit.zoomed2 <- terra::crop(suit.raster, snap="out",
                         y=c(bbox_study2["left"], bbox_study2["right"],
                             bbox_study2["bottom"], bbox_study2["top"]))

suit.data <- as.data.frame(suit.zoomed2,
                           xy=TRUE,
                           na.rm=TRUE)
names(suit.data)[3] <- "suitability"


map_study2 <- ggplot() +
  geom_contour_filled(data=suit.data,
              aes(x=x, y=y, z=suitability),
              alpha=0.8, colour=NA, breaks=breaks1, show.legend=TRUE) +
  geom_sf(data=countries.poly,
          colour=alpha("grey50", alpha=0.5), fill=NA, size=0.4, alpha=0.3) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  annotation_north_arrow(location="tr",
                         height=unit(1, "cm"),
                         width=unit(1, "cm")) +
  scale_fill_manual(values=plot.colours) +
  labs(fill="suitability") +
  theme(axis.title = element_blank(),
        panel.background = element_rect(fill="light steel blue"),
        legend.position=c(0.9, 0.8)) +
  coord_sf(xlim=c(bbox_study2["left"], bbox_study2["right"]),
           ylim=c(bbox_study2["bottom"], bbox_study2["top"]),
           crs=4326, expand=FALSE)
  
map_study2

7.2 Add an a posteriori distance contraining hull

Mendes et al. 2020 described and compared different a priori and a posteriori methods of adding distance constraints to reduce overprediction in species distribution modelling exercises. The Buffered Minimum Convex Polygon method was described as a reliable method. The convex hull of this method can be obtained via the function of BiodiversityR::ensemble.chull.create.

BMCP.hull <- BiodiversityR::ensemble.chull.create(p=pres,
                                                  buffer.maxmins=TRUE,
                                                  buffer.width=1,
                                                  poly.only=TRUE,
                                                  lonlat.dist=TRUE)
## 
## Creation of convex hull around presence locations
## Buffer around convex hull of 7.83522650916998 (1 * 7.83522650916998, where 7.83522650916998 is the maximum of the distances to the closest neighbour for each presence location)
## This maximum distance corresponds to a distance in km of:  827.825363277606
hull.file <- paste0(getwd(), "//Bradypus_BMCP.shp")
shapefile(BMCP.hull$convex.hull, filename=hull.file,overwrite=TRUE)

BMCP.poly <- sf::st_read(hull.file, crs=4326)
## Reading layer `Bradypus_BMCP' from data source `E:\Roeland\R\BiodiversityR\terra\Bradypus_BMCP.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -93.74889 ymin: -31.28005 xmax: -32.28963 ymax: 21.72844
## geographic CRS: WGS 84
suit.data <- as.data.frame(suit.raster,
                           xy=TRUE,
                           na.rm=TRUE)
names(suit.data)[3] <- "suitability"

map_study <- ggplot() +
  geom_contour_filled(data=suit.data,
              aes(x=x, y=y, z=suitability),
              alpha=0.8, colour=NA, breaks=breaks1, show.legend=TRUE) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_sf(data=countries.poly,
          colour=alpha("grey50", alpha=0.5), fill=NA, size=0.4, alpha=0.3) +
  geom_sf(data=BMCP.poly,
          colour=alpha("red", alpha=0.5), fill=NA, size=1.5, alpha=0.3) +
  annotation_north_arrow(location="tr",
                         height=unit(1, "cm"),
                         width=unit(1, "cm")) +
  scale_fill_manual(values=plot.colours) +
  labs(fill="suitability") +
  theme(axis.title = element_blank(),
        panel.background = element_rect(fill="light steel blue"),
        legend.position=c(0.9, 0.8)) +
  coord_sf(xlim=c(bbox_study["left"], bbox_study["right"]),
           ylim=c(bbox_study["bottom"], bbox_study["top"]),
           crs=4326, expand=FALSE)
  
map_study

bbox_study3 <- sf::st_bbox(BMCP.poly)
suit.zoomed3 <- terra::crop(suit.raster, snap="out",
                         y=c(bbox_study3["xmin"]-2, bbox_study3["xmax"]+2,
                             bbox_study3["ymin"]-2, bbox_study3["ymax"]+2))

suit.data <- as.data.frame(suit.zoomed3,
                           xy=TRUE,
                           na.rm=TRUE)
names(suit.data)[3] <- "suitability"


map_study2 <- ggplot() +
  geom_contour_filled(data=suit.data,
              aes(x=x, y=y, z=suitability),
              alpha=0.8, colour=NA, breaks=breaks1, show.legend=TRUE) +
  geom_sf(data=countries.poly,
          colour=alpha("grey50", alpha=0.5), fill=NA, size=0.4, alpha=0.3) +
  geom_mark_hull(data=pres,
                 aes(x=lon, y=lat),
                 colour="red") +
  geom_sf(data=BMCP.poly,
          colour=alpha("red", alpha=0.5), fill=NA, size=1.5, alpha=0.3) +
  annotation_north_arrow(location="tr",
                         height=unit(1, "cm"),
                         width=unit(1, "cm")) +
  scale_fill_manual(values=plot.colours) +
  labs(fill="suitability") +
  theme(axis.title = element_blank(),
        panel.background = element_rect(fill="light steel blue"),
        legend.position=c(0.9, 0.8)) +
  coord_sf(xlim=c(bbox_study3["xmin"]-2, bbox_study3["xmax"]+2),
           ylim=c(bbox_study3["ymin"]-2, bbox_study3["ymax"]+2),
           crs=4326, expand=FALSE)
  
map_study2

8 Session Information

sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19042)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United Kingdom.1252 
## [2] LC_CTYPE=English_United Kingdom.1252   
## [3] LC_MONETARY=English_United Kingdom.1252
## [4] LC_NUMERIC=C                           
## [5] LC_TIME=English_United Kingdom.1252    
## 
## attached base packages:
## [1] tcltk     stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] ggforce_0.3.2        ggspatial_1.1.5      ggmap_3.0.0         
##  [4] ggplot2_3.3.3        terra_1.4-22         dismo_1.3-5         
##  [7] rgdal_1.5-16         raster_3.5-11        sp_1.4-6            
## [10] BiodiversityR_2.14-1 vegan_2.5-6          lattice_0.20-41     
## [13] permute_0.9-5       
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.3.1        backports_1.1.7     Hmisc_4.4-0        
##   [4] plyr_1.8.6          splines_4.0.2       digest_0.6.25      
##   [7] foreach_1.5.0       htmltools_0.5.1.1   earth_5.3.0        
##  [10] relimp_1.0-5        magrittr_1.5        checkmate_2.0.0    
##  [13] cluster_2.1.0       openxlsx_4.1.5      tcltk2_1.2-11      
##  [16] sandwich_2.5-1      prettyunits_1.1.1   jpeg_0.1-8.1       
##  [19] colorspace_1.4-1    mitools_2.4         haven_2.3.1        
##  [22] xfun_0.15           dplyr_1.0.2         crayon_1.3.4       
##  [25] jsonlite_1.6.1      maxlike_0.1-8       lme4_1.1-23        
##  [28] survival_3.1-12     zoo_1.8-8           iterators_1.0.12   
##  [31] glue_1.4.1          polyclip_1.10-0     gtable_0.3.0       
##  [34] V8_3.4.0            kernlab_0.9-29      car_3.0-8          
##  [37] shape_1.4.5         abind_1.4-5         scales_1.1.1       
##  [40] DBI_1.1.0           Rcpp_1.0.7          plotrix_3.8-1      
##  [43] isoband_0.2.1       viridisLite_0.3.0   progress_1.2.2     
##  [46] htmlTable_2.0.0     units_0.6-7         foreign_0.8-80     
##  [49] Formula_1.2-3       survey_4.0          glmnet_4.1         
##  [52] htmlwidgets_1.5.1   httr_1.4.2          RColorBrewer_1.1-2 
##  [55] geosphere_1.5-10    acepack_1.4.1       ellipsis_0.3.1     
##  [58] pkgconfig_2.0.3     farver_2.0.3        nnet_7.3-14        
##  [61] tidyselect_1.1.0    labeling_0.3        rlang_0.4.8        
##  [64] TeachingDemos_2.12  munsell_0.5.0       cellranger_1.1.0   
##  [67] tools_4.0.2         generics_0.1.0      evaluate_0.14      
##  [70] stringr_1.4.0       yaml_2.2.1          maxnet_0.1.2       
##  [73] knitr_1.28          zip_2.0.4           purrr_0.3.4        
##  [76] randomForest_4.6-14 blockCV_2.1.1       RgoogleMaps_1.4.5.3
##  [79] nlme_3.1-148        gam_1.20            concaveman_1.1.0   
##  [82] compiler_4.0.2      rstudioapi_0.11     curl_4.3           
##  [85] png_0.1-7           e1071_1.7-3         tibble_3.0.1       
##  [88] statmod_1.4.34      tweenr_1.0.1        stringi_1.4.6      
##  [91] plotmo_3.6.0        forcats_0.5.0       rgeos_0.5-5        
##  [94] Matrix_1.2-18       classInt_0.4-3      nloptr_1.2.2.1     
##  [97] gbm_2.1.8           vctrs_0.3.4         effects_4.1-4      
## [100] RcmdrMisc_2.7-2     pillar_1.4.4        lifecycle_0.2.0    
## [103] data.table_1.12.8   bitops_1.0-6        R6_2.4.1           
## [106] latticeExtra_0.6-29 KernSmooth_2.23-17  gridExtra_2.3      
## [109] rio_0.5.16          codetools_0.2-16    boot_1.3-25        
## [112] MASS_7.3-51.6       rjson_0.2.20        withr_2.2.0        
## [115] nortest_1.0-4       Rcmdr_2.7-2         mgcv_1.8-31        
## [118] parallel_4.0.2      hms_0.5.3           grid_4.0.2         
## [121] rpart_4.1-15        tidyr_1.1.2         class_7.3-17       
## [124] minqa_1.2.4         rmarkdown_2.3       carData_3.0-4      
## [127] mda_0.5-2           sf_0.9-6            base64enc_0.1-3