From e7d849c5c6a4940092651888fc4fab44e9a19aab Mon Sep 17 00:00:00 2001 From: iantaylor-NOAA Date: Fri, 17 Apr 2026 10:05:36 -0700 Subject: [PATCH 1/4] attempt to support runs test for size frequency data --- R/SScompsTA1.8.R | 6 +++++- R/SSplotRunstest.R | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/R/SScompsTA1.8.R b/R/SScompsTA1.8.R index 2b2c5218..0797b802 100644 --- a/R/SScompsTA1.8.R +++ b/R/SScompsTA1.8.R @@ -131,7 +131,11 @@ SScompsTA1.8 <- function(ss3rep, type = c("len", "age", "size", "con"), fleet = } if (gender.flag) pldat <- cbind(pldat, pick.gender = 0) - if (method.flag) pldat <- cbind(pldat, method = 0) + if (method.flag) { + pldat <- cbind(pldat, method = 0) + # vector to store units (which are strings and don't fit in pldat matrix) + plunits <- rep(NA, nrow(pldat)) + } # Find the weighting factor for this combination of factors if (type[1] == "con") { diff --git a/R/SSplotRunstest.R b/R/SSplotRunstest.R index 776c5c89..5050c64f 100644 --- a/R/SSplotRunstest.R +++ b/R/SSplotRunstest.R @@ -184,12 +184,12 @@ SSplotRunstest <- function(ss3rep, } subplots <- subplots[1] - datatypes <- c("Index", "Mean length", "Mean age", "Conditional age-at-length") - ylabel <- datatypes[which(c("cpue", "len", "age", "con") %in% subplots)] + datatypes <- c("Index", "Mean length", "Mean age", "Conditional age-at-length", "Size frequency") + ylabel <- datatypes[which(c("cpue", "len", "age", "con", "size") %in% subplots)] if (length(ylabel) == 0) { - stop(subplots, "is not a valid type. Please choose from the options cpue, len, age, size, or con") + stop(subplots, " is not a valid type. Please choose from the options cpue, len, age, size, or con") } - if (verbose) message("Running Runs Test Diagnostics w/ plots for", datatypes[which(c("cpue", "len", "age", "con") %in% subplots)]) + if (verbose) message("Running Runs Test Diagnostics w/ plots for", datatypes[which(c("cpue", "len", "age", "con", "size") %in% subplots)]) if (subplots == "cpue") { cpue <- ss3rep[["cpue"]] cpue[["residuals"]] <- ifelse(is.na(cpue[["Obs"]]) | is.na(cpue[["Like"]]), NA, log(cpue[["Obs"]]) - log(cpue[["Exp"]])) @@ -435,13 +435,13 @@ SSplotRunstest <- function(ss3rep, SSrunstest <- function(ss3rep, mixing = "less", - quants = c("cpue", "len", "age", "con")[1], + quants = c("cpue", "len", "age", "con", "size")[1], indexselect = NULL, verbose = TRUE) { - datatypes <- c("Index", "Mean length", "Mean age", "Conditional age-at-length") + datatypes <- c("Index", "Mean length", "Mean age", "Conditional age-at-length", "Size frequency") subplots <- quants - ylabel <- datatypes[which(c("cpue", "len", "age", "con") %in% subplots)] - if (verbose) cat("Running Runs Test Diagnosics for", datatypes[which(c("cpue", "len", "age", "con") %in% subplots)], "\n") + ylabel <- datatypes[which(c("cpue", "len", "age", "con", "size") %in% subplots)] + if (verbose) cat("Running Runs Test Diagnosics for", datatypes[which(c("cpue", "len", "age", "con", "size") %in% subplots)], "\n") if (subplots == "cpue") { cpue <- ss3rep[["cpue"]] cpue[["residuals"]] <- ifelse(is.na(cpue[["Obs"]]) | is.na(cpue[["Like"]]), NA, log(cpue[["Obs"]]) - log(cpue[["Exp"]])) @@ -452,7 +452,7 @@ SSrunstest <- function(ss3rep, Res <- cpue } - if (subplots == "len" | subplots == "age") { + if (subplots == "len" | subplots == "age" | subplots == "size") { comps <- SScompsTA1.8(ss3rep, fleet = NULL, type = subplots, plotit = FALSE)[["runs_dat"]] comps[["residuals"]] <- ifelse(is.na(comps[["Obs"]]), NA, log(comps[["Obs"]]) - log(comps[["Exp"]])) if (is.null(comps[["Fleet_name"]])) { # Deal with Version control @@ -521,7 +521,7 @@ SSrunstest <- function(ss3rep, runstable <- data.frame(Index = indices, runs.p = as.matrix(runs)[, 1], Test = ifelse(is.na(as.matrix(runs)[, 1]), "Excluded", ifelse(as.matrix(runs)[, 1] < 0.05, "Failed", "Passed")), sigma3.lo = as.matrix(runs)[, 2], sigma3.hi = as.matrix(runs)[, 3], type = subplots) colnames(runstable) <- c("Index", "runs.p", "test", "sigma3.lo", "sigma3.hi", "type") - if (verbose) cat(paste0("Residual Runs Test stats by ", datatypes[which(c("cpue", "len", "age", "con") %in% subplots)], ":", "\n")) + if (verbose) cat(paste0("Residual Runs Test stats by ", datatypes[which(c("cpue", "len", "age", "con", "size") %in% subplots)], ":", "\n")) return(runstable) } # end of SSplotRuns() #----------------------------------------------------------------------------------------- From fe2c7750292a7a48ea2d86841d8c3d19cbb56c87 Mon Sep 17 00:00:00 2001 From: iantaylor-NOAA Date: Fri, 17 Apr 2026 11:08:23 -0700 Subject: [PATCH 2/4] use current r4ss version on main - error in github action may be caused by using latest r4ss release which is out of date --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d78e0f2a..9421edc1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,7 +33,7 @@ Suggests: rmarkdown, testthat (>= 3.0.0) Remotes: - r4ss/r4ss@*release + r4ss/r4ss Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 From 7a7c7b2df23de6c0d9132c882666d116e7fe42fa Mon Sep 17 00:00:00 2001 From: Eric Fletcher <37851243+efletcherPIFSC@users.noreply.github.com> Date: Fri, 17 Apr 2026 12:59:32 -1000 Subject: [PATCH 3/4] Updated RoxyenNote to 7.3.3 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9421edc1..6876ef32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,4 +36,4 @@ Remotes: r4ss/r4ss Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 From 92e7b859deaf8361a58245974b35a57b9f2e8d5a Mon Sep 17 00:00:00 2001 From: Eric Fletcher <37851243+efletcherPIFSC@users.noreply.github.com> Date: Fri, 17 Apr 2026 13:06:22 -1000 Subject: [PATCH 4/4] SSrunstest function documention parameter quants updated with value 'size' --- man/SSrunstest.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/SSrunstest.Rd b/man/SSrunstest.Rd index 5841b63c..14c57741 100644 --- a/man/SSrunstest.Rd +++ b/man/SSrunstest.Rd @@ -7,7 +7,7 @@ SSrunstest( ss3rep, mixing = "less", - quants = c("cpue", "len", "age", "con")[1], + quants = c("cpue", "len", "age", "con", "size")[1], indexselect = NULL, verbose = TRUE )