library(ssd4mosaic)
When using the MOSAIC SSD web application, a code is provided after each analysis to reproduce the same results directly in R. Here is an example of censored data species sensitivity distribution analysis using {ssd4mosaic}
functions.
# Data creation
# Most often, you would archive the same result by reading a table file with a
# function akin to utils::read.delim()
ssd4mosaic::fluazinam
data <-
# Which distribution to fit to the data.
# See get_fits function documentation for possible options
list("lnorm")
distributions <-# Whether to display the results plots with a logscale x-axis
TRUE
logscale <-# Concentration unit for plots labels
"\u03bcg/L" unit <-
## model fitting
ssd4mosaic::get_fits(data, distributions, TRUE)
fits <-
## bootstrapping
ssd4mosaic::get_bootstrap(fits)[[1]] bts <-
## Model parameters
lapply(fits, summary)
#> [[1]]
#> Fitting of the distribution ' lnorm ' By maximum likelihood on censored data
#> Parameters
#> estimate Std. Error
#> meanlog 4.976920 0.7422075
#> sdlog 2.687785 0.6056713
#> Loglikelihood: -72.81266 AIC: 149.6253 BIC: 150.9034
#> Correlation matrix:
#> meanlog sdlog
#> meanlog 1.0000000 0.1350239
#> sdlog 0.1350239 1.0000000
## HCx values
lapply(bts, quantile, probs = c(0.05, 0.1, 0.2, 0.5))
#> [[1]]
#> (original) estimated quantiles for each specified probability (censored data)
#> p=0.05 p=0.1 p=0.2 p=0.5
#> estimate 1.743522 4.629205 15.10194 145.0271
#> Median of bootstrap estimates
#> p=0.05 p=0.1 p=0.2 p=0.5
#> estimate 1.943686 5.023317 16.07359 144.5243
#>
#> two-sided 95 % CI of each quantile
#> p=0.05 p=0.1 p=0.2 p=0.5
#> 2.5 % 0.3332222 1.079025 4.034234 35.65986
#> 97.5 % 17.9205455 34.443306 82.766670 771.86244
## CDF plot with confidence intervals
ssd4mosaic::base_cdf(fits, unit = unit, logscale = logscale)
p <-::add_CI_plot(p, bts, logscale)
ssd4mosaic## CDF plot with species names
::options_plot(fits, unit, logscale, data, use_names = TRUE)
ssd4mosaic## CDF plot colored by group
::options_plot(fits, unit, logscale, data, use_groups = TRUE) ssd4mosaic