Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5ebf47f
feat: read LIKELIHOOD table from Report.sso into stockplotr data object
JZahner1 Nov 12, 2026
3528732
feat: plot_likelihoods
JZahner1 Nov 16, 2026
7147573
refactor: map likelihood values to "estimate" rather than "likelihood…
JZahner1 Nov 16, 2026
5bac73f
docs: :memo: roxygen for plot_likelihoods
JZahner1 Nov 16, 2026
8f35880
build: add plot_likelihoods to NAMESPACE
JZahner1 Nov 16, 2026
57f8d2a
refactor:: remove extra parameters from plot_likelihoods
JZahner1 Nov 16, 2026
4c554cf
refactor: add back in necessary function pars for filter_data
JZahner1 Nov 18, 2026
a9ec022
fix: place "Total" likelihood components as first facet
JZahner1 Nov 18, 2026
e8f16b0
feat: group likelihood components by model when multiple models are p…
JZahner1 Nov 19, 2026
16c18ff
feat: read LIKELIHOOD table from Report.sso into stockplotr data object
JZahner1 Nov 12, 2026
017de0f
feat: plot_likelihoods
JZahner1 Nov 16, 2026
ba45f65
refactor: map likelihood values to "estimate" rather than "likelihood…
JZahner1 Nov 16, 2026
3b0073d
docs: :memo: roxygen for plot_likelihoods
JZahner1 Nov 16, 2026
be39167
build: add plot_likelihoods to NAMESPACE
JZahner1 Nov 16, 2026
d4c57b5
refactor:: remove extra parameters from plot_likelihoods
JZahner1 Nov 16, 2026
7b45624
refactor: add back in necessary function pars for filter_data
JZahner1 Nov 18, 2026
6882667
fix: place "Total" likelihood components as first facet
JZahner1 Nov 18, 2026
46c7c99
feat: group likelihood components by model when multiple models are p…
JZahner1 Nov 19, 2026
a1c1f15
Merge branch 'plot_likelihoods' of https://github.com/JZahner1/stockp…
JZahner1 Nov 25, 2026
d35eed8
build: export plot_likelihoods
JZahner1 Nov 25, 2026
41f984a
docs: updated plot_likelihoods documentation
JZahner1 Nov 25, 2026
14e7371
feat: read LIKELIHOOD table from Report.sso into stockplotr data object
JZahner1 Nov 12, 2026
ca3bda5
feat: plot_likelihoods
JZahner1 Nov 16, 2026
ed8cbb3
refactor: map likelihood values to "estimate" rather than "likelihood…
JZahner1 Nov 16, 2026
bec3267
docs: :memo: roxygen for plot_likelihoods
JZahner1 Nov 16, 2026
e050214
build: add plot_likelihoods to NAMESPACE
JZahner1 Nov 16, 2026
7941e45
refactor:: remove extra parameters from plot_likelihoods
JZahner1 Nov 16, 2026
b3d1249
refactor: add back in necessary function pars for filter_data
JZahner1 Nov 18, 2026
e6ff9fe
fix: place "Total" likelihood components as first facet
JZahner1 Nov 18, 2026
7bfed9d
feat: group likelihood components by model when multiple models are p…
JZahner1 Nov 19, 2026
97359e8
feat: plot_likelihoods
JZahner1 Nov 16, 2026
a2b06d6
refactor:: remove extra parameters from plot_likelihoods
JZahner1 Nov 16, 2026
7baeaa7
refactor: add back in necessary function pars for filter_data
JZahner1 Nov 18, 2026
b66917f
feat: group likelihood components by model when multiple models are p…
JZahner1 Nov 19, 2026
d94343a
build: export plot_likelihoods
JZahner1 Nov 25, 2026
48caf8d
docs: updated plot_likelihoods documentation
JZahner1 Nov 25, 2026
fc0454c
refactor: remove explicit "geom" parameter
JZahner1 Nov 30, 2026
7af98ef
test: fixed failing test
JZahner1 Nov 30, 2026
ee6b752
Merge branch 'plot_likelihoods' of https://github.com/JZahner1/stockp…
JZahner1 Nov 30, 2026
37febd4
feat: read likelihood information for RCeattle models
JZahner1 Dec 1, 2026
a93e649
chore: update pollock example data with likelihoods
JZahner1 Dec 1, 2026
0e2f6a6
refactor: update conout_* to add fleet-specific likelihood components…
JZahner1 Dec 2, 2026
6bc02f5
refector: allow for partial regex matches in filter_interactive
JZahner1 Dec 2, 2026
a1fa918
refactor: plot_likelihoods handles fleet-specific likelihood inputs f…
JZahner1 Dec 2, 2026
f57a8c0
feat: optionally remove 0-valued likelihood components from plot_like…
JZahner1 Dec 2, 2026
115fd65
tests: plot_likelihood tests for prepackaged data
JZahner1 Dec 2, 2026
b35b0e3
fix: add explicit modules to plot_discards test after change to BAM e…
JZahner1 Dec 2, 2026
6416021
feat: read LIKELIHOOD table from Report.sso into stockplotr data object
JZahner1 Nov 12, 2026
2902c76
docs: :memo: roxygen for plot_likelihoods
JZahner1 Nov 16, 2026
f4230fe
feat: read likelihood information for RCeattle models
JZahner1 Dec 1, 2026
ca35be1
chore: update pollock example data with likelihoods
JZahner1 Dec 1, 2026
a28592a
refactor: update conout_* to add fleet-specific likelihood components…
JZahner1 Dec 2, 2026
3dd3b15
refector: allow for partial regex matches in filter_interactive
JZahner1 Dec 2, 2026
5a0fc07
feat: optionally remove 0-valued likelihood components from plot_like…
JZahner1 Dec 2, 2026
53710e1
tests: plot_likelihood tests for prepackaged data
JZahner1 Dec 2, 2026
e025879
fix: add explicit modules to plot_discards test after change to BAM e…
JZahner1 Dec 2, 2026
9659dd2
Merge branch 'main' of https://github.com/JZahner1/stockplotr into pl…
JZahner1 Dec 3, 2026
7cbafbd
Merge branch 'plot_likelihoods' of https://github.com/JZahner1/stockp…
JZahner1 Dec 3, 2026
766b051
refactor: adjust SS3, RCeattle, and BAM likelihood conversion
JZahner1 Dec 3, 2026
e90a2df
data: regenerate pre-packaged datasets with correctly formatted likel…
JZahner1 Dec 3, 2026
8d7616b
refactor: allow process_data to optionally process data in the "likel…
JZahner1 Dec 3, 2026
aae8574
feat: support plotting FIMS likelihoods
JZahner1 Dec 3, 2026
7e66c45
tests: adjust tests to work for new plot_likelihoods setup
JZahner1 Dec 3, 2026
8ce0457
docs: updated roxygen documentation
JZahner1 Dec 3, 2026
6ae4828
feat: optionally allow adding likelihood values to plot as text
JZahner1 Dec 3, 2026
5e0ca1b
fix: plot_likelihoods not correctly aggregating fleet likelihoods in …
JZahner1 Dec 3, 2026
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export(plot_fishing_mortality)
export(plot_index)
export(plot_joint_residuals)
export(plot_landings)
export(plot_likelihoods)
export(plot_natural_mortality)
export(plot_obsvpred)
export(plot_recruitment)
Expand Down
11 changes: 8 additions & 3 deletions R/conout_bam.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,24 @@ conout_bam <- function(
module_name = names(extract)
)
}
if (any(grepl(paste(fleet_names, collapse = "|"), df$label))) {
if (any(grepl(paste(fleet_names, collapse = "|"), tolower(df$label)))) {
df <- df |>
dplyr::mutate(
fleet = dplyr::case_when(
grepl(paste(fleet_names, collapse = "|"), label) ~ stringr::str_extract(label, paste(fleet_names, collapse = "|")),
grepl(paste(fleet_names, collapse = "|"), tolower(label)) ~ stringr::str_extract(tolower(label), paste(fleet_names, collapse = "|")),
TRUE ~ NA
),
label = dplyr::case_when(
is.na(fleet) ~ label,
TRUE ~ stringr::str_replace(label, paste(".", fleet_names, sep = "", collapse = "|"), "")
TRUE ~ stringr::str_replace(tolower(label), paste(".", fleet_names, sep = "", collapse = "|"), "")
)
)
}

if(names(extract) == "like"){
df <- df|> dplyr::rename(likelihood = estimate)
}

df[setdiff(tolower(names(out_new)), tolower(names(df)))] <- NA
out_list[[names(extract)]] <- df
}
Expand Down
35 changes: 34 additions & 1 deletion R/conout_rceattle.R
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ conout_rceattle <- function(
# Rceattle stores sex 1 as females, or both sexes when nsex = 1.
sex_names <- if (nsex == 1) NA_character_ else c("female", "male")
quantities_list <- list()
likelihoods_list <- list()

if ("sel_at_age" %in% names(extract[[1]])) {
sel <- extract[[1]][["sel_at_age"]][, seq_len(nsex), seq_along(ages), , drop = FALSE]
Expand Down Expand Up @@ -438,14 +439,46 @@ conout_rceattle <- function(
quantities_list[["m_at_age"]] <- df_m
}

if("jnll_comp" %in% names(extract[[1]])) {
jnll_comp_fleet <- extract[[1]][["jnll_comp"]]
jnll_comp_fleet_df <- jnll_comp_fleet |>
as.data.frame() |>
tibble::rownames_to_column(var = "label") |>
tidyr::pivot_longer(cols=2:dplyr::last_col(), names_to="fleet", values_to="likelihood")

# jnll_comp_df <- jnll_comp_fleet_df |>
# dplyr::group_by(label) |>
# dplyr::summarise(estimate = sum(estimate), .groups = "drop") |>
# dplyr::mutate(type = "values")

jnll_comp_fleet_df[setdiff(tolower(names(out_new)), tolower(names(jnll_comp_fleet_df)))] <- NA
# jnll_comp_df[setdiff(tolower(names(out_new)), tolower(names(jnll_comp_df)))] <- NA

likelihoods_list[["jnll_comp_fleet"]] <- jnll_comp_fleet_df
# likelihoods_list[["jnll_comp"]] <- jnll_comp_df

# jnll_df <- data.frame(label="Total data", estimate=sum(jnll_comp_df$estimate), type="values")
# jnll_df[setdiff(tolower(names(out_new)), tolower(names(jnll_df)))] <- NA
#
# likelihoods_list[["jnll"]] <- jnll_df

}

if (length(quantities_list) > 0) {
out_list[[names(extract)]] <- Reduce(rbind, quantities_list) |>
dplyr::mutate(
module_name = names(extract),
age = as.character(age)
)
}
} else if (is.list(extract[[1]])) { # indicates vector and list

if (length(likelihoods_list) > 0) {
out_list[["likelihoods"]] <- Reduce(rbind, likelihoods_list) |>
dplyr::mutate(
module_name = "likelihoods"
)
}
}else if (is.list(extract[[1]])) { # indicates vector and list
##### remaining lmnts ####
if (any(vapply(extract[[1]], is.matrix, FUN.VALUE = logical(1)))) {
##############################################################
Expand Down
57 changes: 38 additions & 19 deletions R/conout_ss3.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ conout_ss3 <- function(
# ntentionally empty
std2 <- c()
cha <- c()
info <- c()
info <- c("likelihoods_used", "likelihoods_laplace", "likelihoods_by_fleet")
}

# Loop for all identified parameters to extract for plotting and use
Expand Down Expand Up @@ -1043,24 +1043,43 @@ conout_ss3 <- function(
# next
#### info ####
} else if (parm_sel %in% info) {
# if (parm_sel == "LIKELIHOOD") {
# df1 <- extract[-1, ]
# # make row the header names for first df
# colnames(df1) <- df1[1, ]
# # Remove first row containing column names
# df2 <- df1[-1, ] |>
# dplyr::rename(label = Component) |>
# tidyr::pivot_longer(
# cols = -label,
# names_to = "type",
# values_to = "likelihood"
# )
# # match to out_new
# df2[setdiff(tolower(names(out_new)), tolower(names(df2)))] <- NA
# # Add to out list
# out_list[[parm_sel]] <- df2
# } else
if (parm_sel == "DEFINITIONS") {
if (parm_sel %in% c("likelihoods_used", "likelihoods_laplace")) {
# df1 <- extract#[-1, ]
# # make row the header names for first df
# # colnames(df1) <- df1[1, ]
# # Remove first row containing column names
# df2 <- df1 |>
# tibble::rownames_to_column("Component") |>
# dplyr::rename(label = Component) |>
# tidyr::pivot_longer(
# cols = -label,
# names_to = "type",
# values_to = "estimate"
# ) |>
# dplyr::mutate(module_name="likelihoods")
# # match to out_new
# df2[setdiff(tolower(names(out_new)), tolower(names(df2)))] <- NA

# out_list[[parm_sel]] <- df2
} else if(parm_sel == "likelihoods_by_fleet"){
df1 <- extract
df2 <- df1 |>
dplyr::filter(!grepl("use|skip|lambda", Label)) |>
dplyr::rename(label=Label) |>
dplyr::select(-ALL) |>
tidyr::pivot_longer(
cols = -label,
names_to = "fleet",
values_to = "likelihood"
) |>
tidyr::separate(col=label, into=c("label", "type"), sep="_(?=lambda|like|N)", remove=FALSE, extra="merge") |>
dplyr::mutate(module_name="likelihoods")

df2[setdiff(tolower(names(out_new)), tolower(names(df2)))] <- NA

out_list[[parm_sel]] <- df2
} #else
else if (parm_sel == "DEFINITIONS") {
# Extract start year and end year for iding era
start_year <- as.numeric(extract[which(apply(extract, 1, function(row) any(row == "Start_year:"))), 2])
end_year <- as.numeric(extract[which(apply(extract, 1, function(row) any(row == "End_year:"))), 2])
Expand Down
1 change: 1 addition & 0 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ convert_output <- function(
}
}

model <- models[i]
# Recognize model through file extension
if (is.character(file) && tolower(stringr::str_extract(file, "\\.([^.]+)$")) == ".rds") {
file <- readRDS(file)
Expand Down
9 changes: 7 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#' \item{bio_pattern}{Indexing column of data}
#' \item{settlement}{Indexing column of data}
#' \item{morph}{Indexing column of data}
#' \item{beg_mid}{Whether a time series value refers to the beginning or middle of the season}
#' \item{type}{Indexing column of data}
#' \item{factor}{Indexing column of data}
#' \item{part}{Indexing column of data}
Expand All @@ -86,7 +87,8 @@
#' \item{length_bins}{Length bins for composition or other length based data}
#' \item{count}{Indexing column of data}
#' \item{block}{Indexing column of data}
#' \item{model}{Indexing column of data}
#' \item{unit}{Units of the estimate when reported by the model}
#' \item{model}{Name of the model the row belongs to, assigned by convert_output()}
#' }
#'
#' @keywords datasets
Expand All @@ -111,7 +113,7 @@
#'
#' @usage data(vermilion_snapper)
#'
#' @format A tibble (\code{tbl_df}, \code{tbl}, \code{data.frame}) with 35,881 rows and 35 variables:
#' @format A tibble (\code{tbl_df}, \code{tbl}, \code{data.frame}) with 686,991 rows and 36 variables:
#' \describe{
#' \item{label}{Standard name for estimate or value name}
#' \item{estimate}{Actual value of the label}
Expand All @@ -136,6 +138,7 @@
#' \item{bio_pattern}{Indexing column of data}
#' \item{settlement}{Indexing column of data}
#' \item{morph}{Indexing column of data}
#' \item{beg_mid}{Whether a time series value refers to the beginning or middle of the season}
#' \item{type}{Indexing column of data}
#' \item{factor}{Indexing column of data}
#' \item{part}{Indexing column of data}
Expand All @@ -146,6 +149,8 @@
#' \item{length_bins}{Length bins for composition or other length based data}
#' \item{count}{Indexing column of data}
#' \item{block}{Indexing column of data}
#' \item{unit}{Units of the estimate when reported by the model}
#' \item{model}{Name of the model the row belongs to, assigned by convert_output()}
#' }
#'
#' @keywords datasets
Expand Down
4 changes: 2 additions & 2 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ plot_biomass <- function(
# TODO: check and add into process_data step to summarize when theres >1 label
processing <- process_data(
prepared_data,
group,
facet
group = group,
facet = facet
)

# variable <- processing[[1]]
Expand Down
Loading
Loading