-
Notifications
You must be signed in to change notification settings - Fork 17
/
README.Rmd
153 lines (104 loc) · 5.17 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ssdtools <img src="man/figures/logo.png" align="right" alt="ssdtools logo of cumulative species sensitivity distribution with outlines of commonly used species as data" />
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![R-CMD-check](https://github.com/bcgov/ssdtools/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bcgov/ssdtools/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/bcgov/ssdtools/graph/badge.svg)](https://app.codecov.io/gh/bcgov/ssdtools)
[![CRAN status](https://www.r-pkg.org/badges/version/ssdtools)](https://cran.r-project.org/package=ssdtools)
![CRAN downloads](https://cranlogs.r-pkg.org/badges/ssdtools)
<!-- badges: end -->
`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.
## Installation
### Release
To install the latest release version from [CRAN](https://CRAN.R-project.org/package=ssdtools).
```r
install.packages("ssdtools")
```
#### Website
The website for the release version is at <https://bcgov.github.io/ssdtools/>.
### Development
To install the latest development version from [r-universe](https://bcgov.r-universe.dev/ssdtools).
```r
install.packages("ssdtools", repos = c("https://bcgov.r-universe.dev", "https://cloud.r-project.org"))
```
or from [GitHub](https://github.com/bcgov/ssdtools)
```r
# install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))
pak::pak("bcgov/ssdtools")
```
#### Website
The website for the development version is at <https://bcgov.github.io/ssdtools/dev/>.
## Introduction
The dependency [`ssddata`](https://github.com/open-AIMS/ssddata) provides example data sets for several chemicals including Boron.
```{r, message=FALSE}
library(ssdtools)
ssddata::ccme_boron
```
The six default distributions are fit using `ssd_fit_dists()`
```{r}
fits <- ssd_fit_dists(ssddata::ccme_boron)
```
and can be quickly plotted using `autoplot`
```{r, warning = FALSE, message = FALSE, fig.alt="A plot of the data and fitted distributions"}
autoplot(fits)
```
The goodness of fit can be assessed using `ssd_gof`
```{r}
ssd_gof(fits)
```
and the model-averaged 5% hazard concentration estimated (with bootstrapping to get confidence intervals) using `ssd_hc`.
```{r}
set.seed(99)
hc5 <- ssd_hc(fits, ci = TRUE)
print(hc5)
```
Model-averaged predictions complete with confidence intervals can also be estimated by parametric bootstrapping using the `stats` generic `predict`.
```{r, eval=FALSE}
boron_pred <- predict(fits, ci = TRUE)
```
The predictions can be plotted together with the original data using `ssd_plot`.
```{r, fig.alt="A plot of the data and model-averaged prediction with confidence intervals"}
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](https://bcgov.github.io/ssdtools/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>.*
### Getting Help or Reporting an Issue
To report bugs/issues/feature requests, please file an [issue](https://github.com/bcgov/ssdtools/issues/).
### Contribution
If you would like to contribute to the package, please see our
[CONTRIBUTING](https://github.com/bcgov/ssdtools/blob/master/.github/CONTRIBUTING.md) guidelines.
### Code of Conduct
Please note that the ssdtools project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html).
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.
<div id="refs"></div>
```{r, results = "asis", echo = FALSE}
cat(ssdtools::ssd_licensing_md())
```