Skip to content

Commit

Permalink
added n(s)ec to compare_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarneche committed Sep 22, 2023
1 parent 169abc5 commit c4c84ba
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: bayesnec
Title: A Bayesian No-Effect- Concentration (NEC) Algorithm
Version: 2.1.0.3
Authors@R: c(person("Rebecca", "Fisher", email = "r.fisher@aims.gov.au", role = c("aut", "cre")), person("Diego","Barneche",role="aut"), person("Gerard","Ricardo",role="aut"), person("David","Fox",role="aut"))
Description: Implementation of No-Effect-Concentration estimation that uses 'brms' (see Burkner (2017)<doi:10.18637/jss.v080.i01>; Burkner (2018)<doi:10.32614/RJ-2018-017>; Carpenter 'et al.' (2017)<doi:10.18637/jss.v076.i01> to fit concentration(dose)-response data using Bayesian methods for the purpose of estimating 'ECx' values, but more particularly 'NEC' (see Fox (2010)<doi:10.1016/j.ecoenv.2009.09.012>), 'NSEC' (see Fisher and Fox (2023)<10.1002/etc.5610>), and 'N(S)EC (see Fisher et al. 2023<10.1002/ieam.4809>). This package expands and supersedes an original version implemented in R2jags, see Fisher, Ricardo and Fox (2020)<doi:10.5281/ZENODO.3966864>.
Description: Implementation of No-Effect-Concentration estimation that uses 'brms' (see Burkner (2017)<doi:10.18637/jss.v080.i01>; Burkner (2018)<doi:10.32614/RJ-2018-017>; Carpenter 'et al.' (2017)<doi:10.18637/jss.v076.i01> to fit concentration(dose)-response data using Bayesian methods for the purpose of estimating 'ECx' values, but more particularly 'NEC' (see Fox (2010)<doi:10.1016/j.ecoenv.2009.09.012>), 'NSEC' (see Fisher and Fox (2023)<doi:10.1002/etc.5610>), and 'N(S)EC (see Fisher et al. 2023<doi:10.1002/ieam.4809>). This package expands and supersedes an original version implemented in R2jags, see Fisher, Ricardo and Fox (2020)<doi:10.5281/ZENODO.3966864>.
Depends:
R (>= 4.1),
brms,
Expand Down
9 changes: 6 additions & 3 deletions R/compare_estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#' }
#'
#' @export
compare_estimates <- function(x, comparison = "nec", ecx_val = 10,
compare_estimates <- function(x, comparison = "n(s)ec", ecx_val = 10,
type = "absolute", hormesis_def = "control",
sig_val = 0.01, resolution = 100, x_range = NA) {
if ((comparison %in% c("nec", "ecx", "nsec")) == FALSE) {
stop("comparison must be one of nec, ecx or nsec.")
if ((comparison %in% c("nec", "n(s)ec", "ecx", "nsec")) == FALSE) {
stop("comparison must be one of nec, n(s)ec, ecx or nsec.")
}
chk_numeric(ecx_val)
if ((type %in% c("relative", "absolute", "direct")) == FALSE) {
Expand All @@ -54,6 +54,9 @@ compare_estimates <- function(x, comparison = "nec", ecx_val = 10,
chk_numeric(x_range)
}
if (comparison == "nec") {
posterior_list <- lapply(x, nec, posterior = TRUE, xform = identity)
}
if (comparison == "n(s)ec") {
posterior_list <- lapply(x, return_nec_post, xform = identity)
}
if (comparison == "ecx") {
Expand Down
6 changes: 3 additions & 3 deletions R/compare_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' \code{\link{bayesnecfit}} or \code{\link{bayesmanecfit}} returned by
#' \code{\link{bnec}}.
#' @param comparison The posterior predictions to compare, takes values of
#' "nec", "nsec", "ecx" or "fitted".
#' "nec", "n(s)ec", "nsec", "ecx" or "fitted".
#' @param make_newdata Only used if \code{comparison = "fitted"}. Should the
#' user allow the package to create \code{newdata} for predictions?
#' If so, arguments \code{resolution} and \code{x_range} will be used. Defaults
Expand Down Expand Up @@ -59,11 +59,11 @@
#' data(manec_example)
#' nec4param <- pull_out(manec_example, model = "nec4param")
#' ecx4param <- pull_out(manec_example, model = "ecx4param")
#' compare_posterior(list("nec" = ecx4param, "ecx" = nec4param), ecx_val = 50)
#' compare_posterior(list("n(s)ec" = ecx4param, "ecx" = nec4param), ecx_val = 50)
#' }
#'
#' @export
compare_posterior <- function(x, comparison = "nec", ecx_val = 10,
compare_posterior <- function(x, comparison = "n(s)ec", ecx_val = 10,
type = "absolute", hormesis_def = "control",
sig_val = 0.01, resolution, x_range = NA,
make_newdata = TRUE, ...) {
Expand Down
4 changes: 1 addition & 3 deletions man/average_estimates.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/compare_estimates.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions man/compare_posterior.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c4c84ba

Please sign in to comment.