Learn R Programming

ssdtools

ssdtools is an R package to fit and plot Species Sensitivity Distributions (SSD).

SSDs are cumulative probability distributions which are fitted to toxicity concentrations for different species as described by Posthuma et al. (2001). The ssdtools package uses Maximum Likelihood to fit distributions such as the log-normal, log-logistic, log-Gumbel (also known as the inverse Weibull), gamma, Weibull and log-normal log-normal mixture. Multiple distributions can be averaged using Akaike Information Criteria. Confidence intervals on hazard concentrations and proportions are produced by bootstrapping.

Introduction

The dependency ssddata provides example data sets for several chemicals including Boron. The ECOTOX Knowledgebase is another source of toxicity concentrations for over 12,000 chemicals.

library(ssdtools)
ssddata::ccme_boron
#> # A tibble: 28 × 5
#>    Chemical Species                  Conc Group        Units
#>    <chr>    <chr>                   <dbl> <fct>        <chr>
#>  1 Boron    Oncorhynchus mykiss       2.1 Fish         mg/L 
#>  2 Boron    Ictalurus punctatus       2.4 Fish         mg/L 
#>  3 Boron    Micropterus salmoides     4.1 Fish         mg/L 
#>  4 Boron    Brachydanio rerio        10   Fish         mg/L 
#>  5 Boron    Carassius auratus        15.6 Fish         mg/L 
#>  6 Boron    Pimephales promelas      18.3 Fish         mg/L 
#>  7 Boron    Daphnia magna             6   Invertebrate mg/L 
#>  8 Boron    Opercularia bimarginata  10   Invertebrate mg/L 
#>  9 Boron    Ceriodaphnia dubia       13.4 Invertebrate mg/L 
#> 10 Boron    Entosiphon sulcatum      15   Invertebrate mg/L 
#> # ℹ 18 more rows

The six default distributions are fit using ssd_fit_dists()

fits <- ssd_fit_dists(ssddata::ccme_boron)

and can be quickly plotted using autoplot

autoplot(fits)

The goodness of fit can be assessed using ssd_gof

ssd_gof(fits)
#> # A tibble: 6 × 9
#>   dist           ad     ks    cvm   aic  aicc   bic delta weight
#>   <chr>       <dbl>  <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>
#> 1 gamma       0.440 0.117  0.0554  238.  238.  240. 0.005  0.357
#> 2 lgumbel     0.829 0.158  0.134   244.  245.  247. 6.56   0.013
#> 3 llogis      0.487 0.0994 0.0595  241.  241.  244. 3.39   0.066
#> 4 lnorm       0.507 0.107  0.0703  239.  240.  242. 1.40   0.177
#> 5 lnorm_lnorm 0.320 0.116  0.0414  240.  243.  247. 4.98   0.03 
#> 6 weibull     0.434 0.117  0.0542  238.  238.  240. 0      0.357

and the model-averaged 5% hazard concentration estimated (with bootstrapping to get confidence intervals) using ssd_hc.

set.seed(99)
hc5 <- ssd_hc(fits, ci = TRUE)
print(hc5)
#> # A tibble: 1 × 11
#>   dist    proportion   est    se   lcl   ucl    wt method    nboot pboot samples
#>   <chr>        <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>     <dbl> <dbl> <I<lis>
#> 1 average       0.05  1.26 0.782 0.407  3.29     1 parametr…  1000     1 <dbl>

Model-averaged predictions complete with confidence intervals can also be estimated by parametric bootstrapping using the stats generic predict.

boron_pred <- predict(fits, ci = TRUE)

The predictions can be plotted together with the original data using ssd_plot.

library(ggplot2)

theme_set(theme_bw())

ssd_plot(ssddata::ccme_boron, boron_pred,
  shape = "Group", color = "Group", label = "Species",
  xlab = "Concentration (mg/L)", ribbon = TRUE
) +
  expand_limits(x = 3000) +
  scale_colour_ssd()

Information

Get started with ssdtools at https://bcgov.github.io/ssdtools/articles/ssdtools.html.

A shiny app to allow non-R users to interface with ssdtools is available at https://github.com/bcgov/shinyssdtools.

For the latest changes to the development version see the NEWS file.

For recent developments in SSD modeling including a review of existing software see:

Fox, D.R., et al. 2021. Recent Developments in Species Sensitivity Distribution Modeling. Environ Toxicol Chem 40(2): 293–308. https://doi.org/10.1002/etc.4925.

Citation

To cite package 'ssdtools' in publications use:

  Thorley J, Fisher R, Fox D, Schwarz C (2025). "ssdtools v2: An R
  package to fit Species Sensitivity Distributions." _Journal of Open
  Source Software_, *10*(105), 7492. doi:10.21105/joss.07492
  <https://doi.org/10.21105/joss.07492>.

