Learn R Programming

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

ssdtools

ssdtools is an R package to plot and fit 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, gamma, burr Type-III, log-logistic, log-Gumbel, Gompertz and Weibull. The user can also provide custom distributions. Multiple distributions can be averaged using Information Criteria. Confidence intervals on hazard concentrations and proportions are produced by parametric bootstrapping.

Installation

To install the latest version from CRAN

install.packages("ssdtools")

To install the latest development version:

install.packages("devtools")
devtools::install_github("bcgov/ssdtools")

Introduction

ssdtools provides a data set for several chemicals including Boron.

library(ssdtools)
boron_data
#> # A tibble: 28 x 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 
#> # … with 18 more rows

Multiple distributions can be fit using ssd_fit_dists()

boron_dists <- ssd_fit_dists(boron_data)

and plot using the ggplot2 generic autoplot

library(ggplot2)
theme_set(theme_bw())
autoplot(boron_dists)

The goodness of fit can be assessed using ssd_gof

ssd_gof(boron_dists)
#> # A tibble: 3 x 9
#>   dist        ad    ks    cvm   aic  aicc   bic delta weight
#> * <chr>    <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>
#> 1 burrIII2 0.500 0.108 0.0628  241.  242.  244.  3.74  0.093
#> 2 gamma    0.440 0.117 0.0554  238.  238.  240.  0     0.606
#> 3 lnorm    0.507 0.107 0.0703  239.  240.  242.  1.40  0.301

and the model-averaged 5% hazard concentration estimated using ssd_hc

set.seed(99)
boron_hc5 <- ssd_hc(boron_dists, ci = TRUE)
print(boron_hc5)
#> # A tibble: 1 x 6
#>   percent   est    se   lcl   ucl dist   
#>     <dbl> <dbl> <dbl> <dbl> <dbl> <chr>  
#> 1       5  1.30 0.813 0.521  3.58 average

Model-averaged predictions complete with confidence intervals can be produced using the stats generic predict

set.seed(99)
boron_pred <- predict(boron_dists, ci = TRUE)

and plotted together with the original data using ssd_plot.

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

Information

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

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

A shiny webpage developed for non-R-users is available at https://bcgov-env.shinyapps.io/ssdtools/.

The ssdtools package was developed as a result of earlier drafts of:

Schwarz, C., and Tillmanns, A. 2019. Improving Statistical Methods for Modeling Species Sensitivity Distributions. Province of British Columbia, Victoria, BC. Available from http://a100.gov.bc.ca/appsdata/acat/documents/r57400/2_1568399094009_8398900200.pdf.

The CCME data.csv data file is derived from a factsheet prepared by the Canadian Council of Ministers of the Environment. See the data-raw folder for more information.

Getting Help or Reporting an Issue

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

Citation


To cite ssdtools in publications use:

  Thorley, J. and Schwarz C., (2018). ssdtools An R package to fit
  Species Sensitivity Distributions. Journal of Open Source Software,
  3(31), 1082. https://doi.org/10.21105/joss.01082

A BibTeX entry for LaTeX users is

  @Article{,
    title = {{ssdtools}: An R package to fit Species Sensitivity Distributions},
    author = {Joe Thorley and Carl Schwarz},
    journal = {Journal of Open Source Software},
    year = {2018},
    volume = {3},
    number = {31},
    pages = {1082},
    doi = {10.21105/joss.01082},
  }

How to Contribute

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

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

The code is released under the Apache License 2.0

Copyright 2015 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at 

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

ssdtools by the Province of British Columbia is licensed under a Creative Commons Attribution 4.0 International License.

Copy Link

Version

Install

install.packages('ssdtools')

Monthly Downloads

518

Version

0.1.0

License

Apache License (== 2.0) | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Joe Thorley

Last Published

January 13th, 2020

Functions in ssdtools (0.1.0)

is.fitdist

Is fitdist
lgumbel

Log-Gumbel Distribution
predict.fitdistcens

Predict censored fitdist
geom_hcintersect

Hazard Concentration Intersection
predict.fitdists

Predict fitdists
dllog

Log-Logistic Distribution
gamma

Gamma Distribution
fluazinam_pred

Model averaged predictions for fluazinam
boron_data

CCME Species Sensitivity Data for Boron
geom_ssd

Plot Species Sensitivity Data
ssd_plot

SSD Plot
geom_xribbon

Ribbons Plot
ssd_plot_cdf

Plot Cumulative Distribution Function
fluazinam_dists

fitdists for fitdistrplus fluazinam Data
gompertz

Gompertz Distribution
nobs.fitdist

Number of Observations
subset.fitdists

Subset fitdists
params

Parameter Descriptions for ssdtools Functions
ssd_ecd

Empirical Cumulative Density
ssd_fit_dists

Fit Distributions
npars

Get the Number of Parameters
predict.fitdistscens

Predict censored fitdists
weibull

Weibull Distribution
ssd_exposure

Percent Exposure
nobs.fitdistcens

Number of Observations
fluazinam_lnorm

fitdist for CCME Boron Data
ssd_cfplot

Cullen and Frey Plot
ssd_hp

Hazard Percent
is.fitdistcens

Is censored fitdist
pareto

Pareto Distribution
predict.fitdist

Predict fitdist
ssd_match_moments

Match Moments
ssdtools-ggproto

Base ggproto classes for ggplot2
is.fitdistscens

Is censored fitdists
is.fitdists

Is fitdists
ssd_hc

Hazard Concentration
ssd_gof

Goodness of Fit
ssdtools-package

ssdtools: Species Sensitivity Distributions
stat_ssd

Plot Species Sensitivity Data
boron_pred

Model averaged predictions for CCME Boron Data
comma_signif

Comma and Significance Formatter
burrIII2

Burr Type III Two-Parameter Distribution
boron_hc5

Model averaged 5% hazard concentration for CCME Boron Data
boron_dists

fitdists for CCME Boron Data
boron_lnorm

fitdist for CCME Boron Data
autoplot.fitdist

Autoplot fitdist
ccme_data

CCME Species Sensitivity Data
burrIII3

Burr Type III Three-Parameter Distribution