-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from pfmc-assessments/style-doc-code
I changed the github workflow that updated documentation with one that does all that as well as style the code (as discussed in nmfs-fish-tools/ghactions4r#131). So now we have nicely styled code.
- Loading branch information
Showing
7 changed files
with
181 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,102 +2,53 @@ Package: PEPtools | |
Title: Tools for Stock Assessments used by the Population Ecology Program | ||
Version: 0.0.2.0001 | ||
Authors@R: c( | ||
person( | ||
given = c("Kelli", "F."), | ||
family = "Johnson", | ||
role = c("aut", "cre"), | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-5149-451X") | ||
), | ||
person( | ||
given = c("Ian", "G."), | ||
family = "Taylor", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-4232-5669") | ||
), | ||
person( | ||
given = c("Chantel", "R."), | ||
family = "Wetzel", | ||
role = "aut", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-7573-8240") | ||
), | ||
person( | ||
given = c("John", "R."), | ||
family = "Wallace", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-2333-1262") | ||
), | ||
person( | ||
given = c("Kiva"), | ||
family = "Oken", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-5627-6837") | ||
), | ||
person( | ||
given = c("Kristin", "N."), | ||
family = "Marshall", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-9769-2300") | ||
), | ||
person( | ||
given = c("Edward", "J."), | ||
family = "Dick", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0001-7681-9176") | ||
), | ||
person( | ||
given = c("Melissa"), | ||
family = "Monk", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0009-0007-6407-5131") | ||
), | ||
person( | ||
given = c("Jason"), | ||
family = "Cope", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0001-7812-6728") | ||
), | ||
person( | ||
given = c("Brian", "J."), | ||
family = "Langseth", | ||
role = "ctb", | ||
email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-9901-6146") | ||
) | ||
) | ||
Description: The package contains various tools that are useful to | ||
scientists at the Northwest Fisheries Science Center (NWFSC) | ||
in the Population Ecology Program (PEP). Users typically spend the | ||
majority of their time producing assessments of groundfish stock off the | ||
U.S. West Coast. Though, many of the tools will also be useful for | ||
the general science they conduct as well. | ||
Depends: R (>= 3.5.0) | ||
person(c("Kelli", "F."), "Johnson", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-5149-451X")), | ||
person(c("Ian", "G."), "Taylor", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-4232-5669")), | ||
person(c("Chantel", "R."), "Wetzel", , "[email protected]", role = "aut", | ||
comment = c(ORCID = "0000-0002-7573-8240")), | ||
person(c("John", "R."), "Wallace", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-2333-1262")), | ||
person("Kiva", "Oken", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-5627-6837")), | ||
person(c("Kristin", "N."), "Marshall", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-9769-2300")), | ||
person(c("Edward", "J."), "Dick", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0001-7681-9176")), | ||
person("Melissa", "Monk", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0009-0007-6407-5131")), | ||
person("Jason", "Cope", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0001-7812-6728")), | ||
person(c("Brian", "J."), "Langseth", , "[email protected]", role = "ctb", | ||
comment = c(ORCID = "0000-0002-9901-6146")) | ||
) | ||
Description: The package contains various tools that are useful to | ||
scientists at the Northwest Fisheries Science Center (NWFSC) in the | ||
Population Ecology Program (PEP). Users typically spend the majority | ||
of their time producing assessments of groundfish stock off the U.S. | ||
West Coast. Though, many of the tools will also be useful for the | ||
general science they conduct as well. | ||
License: MIT + file LICENSE | ||
Depends: | ||
R (>= 3.5.0) | ||
Imports: | ||
adnuts, | ||
glue, | ||
lubridate, | ||
pkgbuild, | ||
r4ss, | ||
remotes, | ||
stats, | ||
usethis, | ||
utils | ||
adnuts, | ||
glue, | ||
lubridate, | ||
pkgbuild, | ||
r4ss, | ||
remotes, | ||
stats, | ||
usethis, | ||
utils | ||
Suggests: | ||
devtools, | ||
TMB | ||
devtools, | ||
TMB | ||
Remotes: | ||
github::cole-monnahan-noaa/adnuts, | ||
github::r4ss/r4ss | ||
License: MIT + file LICENSE | ||
github::cole-monnahan-noaa/adnuts, | ||
github::r4ss/r4ss | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.3.1 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,50 @@ | ||
#' Buffer calculation for West Coast groundish assessments | ||
#' | ||
#' @details | ||
#' | ||
#' @details | ||
#' Buffer calculation for U.S. West Coast Groundfish Stocks | ||
#' Applies the time-varying sigma approach based on the 2019 | ||
#' approach described in: | ||
#' approach described in: | ||
#' Wetzel, C.R. and O.S. Hamel, 2023. Applying a probability harvest control rule | ||
#' to account for increased uncertainty in setting precautionary harvest limits | ||
#' from past stock assessments. Fisheries Research 262: 106659. | ||
#' | ||
#' from past stock assessments. Fisheries Research 262: 106659. | ||
#' | ||
#' @param years Years to generate buffer values. The first year should align with | ||
#' the year of the assessment. Input should be vector of years to calulculate | ||
#' West Coast groundfish buffers for (e.g., years = 2021:2032). | ||
#' @param sigma The initial sigma value to use based on West Coast groundfish | ||
#' assessment categories (cat 1 = 0.50, cat 2 = 1.0, cat 3 = 2.0). For categories | ||
#' 1 and 2 the sigma will be time-varying. | ||
#' 1 and 2 the sigma will be time-varying. | ||
#' @param pstar The management risk tolerance determined by the PFMC (i.e., 0.45, 0.40). | ||
#' | ||
#' | ||
#' @examples | ||
#' get_buffer(years = 2011:2032, sigma = 1.0, pstar = 0.4) | ||
#' @author written by Chantel Wetzel | ||
#' @export | ||
#' | ||
get_buffer <- function(years, sigma, pstar){ | ||
|
||
y <- 1:(length(years) - 1) | ||
if (sigma != 2.0) { | ||
# the rate of change in sigma approved by the SSC in 2019 | ||
r <- 0.075 | ||
} else { | ||
get_buffer <- function(years, sigma, pstar) { | ||
y <- 1:(length(years) - 1) | ||
if (sigma != 2.0) { | ||
# the rate of change in sigma approved by the SSC in 2019 | ||
r <- 0.075 | ||
} else { | ||
r <- 0 | ||
} | ||
|
||
# This is the equation for the rate of change in sigma | ||
sigma_calc <- c(sigma, sigma * (1+(y-1)*r)) | ||
buffer <- exp(stats::qnorm(pstar, 0, sigma_calc)) | ||
max_buffer <- exp(stats::qnorm(pstar, 0, 2.0)) | ||
# Set the buffer for fixed catch years to 1.0 | ||
buffer[1:2] <- 1 | ||
category_3 <- which(buffer < max_buffer) | ||
if (length(category_3) > 0) { | ||
buffer[category_3] <- max_buffer | ||
} | ||
|
||
out <- data.frame( | ||
year = years, | ||
buffer = round(buffer, 3) | ||
) | ||
|
||
return(out) | ||
} | ||
} | ||
|
||
# This is the equation for the rate of change in sigma | ||
sigma_calc <- c(sigma, sigma * (1 + (y - 1) * r)) | ||
buffer <- exp(stats::qnorm(pstar, 0, sigma_calc)) | ||
max_buffer <- exp(stats::qnorm(pstar, 0, 2.0)) | ||
# Set the buffer for fixed catch years to 1.0 | ||
buffer[1:2] <- 1 | ||
category_3 <- which(buffer < max_buffer) | ||
if (length(category_3) > 0) { | ||
buffer[category_3] <- max_buffer | ||
} | ||
|
||
out <- data.frame( | ||
year = years, | ||
buffer = round(buffer, 3) | ||
) | ||
|
||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.