library(sdm)Species Distribution Modeling
An analysis of species distribution using ensemble methods in R.
About
In this short article, I demonstrate how to build ensemble model of rf, maxent, and brt in R using sdm package version 1.2.46 (Naimi and Araújo 2016).
Loading the libraries
Species occurrence records
Here we will use the occurrence records inbuilt in the package to boost reproducibility.
species <- vect(system.file('external/species.shp', package = 'sdm'))
preds <- rast(list.files(system.file("external", package = 'sdm'), pattern = '.asc', full.names = TRUE))Building the sdmData object.
d <- sdmData(Occurrence ~., train = species, predictors = preds)Building the sdmModels object.
m <- sdm(Occurrence ~., data = d, methods = c('rf', 'maxent', 'brt'), replications = 'cv', cv.folds = 4, n = 3)ens <- ensemble(x = m,
newdata = preds,
filename = ".tif",
setting = list(method = "weighted", stat = "TSS", opt = 2),
overwrite = TRUE)
plot(ens)Cool, this is the plot of all the models “combined”.
References
Naimi, Babak, and Miguel B. Araújo. 2016. “Sdm: A Reproducible and Extensible r Platform for Species Distribution Modelling.” Ecography. https://doi.org/10.1111/ecog.01881.