knitr::opts_chunk$set( echo = TRUE, fig.width = 6, fig.height = 4 )
The ssdtools
package produces a plot of the cumulative distributions for multiple distribution through the use of the ssd_plot_cdf()
function.
For example, consider the boron data.
library(ggplot2) library(ssdtools) fits <- ssd_fit_dists(ssddata::ccme_boron) gp <- ssd_plot_cdf(fits) + scale_color_ssd() print(gp)
This graphic is a ggplot object and so can be saved and embellished in the usual way. For example, suppose we want to superimpose an environmental concentration cumulative distribution and compute the exposure risk as outlined in @verdonck_limitations_2003.
# what are the mean and sd on the log-scale for the environmental concentration ex.mean.log <- log(0.1) ex.sd.log <- 1
Finding a suitable probability distribution to describe the exposure concentration is beyond the scope of this document -- we will assume that this has been done elsewhere.
In particular, suppose that the exposure concentration follows a log-normal distribution with a mean of r signif(ex.mean.log, 3)
and a standard deviation of r ex.sd.log
on the logarithmic scale.
From the exposure distribution, we construct a data frame with the concentration values and the cumulative probability of seeing this exposure or less in the environment.
Notice that some care is needed because the ssdtools plot is on the logarithmic base 10 scale and not the natural logarithm base $e$ scale.
ex.cdf <- data.frame(Conc = exp(seq(log(.01), log(10), .1))) # generate a grid of concentrations ex.cdf$ex.cdf <- plnorm(ex.cdf$Conc, meanlog = ex.mean.log, sdlog = ex.sd.log ) # generate the cdf
We now add this to the plot
gp + geom_line(data = ex.cdf, aes(x = Conc, y = ex.cdf), color = "red", linewidth = 2) + annotate("text", label = paste("Exposure distribution"), x = 1.08 * ex.cdf$Conc[which.max(ex.cdf$ex.cdf > 0.5)], y = 0.5, angle = 75 )
The ssdtools
package contains a function ssd_exposure()
that computes the risk as defined by Verdonck et al (2003) representing the average proportion of species at risk.
set.seed(99) ex.risk <- ssd_exposure(fits, meanlog = ex.mean.log, sdlog = ex.sd.log) ex.risk
The risk of r round(ex.risk, 5)
can also be added to the plot in the usual way:
gp + geom_line(dat = ex.cdf, aes(x = Conc, y = ex.cdf), color = "red", linewidth = 2) + annotate("text", label = paste("Exposure distribution"), x = 1.08 * ex.cdf$Conc[which.max(ex.cdf$ex.cdf > 0.5)], y = 0.5, angle = 75 ) + annotate("text", label = paste("Verdonck risk :", round(ex.risk, 5)), x = Inf, y = 0, hjust = 1.1, vjust = -.5 )
Other embellishments can be added in a similar fashion using the features of ggplot and are not discussed here.
ssdtools by the Province of British Columbia
is licensed under a
Creative Commons Attribution 4.0 International License.
Verdonck, F. A., Aldenberg, T. , Jaworska, J. and Vanrolleghem, P. A. (2003), Limitations of current risk characterization methods in probabilistic environmental risk assessment. Environmental Toxicology and Chemistry, 22: 2209-2213. https://doi.org/10.1897/02-435
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.