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

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.

Speed test

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 1e-7:

my_check <- function(values) {
  return(all.equal(values[[1]], values[[2]], tolerance = 1e-7))

Now we test the execution time using the microbenckmark package:

bench <- microbenchmark::microbenchmark(
  SDMtune = predict(sdmtune_model, data = data, type = "cloglog"),
  dismo = predict(maxent_model, data@data),
  check = my_check

Plot the output:

ggplot(bench, aes(x = expr, y = time/1000000, fill = expr)) +
  geom_boxplot() +
  labs(fill = "", x = "Package", y = "time (milliseconds)") +

Code of conduct

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.”
Phillips, Steven J, Robert P Anderson, and Robert E Schapire. 2006. “Maximum entropy modeling of species geographic distributions.” *Ecological Modelling* 190: 231–59. .