How can I plot the model averaged fit with individual fits?
library(ssdtools)
dist <- ssd_fit_dists(ssddata::ccme_boron)
ssd_plot_cdf(dist, average = NA)
How do I fit distributions to multiple groups such taxa and/or chemicals?
An elegant approach using some tidyverse packages is demonstrated below.
library(ssddata)
library(ssdtools)
library(ggplot2)
library(dplyr)
library(tidyr)
library(purrr)
boron_preds <- nest(ccme_boron, data = c(Chemical, Species, Conc, Units)) %>%
mutate(
Fit = map(data, ssd_fit_dists, dists = "lnorm"),
Prediction = map(Fit, predict)
) %>%
unnest(Prediction)
The resultant data and predictions can then be plotted as follows.
ssd_plot(ccme_boron, boron_preds, xlab = "Concentration (mg/L)", ci = FALSE) +
facet_wrap(~Group)
Licensing
Copyright 2018-2024 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