SDMtune provides a user-friendly framework that enables the training and the evaluation of species distribution models (SDMs). The package implements functions for data driven variable selection and model tuning and includes numerous utilities to display the results. All the functions used to select variables or to tune model hyperparameters have an interactive real-time chart displayed in the RStudio viewer pane during their execution. Visit the package website and learn how to use SDMtune starting from the first article Prepare data for the analysis.
You can install the latest release version from CRAN:
Or the development version from GitHub:
Real-time charts displaying the training and the validation metrics are displayed in the RStudio viewer pane during the execution of the tuning and variable selection functions.
Let’s see SDMtune in action. If the following code is not clear, please check the articles in the website. Here we prepare the data and we train a Maxent model using SDMtune:
# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) predictors <- raster::stack(files) # Prepare presence and background locations p_coords <- virtualSp$presence bg_coords <- virtualSp$background # Create SWD object data <- prepareSWD(species = "Virtual sp", p = p_coords, a = bg_coords, env = predictors, categorical = "biome") # Train a model sdmtune_model <- train(method = "Maxent", data = data)
We want to compare the execution time of the
predict function between SDMtune that uses its own algorithm and dismo (Hijmans et al. 2017) that calls the MaxEnt Java software (Phillips, Anderson, and Schapire 2006). We first convert the
sdmtune_model in a object that is accepted by dismo:
Here a function to test that the results are equal, with a tolerance of
Now we test the execution time using the microbenckmark package:
Plot the output:
Please note that this project follows a Contributor Code of Conduct.
Hijmans, Robert J., Steven Phillips, John Leathwick, and Jane Elith. 2017. “dismo: Species Distribution Modeling. R package version 1.1-4.” https://cran.r-project.org/package=dismo.
Phillips, Steven J, Robert P Anderson, and Robert E Schapire. 2006. “Maximum entropy modeling of species geographic distributions.” Ecological Modelling 190: 231–59. https://doi.org/10.1016/j.ecolmodel.2005.03.026.