Learn R Programming

Small Sample Size Species Distribution Modeling

The S4DM R package

This repository contains an R package that implements Species Distribution Modeling methods which work even when there are relatively few occurrence records (as is the case for poorly-sample or range-restricted species). These methods were primarily developed by the Drake lab, and include three types of methods: 1) Plug-and-play models, 2) environmental-range models, and 3) density-ratio models. Most of the important functions in this package are wrappers around existing functions that handle density estimation or density-ratio estimation. Much of this code was created by modifying existing code at https://github.com/DrakeLab/PlugNPlay in order to make functions more modular and extensible.

How it works

The package is build on a hierarchy of modular functions, each of which calls on lower-level functions:

  1. The highest-level functions are make_range_map and evaluate_range_map, which are wrappers for...
  2. The next-highest-level functions, fit_plug_and_play, fit_density_ratio, project_plug_and_play, and project_density_ratio, which are wrappers for ...
  3. Internal modules such as pnp_kde or dr_ulsif. These modules both model the environmental covariates and predict values at environmental covariates from fitted models. These modules are largely wrappers around existing functions for fitting density functions or density-ratios. Modules beginning with "pnp_" pertain to density functions while models beginning with "dr_" pertain to density ratio functions.

This hierarchical structure built on low-level internal modules is designed to allow for the easy addition of new methods by adding small, self-contained modules. The highest-level functions are intended only for quick-and-dirty analyses or quick visualizations. We recommend that users focus on the "fit" and "project" functions for work intended for publication.

What is Plug-and-Play?

In general usage, the term plug-and-play (PNP) refers to software or hardware that can be connected without any additional setup or configuration. In the context of species distribution models, plug-and-play is a framework developed by Drake and Richards (https://esajournals.onlinelibrary.wiley.com/doi/full/10.1002/ecs2.2373) that recognizes that species distribution models can be constructed by "plugging in" any methods that can estimate density functions.

Copy Link

Version

Install

install.packages('S4DM')

Monthly Downloads

161

Version

0.0.1

License

MIT + file LICENSE

Maintainer

Brian S. Maitner

Last Published

January 10th, 2025

Functions in S4DM (0.0.1)

sample_points

Example S4DM occurrence data
pnp_vine

Internal function for fitting vine copula distributions in plug-and-play SDMs.
sdm_threshold

Thresholds a continuous relative occurrence rate raster to create a binary raster.
stratify_spatial

Split data for k-fold spatially stratified cross validation
stratify_random

Split data for k-fold spatially stratified cross validation
project_density_ratio

Projects fitted density-ratio distribution models onto new covariates.
rescale_w_objects

Rescale a dataset using vectors of means and SDs
project_plug_and_play

Projects fitted plug-and-play distribution models onto new covariates.
dr_ulsif

Density-ratio SDM estimation with uLSIF
dr_rulsif

Density-ratio SDM estimation with RuLSIF
get_env_bg

Extract background data for SDM fitting.
descale_w_objects

Return scaled variables to the original scale using means and SDs
make_range_map

Make a range map using plug-and-play modeling.
dr_maxnet

Density-ratio SDM estimation with Maxnet
pnp_gaussian

Internal function for fitting gaussian distributions in plug-and-play SDMs.
pnp_none

Internal function for returning empty pnp_estimate class models
get_env_pres

Extract presence data for SDM fitting.
pnp_rangebagging

Internal function for rangebagging in plug-and-play SDMs.
ensemble_range_map

Generate ensemble predictions from S4DM range maps
evaluate_range_map

Evaluate S4DM range map quality
fit_density_ratio

Fit density-ratio distribution models in a plug-and-play framework.
get_response_curves

Generate Response Curves
get_functions

Internal function for getting available function names.
fit_plug_and_play

Fit presence-background distribution models in a plug-and-play framework.
pnp_kde

Internal function for fitting KDE distributions in plug-and-play SDMs.
pnp_lobagoc

Internal function for fitting lobagoc distributions in plug-and-play SDMs.