The package ‘SSDM’ is a computer platform implemented in R providing a range of methodological approaches and parameterization at each step of the SSDM building. This vignette presents a typical workflow in R command to use it. An additionnal vignette presents the same workflow using the graphic user interface with gui function (see GUI vignette).

The workflow of the package ‘SSDM’ is based on three modelling levels:

  1. the individual Species Distribution Model (SDM) fitting the occurrences of a single species on environmental predictor variables with a single modelling algorithm,
  2. the ensemble SDM (ESDM) combining the outputs of several SDMs, each SDM using a different modelling algorithm,
  3. the stack SDM combining several SDM or ESDM outputs to model species assemblages and compute species diversity and species richness (Fig. 1).
Figure 1. Flow chart of the package SSDM

Figure 1. Flow chart of the package ‘SSDM’

Data inputs

Environmental variables

In addition to build species distribution models you will need environmental variables. Currently ‘SSDM’ uses all raster formats supported by the R package ‘rgdal’. The package ‘SSDM’ supports both continuous (e.g., climate maps, digital elevation models, bathymetric maps) and categorical environmental variables (e.g., land cover maps, soil type maps) as inputs. The package also allows normalizing environmental variables, which may be useful to improve the fit of certain algorithms (like artificial neural networks).

Rasters of environmental data need to have the same coordinate reference system while spatial extent and resolution of the environmental layers can differ. During processing, the package will deal with between-variables discrepancies in spatial extent and resolution by rescaling all environmental rasters to the smallest common spatial extent then upscaling them to the coarsest resolution.

‘SSDM’ include load_var function to read raster files including your environmental variables. We will work with three 30 arcsec-resolution rasters covering the north part of the main island of New Caledonia ’Grande Terre’. Climatic variables (RAINFALL and TEMPERATURE) are from the WorldClim database, and the SUBSTRATE map is from the IRD Atlas of New Caledonia (2012) (see ?Env).

library(SSDM)
## Welcome to the SSDM package, you can launch the graphical user interface by typing gui() in the console.
Env <- load_var(system.file('extdata',  package = 'SSDM'), categorical = 'SUBSTRATE', verbose = FALSE)
Env
## class       : RasterStack 
## dimensions  : 120, 120, 14400, 3  (nrow, ncol, ncell, nlayers)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : 164, 165, -21, -20  (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## names       :  RAINFALL, SUBSTRATE, TEMPERATURE 
## min values  : 0.4593978, 0.0000000,   0.6610169 
## max values  :         1,         2,           1

Note that:

  • Specify which environmental variable is categorical with categorical parameter.
  • Normalization is activated by default, check Norm option.

Natural history records

Species distribution models are built on natural history records.

‘SSDM’ include load_occ function to read raw csv or txt files including your natural history records. We will work with natural history records from five Cryptocarya species native to New Caledonia (see ?Occurrences).

Occ <- load_occ(path = system.file('extdata',  package = 'SSDM'), Env,
         Xcol = 'LONGITUDE', Ycol = 'LATITUDE',
         file = 'Occurrences.csv', sep = ',', verbose = FALSE)
head(Occ)
##      SPECIES LONGITUDE  LATITUDE
## 1  elliptica  164.1833 -20.28333
## 2  elliptica  164.1833 -20.46666
## 5  elliptica  164.5166 -20.39999
## 8  elliptica  164.7666 -20.74999
## 11 elliptica  164.9166 -20.94999
## 12  gracilis  164.5166 -20.41666

Note that:

  • Occurences are checked after environmental data are loaded, therefore environmental data need to be loaded before occurrences.
  • Use GeoRes option to thin occurences. Thinning removes unnecessary records, reducing the effect of sampling bias while retaining the greatest amount of information.
  • For issues opening file look at additional options of read.csv function used to open you raw data.*

Model algorithms

Individual species distribution models (SDMs)

In the example below we build an elliptica distribution model with a subset the occurrences of the species and specifying a single algorithm, here generalized linear models. The package ‘SSDM’ includes the main algorithms used to model species distributions: general additive models (GAM), generalized linear models (GLM), multivariate adaptive regression splines (MARS), classification tree analysis (CTA), generalized boosted models (GBM), maximum entropy (Maxent), artificial neural networks (ANN), random forests (RF), and support vector machines (SVM). Default parameters of the dependent R package of each algorithm were conserved but most of them remain settable.

