Learn R Programming

⚠️There's a newer version (1.0.0) of this package.Take me there.

tidysdm

The goal of tidysdm is to implement Species Distribution Models using the tidymodels framework. The advantage of tidymodels is that the model syntax and the results returned to the user are standardised, thus providing a coherent interface to modelling. Given the variety of models required for SDM, tidymodels is an ideal framework. tidysdm provides a number of wrappers and specialised functions to facilitate the fitting of SDM with tidymodels.

Besides modelling contemporary species, tidysdm has a number of functions specifically designed to work with palaeontological data.

Whilst users are free to use their own environmental data, the articles showcase the potential integration with pastclim, which helps downloading and manipulating present day data, future predictions, and palaeoclimate reconstructions.

An overview of the capabilities of tidysdm is given in Leonardi et al. (2023).

Installation

tidysdm is on CRAN, and the easiest way to install it is with:

install.packages("tidysdm")

The version on CRAN is recommended for every day use. New features and bug fixes appear first on the dev branch on GitHub, before they make their way to CRAN. If you need to have early access to these new features, you can install tidysdm directly from GitHub. To install from GitHub, you will need to use devtools; if you haven't done so already, get it from CRAN with install.packages("devtools").

You can install the latest dev version of tidysdm from GitHub with:

# install.packages("devtools")
devtools::install_github("EvolEcolGroup/tidysdm", ref = "dev")

Overview of functionality

On its dedicated website, you can find Articles giving you a step-by-step overview of the fitting SDMs to contemporary species, as well as an equivalent tutorial for using palaeontological data. Furthermore, there is an Article with examples of how to leverage various features of tidymodels that are not commonly adopted in SDM pipelines

There is also a dev version of the site updated for the dev branch of tidysdm (on the top left of the dev website, the version number is in red and in the format x.x.x.9xxx, indicating it is a development version). If you want to contribute, make sure to read our contributing guide.

When something does not work

What should you do if you get an error when trying to fit a model? tidysdm is a relatively new package, so it might well be that, when you get an error, you might have encountered a bug. However, it is also possible that you have misspecified your model (and so the error comes from tidymodels, because your model is not valid). We have prepared an Article on how to diagnose failing models. It is not a fully comprehensive list of everything that could go wrong, but it will hopefully give you ideas on how to dig deeper in what is wrong. You should also check the issues on GitHub to see whether the problem has already been reported.

If you are convinced that the problem is a bug in tidysdm, feel free to create an new issue. Please make sure you have updated to the latest version of tidysdm, as well as updating all other packages on your system, and provide a reproducible example for the developers to investigate the problem. If you think you can help with fixing that bug, read our contributing guide.

Copy Link

Version

Install

install.packages('tidysdm')

Monthly Downloads

438

Version

0.9.5

License

AGPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Andrea Manica

Last Published

June 23rd, 2024

Functions in tidysdm (0.9.5)

filter_high_cor

Deprecated: Filter to retain only variables below a given correlation threshold
gam_formula

Create a formula for gam
form_resp

Get the response variable from a formula
km2m

Convert a geographic distance from km to m
maxnet_predict

Wrapper to predict maxnet models
niche_overlap

Compute overlap metrics of the two niches
optim_thresh_sens

Find threshold that gives a target sensitivity
lacerta_ensemble

A simple ensemble for the lacerta data
predict.simple_ensemble

Predict for a simple ensemble set
lacerta

Coordinates of presences for Iberian emerald lizard
optim_thresh_tss_max

Find threshold that maximises TSS
lacerta_rep_ens

A repeat ensemble for the lacerta data
geom_split_violin

Split violin geometry for ggplots
optim_thresh

Find threshold that optimises a given metric
predict_raster

Make predictions for a whole raster
grid_cellsize

Get default grid cellsize for a given dataset
optim_thresh_kap_max

Find threshold that maximises Kappa
horses

Coordinates of radiocarbon dates for horses
sample_pseudoabs

Sample pseudo-absence points for SDM analysis
prob_metrics_sf

Probability metrics for sf objects
sample_background

Sample background points for SDM analysis
prob_to_binary

simple function to convert probability to binary classes
maxent_params

Parameters for maxent models
thin_by_dist_time

Thin points dataset based on geographic and temporal distance
thin_by_dist

Thin points dataset based on geographic distance
grid_offset

Get default grid cellsize for a given dataset
%>%

Pipe operator
y2d

Convert a time interval from years to days
sdm_spec_maxent

Model specification for a MaxEnt for SDM
sdm_spec_rand_forest

Model specification for a Random Forest for SDM
tss_max

Maximum TSS - True Skill Statistics
thin_by_cell

Thin point dataset to have 1 observation per raster cell
sample_background_time

Sample background points for SDM analysis for points with a time point.
thin_by_cell_time

Thin point dataset to have 1 observation per raster cell per time slice
out_of_range_warning

Warn if some times are outside the range of time steps from a raster
maxent

MaxEnt model
kap_max

Maximum Cohen's Kappa
repeat_ensemble

Repeat ensemble
plot_pres_vs_bg

Plot presences vs background
lacertidae_background

Coordinates of presences for lacertidae in the Iberian peninsula
recipe.sf

Recipe for sf objects
predict.repeat_ensemble

Predict for a repeat ensemble set
sdm_metric_set

Metric set for SDM
maxnet_fit

Wrapper to fit maxnet models with formulae
sdm_spec_boost_tree

Model specification for a Boosted Trees model for SDM
sdm_spec_glm

Model specification for a GLM for SDM
sdm_spec_gam

Model specification for a GAM for SDM
tss

TSS - True Skill Statistics
tidysdm-package

tidysdm: Species Distribution Models with Tidymodels
sample_pseudoabs_time

Sample pseudo-absence points for SDM analysis for points with a time point.
simple_ensemble

Simple ensemble
spatial_initial_split

Simple Training/Test Set Splitting for spatial data
check_splits_balance

Check the balance of presences vs pseudoabsences among splits
add_member

Add best member of workflow to a simple ensemble
boyce_cont

Boyce continuous index (BCI)
blockcv2rsample

Convert an object created with blockCV to an rsample object
check_sdm_presence

Check that the column with presences is correctly formatted
autoplot.spatial_initial_split

Create a ggplot for a spatial initial rsplit.
control_ensemble_grid

Control wrappers
dist_pres_vs_bg

Distance between the distribution of climate values for presences vs background
filter_collinear

Filter to retain only variables that have low collinearity
collect_metrics.simple_ensemble

Obtain and format results produced by tuning functions for ensemble objects
autoplot.simple_ensemble

Plot the results of a simple ensemble
calib_class_thresh

Calibrate class thresholds
extrapol_mess

Multivariate environmental similarity surfaces (MESS)
add_repeat

Add repeat(s) to a repeated ensemble
check_coords_names

Check that we have a valid pair of coordinate names
clamp_predictors

Clamp the predictors to match values in training set
conf_matrix_df

Make a confusion matrix dataframe for multiple thresholds
explain_tidysdm

Create explainer from your tidysdm ensembles.