A BibTeX entry for LaTeX users is

  @Article{,
    title = {ssdtools v2: An R package to fit Species Sensitivity Distributions},
    author = {Joe Thorley and Rebecca Fisher and David Fox and Carl Schwarz},
    year = {2025},
    journal = {Journal of Open Source Software},
    volume = {10},
    number = {105},
    pages = {7492},
    doi = {10.21105/joss.07492},
  }

Installation

Release

To install the latest release version from CRAN.

install.packages("ssdtools")

The website for the release version is at https://bcgov.github.io/ssdtools/.

Development

To install the development version from GitHub

# install.packages("remotes")
remotes::install_github("bcgov/ssdtools")

or from r-universe.

install.packages("ssdtools", repos = c("https://bcgov.r-universe.dev", "https://cloud.r-project.org"))

The website for the development version is at https://bcgov.github.io/ssdtools/dev/.

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

Contribution

If you would like to contribute to the package, please see our CONTRIBUTING guidelines.

Code of Conduct

Please note that the ssdtools project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

References

Posthuma, L., Suter II, G.W., and Traas, T.P. 2001. Species Sensitivity Distributions in Ecotoxicology. CRC Press.

Licensing

Copyright 2015-2023 Province of British Columbia
Copyright 2021 Environment and Climate Change Canada
Copyright 2023-2024 Australian Government Department of Climate Change, Energy, the Environment and Water

The documentation is released under the CC BY 4.0 License

The code is released under the Apache License 2.0

Copy Link

Version

Install

install.packages('ssdtools')

Monthly Downloads

1,272

Version

2.3.0

License

Apache License (== 2.0) | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Joe Thorley

Last Published

February 20th, 2025

Functions in ssdtools (2.3.0)

params

Parameter Descriptions for ssdtools Functions
geom_ssdsegment

Species Sensitivity Censored Segments
is.fitdists

Is fitdists Object
is_censored

plgumbel

pgompertz

geom_ssd

geom_ssdpoint

Species Sensitivity Data Points
glance.fitdists

Get a tibble summarizing each distribution
geom_xribbon

Ribbon on X-Axis
predict.fitburrlioz

Predict Hazard Concentrations of fitburrlioz Object
ssd_data

Data from fitdists Object
qgompertz

rgompertz

predict.fitdists

Predict Hazard Concentrations of fitdists Object
ssd_censor_data

Censor Data
reexports

Objects exported from other packages
qlgumbel

rlgumbel

Random Generation for log-Gumbel Distribution
scale_colour_ssd

Discrete color-blind scale for SSD Plots
ssd_ecd

Empirical Cumulative Density
ssd_dists

Species Sensitivity Distributions
ssd_fit_bcanz

Fit BCANZ Distributions
ssd_ecd_data

Empirical Cumulative Density for Species Sensitivity Data
ssd_exposure

Proportion Exposure
ssd_eburrIII3

Default Parameter Estimates
ssd_fit_burrlioz

Fit Burrlioz Distributions
ssd_dists_all

All Species Sensitivity Distributions
ssd_hc_burrlioz

ssd_label_comma

Label numbers with significant digits and comma
ssd_dists_bcanz

BCANZ Distributions
ssd_dists_shiny

All Shiny Species Sensitivity Distributions
ssd_hc

Hazard Concentrations for Species Sensitivity Distributions
ssd_hc_bcanz

BCANZ Hazard Concentrations
ssd_hp

Hazard Proportion
ssd_label_comma_hc

Label numbers with significant digits and comma. If hc_value is present in breaks, put on new line and make bold.
ssd_fit_dists

Fit Distributions
ssd_gof

Goodness of Fit
ssd_min_pmix

Calculate Minimum Proportion in Mixture Models
ssd_plot

Plot Species Sensitivity Data and Distributions
ssd_pburrIII3

Cumulative Distribution Function
ssd_pal

Color-blind Palette for SSD Plots
ssd_plot_data

Plot Species Sensitivity Data
ssd_hp_bcanz

BCANZ Hazard Proportion
ssd_is_censored

Is Censored
ssd_match_moments

Match Moments
ssd_licensing_md

Licensing Markdown
ssd_plot_cdf

Plot Cumulative Distribution Function (CDF)
ssd_plot_cf

ssd_qburrIII3

Quantile Function
ssdtools-ggproto

ggproto Classes for Plotting Species Sensitivity Data and Distributions
ssd_wqg_bc

ssd_wqg_burrlioz

ssdtools-package

ssdtools: Species Sensitivity Distributions
ssd_rburrIII3

Random Number Generation
ssd_sort_data

Sort Species Sensitivity Data
tidy.fitdists

Turn a fitdists Object into a Tibble
stat_ssd

subset.fitdists

Subset fitdists Object
autoplot.fitdists

Plot a fitdists Object
boron_pred

Model Averaged Predictions for CCME Boron Data
estimates.fitdists

Estimates for fitdists Object
dlgumbel

augment.fitdists

Augmented Data from fitdists Object
coef.fitdists

Turn a fitdists Object into a Tidy Tibble
dgompertz

comma_signif

geom_hcintersect

Species Sensitivity Hazard Concentration Intersection
dist_data

Distribution Data