SDM <- modelling('GLM', subset(Occurrences, Occurrences$SPECIES == 'elliptica'), 
                 Env, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', verbose = FALSE)
plot(SDM@projection, main = 'SDM\nfor Cryptocarya elliptica\nwith GLM algorithm')

Note that: The package ‘SSDM’ encompass a large methodolgy offered by litterature. Have a look at all parameters for modelling function with ?modelling.

Ensemble species distribution models (ESDMs)

In this other example we build an ensemble elliptica distribution model combining CTA and MARS based SDMs of this species. Because uncertainty in distribution projections can skew policy making and planning, a recommendation is to fit a number of alternative model algorithms and to explore the range of projections across the different SDMs and then to find consensus in SDM projections. Two consensus methods are implemented in the package ‘SSDM’:

  1. a simple average of the SDM outputs
  2. a weighted average (default option, used below), with weigths based on a user-specified metric or group of metrics.

The package also provides an uncertainty map representing the between-algorithms variance. The degree of agreement between each pair of algorithms can be assessed through a correlation matrix giving the Pearson’s coefficient.

ESDM <- ensemble_modelling(c('CTA', 'MARS'), subset(Occurrences, Occurrences$SPECIES == 'elliptica'),
                           Env, rep = 1, Xcol = 'LONGITUDE', Ycol = 'LATITUDE',
                          ensemble.thresh = c(0.6), verbose = FALSE)
plot(ESDM@projection, main = 'ESDM\nfor Cryptocarya elliptica\nwith CTA and MARS algorithms')

Note that: the package ‘SSDM’ includes a large methodology offered by litterature. Have a look at all parameters for ensemble_modelling function with ?ensemble_modelling.

Stacked species distribution models (SSDMs)

Finally, we build a stacked species distribution model using CTA and SVM algorihtms and multiple species. The outputs of the differnt species are aggregated in SSDM maps of local species richness and composition using summing continuous habitat suitability maps stacking method (pSSDM).

SSDM <- stack_modelling(c('CTA', 'SVM'), Occurrences, Env, rep = 1,
                       Xcol = 'LONGITUDE', Ycol = 'LATITUDE',
                       Spcol = 'SPECIES', method = "pSSDM", verbose = FALSE)
plot(SSDM@diversity.map, main = 'SSDM\nfor Cryptocarya genus\nwith CTA and SVM algorithms')

Five other stacking methods are available (see references in ?stack_modelling for details):

  • by summing discrete presence/absence maps (bSSDM) derived from one of the six metrics available to compute binary maps
  • by summing discrete presence/absence maps obtained by drawing repeatedly from a Bernoulli distribution
  • by applying the ‘probability ranking’ rule (PRR) of the SESAM framework (a number of species equal to the prediction of species richness is selected on the basis of decreasing probability of presence calculated by the SDMs) with species richness as estimated by a pSSDM (referred to as ‘PRR.pSSDM’)
  • by applying the PRR with species richness as estimated by a MEM (‘PRR.MEM’)
  • by using the maximum-likelihood adjustment approach

Outputs

Model accuracy assessment

A range of model evaluation metrics included in package ‘SDMTools’ have been integrated in the package ‘SSDM’. They include the area under the receiving operating characteristic (ROC) curve (AUC), the Cohen’s Kappa coefficient, the omission rate, the sensitivity (true positive rate) and the specificity (true negative rate). These metrics are all based on the confusion matrix (also called ‘error matrix’, which represents the instances in a predicted class versus the instances in an actual class). The confusion matrix is computed converting the habitat suitability maps into binary presence/absence maps.

knitr::kable(ESDM@evaluation)
threshold AUC omission.rate sensitivity specificity prop.correct Kappa
0.37625 0.6725 0.5 0.5 0.4883333 0.4884488 0.1615458

To assess the accuracy of an SSDM, the package provides the opportunity to compare modeled species assemblages with species pools from independent inventories observed in the field. Six evaluation metrics are computed: (1) the species richness error, i.e. the difference between the predicted and observed species richness; (2) assemblage prediction success, i.e. the proportion of correct predictions; (3) assemblage Cohen’s kappa, i.e. the proportion of specific agreement; (4) assemblage specificity, i.e. the proportion of true negatives (species that are both predicted and observed as being absent); (5) assemblage sensitivity, i.e. the proportion of true positives (species that are both predicted and observed as present); and (6) the Jaccard index, a widely used metric of community similarity.

knitr::kable(SSDM@evaluation)
species.richness.error prediction.success kappa specificity sensitivity Jaccard
mean 1.5217391 0.6195652 1.0830322 0.3181818 1 0.5652174
SD 0.9940535 0.2485134 0.0850799 0.3560107 0 0.2610639

Importance analysis of environmental variables

The package ‘SSDM’ provides two methods to measure the relative contribution of environmental variables, which quantifies the relevance of an environmental variable to determine species distribution. The first method is based on a jack knife approach that evaluates the change in accuracy between a full model and the models where each environmental variable are omitted in turns. All metrics available in the package can serve to assess the change in accuracy. The second method is based on the Pearson’s correlation coefficient between a full model and the models where each environmental variable are omitted in turns.

knitr::kable(SSDM@variable.importance)
RAINFALL SUBSTRATE TEMPERATURE
Mean 24.68774 8.333333 66.97893
SD 16.46113 16.666667 27.21894

Endemism mapping

In addition to species richness, endemism is an important feature for conservation as it refers to species being unique to the defined geographic location. Species endemism maps can be computed using two metrics:

  1. the weighted endemism index (WEI)
  2. the corrected weighted endemism index
plot(SSDM@endemism.map, main = 'Endemism map\nfor Cryptocarya genus\nwith CTA and SVM algorithms')

Summary plot

All results can be sumarized inside a shiny dashboard by calling plot method directly on an SSDM object.

# plot(SSDM)