Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only fit current invpareto distribution in isolation. #411

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ssdtools
Title: Species Sensitivity Distributions
Version: 2.2.0.9000
Version: 2.2.0.9002
Authors@R: c(
person("Joe", "Thorley", , "joe@poissonconsulting.ca", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7683-4592")),
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->

# ssdtools 2.2.0.9002

- Added valid column to dist_data to indicate the "invpareto" has invalid likelihood.
- Modified `ssd_fit_dists()` so fits distributions with invalid likelihoods in isolation.
- Modified `ssd_hc()` and `ssd_hp()` so does not average if just one distribution.

# ssdtools 2.2.0.9001

- Update citations.


# ssdtools 2.2.0.9000

- House-keeping on Github actions.


# ssdtools 2.2.0

- Added `ssd_label_comma_hc()` function to label numbers with significant digits and comma and offset hazard concentration value if present in breaks.
Expand Down
2 changes: 1 addition & 1 deletion R/augment.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/autoplot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/bcanz.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/boot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/burrlioz.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/burrrIII3.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
6 changes: 3 additions & 3 deletions R/censor.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,7 +16,7 @@
# limitations under the License.

#' Censor Data
#'
#'
#' Censors data to a specified range based on the `censoring` argument.
#' The function is useful for creating test data sets.
#'
Expand Down Expand Up @@ -70,7 +70,7 @@ censor_data <- function(data, censoring) {
if (!.is_censored(censoring)) {
return(data)
}

data$right[data$left < censoring[1]] <- min(censoring)
data$left[data$left < censoring[1]] <- 0
data$left[data$right > censoring[2]] <- max(censoring)
Expand Down
2 changes: 1 addition & 1 deletion R/censored.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/chk.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/cis.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/coef.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/convergence.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/d.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
14 changes: 7 additions & 7 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,9 +30,9 @@
#' @family boron
#' @examples
#' \dontrun{
#' fits <- ssd_fit_dists(ssddata::ccme_boron)
#' set.seed(99)
#' boron_pred <- predict(fits, ci = TRUE)
#' fits <- ssd_fit_dists(ssddata::ccme_boron)
#' set.seed(99)
#' boron_pred <- predict(fits, ci = TRUE)
#' }
#' head(boron_pred)
"boron_pred"
Expand All @@ -43,10 +43,10 @@
#'
#' \describe{
#' \item{dist}{The distribution (chr).}
#' \item{npars}{The number of parameters (int).}
#' \item{tails}{Whether the distribution has both tails (flag).}
#' \item{stable}{Whether the distribution is numerically stable (flag).}
#' \item{bcanz}{Whether the distribution belongs to the set of distributions approved by BC, Canada, Australia and New Zealand for official guidelines (flag).}
#' \item{tails}{Whether the distribution has both tails (flag).}
#' \item{npars}{The number of parameters (int).}
#' \item{valid}{Whether the distribution has a valid likelihood that allows it to be fit with other distributions for modeling averaging (flag).}
#' }
#' @family dists
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion R/devtools-helpers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/dist.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
20 changes: 12 additions & 8 deletions R/dists.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -29,10 +29,11 @@
#' ssd_dists(bcanz = TRUE)
#' ssd_dists(tails = FALSE)
#' ssd_dists(npars = 5)
ssd_dists <- function(bcanz = NULL, tails = NULL, npars = 2:5) {
ssd_dists <- function(bcanz = NULL, tails = NULL, npars = 2:5, valid = TRUE) {
chk_null_or(bcanz, vld = vld_flag)
chk_null_or(tails, vld = vld_flag)

chk_null_or(valid, vld = vld_flag)

chk_whole_numeric(npars)
chk_not_any_na(npars)
chk_range(npars, c(2L, 5L))
Expand All @@ -44,23 +45,26 @@ ssd_dists <- function(bcanz = NULL, tails = NULL, npars = 2:5) {
if (!is.null(tails)) {
dists <- dists[dists$tails == tails, ]
}
if (!is.null(valid)) {
dists <- dists[dists$valid == valid, ]
}
dists <- dists[dists$npars %in% npars, ]

dists$dist
}

#' All Species Sensitivity Distributions
#'
#' Gets a character vector of the names of all the available distributions.
#'
#'
#' @inheritParams params
#' @return A unique, sorted character vector of the distributions.
#' @family dists
#' @export
#'
#' @examples
#' ssd_dists_all()
ssd_dists_all <- function() {
ssd_dists(bcanz = NULL, tails = NULL, npars = 2:5)
ssd_dists_all <- function(valid = TRUE) {
ssd_dists(bcanz = NULL, tails = NULL, npars = 2:5, valid = valid)
}

#' All Shiny Species Sensitivity Distributions
Expand All @@ -75,5 +79,5 @@ ssd_dists_all <- function() {
#' @examples
#' ssd_dists_shiny()
ssd_dists_shiny <- function() {
ssd_dists(bcanz = NULL, tails = TRUE, npars = 2:5)
ssd_dists(bcanz = NULL, tails = TRUE, npars = 2:5, valid = TRUE)
}
2 changes: 1 addition & 1 deletion R/estimates.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
12 changes: 6 additions & 6 deletions R/exposure.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -27,11 +27,11 @@
#' @export
#' @examples
#' \dontrun{
#' fits <- ssd_fit_dists(ssddata::ccme_boron, dists = "lnorm")
#' set.seed(10)
#' ssd_exposure(fits)
#' ssd_exposure(fits, meanlog = 1)
#' ssd_exposure(fits, meanlog = 1, sdlog = 1)
#' fits <- ssd_fit_dists(ssddata::ccme_boron, dists = "lnorm")
#' set.seed(10)
#' ssd_exposure(fits)
#' ssd_exposure(fits, meanlog = 1)
#' ssd_exposure(fits, meanlog = 1, sdlog = 1)
#' }
ssd_exposure <- function(x, meanlog = 0, sdlog = 1, nboot = 1000) {
chk_number(meanlog)
Expand Down
2 changes: 1 addition & 1 deletion R/fit-burrlioz.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
7 changes: 5 additions & 2 deletions R/fit.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -185,7 +185,10 @@ ssd_fit_dists <- function(
chk_not_any_na(dists)
chk_unique(dists)

chk_subset(dists, ssd_dists_all())
chk_subset(dists, ssd_dists_all(valid = NULL))
if(length(dists) > 1 && any(dists %in% ssd_dists_all(valid = FALSE))) {
err("distributions with invalid likelihoods must be fitted in isolation.")
}

chk_whole_number(nrow)
chk_gte(nrow, 4L)
Expand Down
2 changes: 1 addition & 1 deletion R/gamma.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/getters.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 2 additions & 2 deletions R/ggplot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,7 +33,7 @@ ssd_pal <- function() {
}

#' Discrete color-blind scale for SSD Plots
#'
#'
#' The functions were designed for coloring different groups in a plot of SSD data.
#'
#' @param ... Arguments passed to [ggplot2::discrete_scale()].
Expand Down
2 changes: 1 addition & 1 deletion R/ggproto.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/glance.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion R/gof.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2015-2023 Province of British Columbia
# Copyright 2021 Environment and Climate Change Canada
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Copyright 2023-2024 Australian Government Department of Climate Change,
# Energy, the Environment and Water
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading
Loading