Skip to content

[feat]: Add relative option to plot_index, follows #468 - #469

Merged
Schiano-NOAA merged 14 commits into
nmfs-ost:mainfrom
ericward-noaa:more-fims-plots-index-relative
Nov 13, 2026
Merged

Schiano-NOAA merged 14 commits into
nmfs-ost:mainfrom
ericward-noaa:more-fims-plots-index-relative

Conversation

@ericward-noaa

@ericward-noaa ericward-noaa commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What is the feature?

How have you implemented the solution?

#' @PARAM relative Logical. TRUE/FALSE; divide each fleet's observed and
#' predicted index (and intervals) by the mean of its observed index, and plot
#' all fleets on one panel, colored by fleet. Indices with conflicting trends
#' (data conflicts) are a common cause of poor fits and are easiest to see
#' this way (r4ss::SSplotIndices() subplot 9). Any group other than
#' "fleet" is added to facet.

Does the PR impact any other area of the project, maybe another repo?

  • just plot_index()

PR contribution checklist

Thank you for contributing to stockplotr! Please check the boxes below to confirm this pull request (PR) is ready for review. Edit this PR description to add the release indicator and any explanations.

  • I have read and adhered to the contributor guide.
  • I have kept this PR focused on one plot where applicable. For multiple features, I have used separate PRs (stacked PRs are welcome if needed).
  • I have aimed to keep this PR to no more than 750 lines, excluding tests and example data (for example, up to 750 lines for a new function).
  • If I have provided an example dataset, I have explained why the existing sample datasets are not sufficient.
  • I have tested that my changes are compatible with all example outputs in the "data" folder (example_data.rda; pollock.rda; ss3_simple.rda; vermilion_snapper.rda).
  • If I didn't follow the development workflow, I have explained why in this PR.
  • If applicable, I've added the plot to save_all_plots() and updated the associated tests in test-save_all_plots.R.
  • After opening this PR, I have checked that my own tests and spellcheck pass (spelling::spell_check_package()). If other checks fail, I have flagged them for the package maintainers to help diagnose and remedy.
  • I have requested review from one package maintainer (Sam or Sophie).

convert_output() passed FIMS output through unchanged, so `estimate` and
`year` were empty and no stockplotr plot could use it. The new
conout_fims() reshapes `FIMS::get_estimates()` output (or a FIMSFit object,
or an .rds file with either):

- Each data point (index, landings, age and length compositions) is split
  into "*_observed" and "*_predicted" rows, with the observation error and
  negative log-likelihood on the observed row, as for SS
- `estimated` becomes `estimate`, and the new `start_year` argument converts
  FIMS year indices to years; `era` is "time", or "fore" after the last year
  of data.
- fims_var_names.csv maps current FIMS labels (e.g., expected_recruitment,
  numbers_at_age, log_devs) to the standard labels.

Also fixes:
- convert_output() ignored a user-supplied `model` when `file` is an object.
- plot_index() matched every label containing "index" (e.g., index_log_q in
  Rceattle output or index numbers at age in FIMS output); it now plots only
  index_observed and index_predicted.
- plot_index() failed for a single index fleet, because the fleet facet was
  added back after process_data() dropped the column.
plot_index() adds `interval`, which draws intervals around the observed
index from its observation error, and `log`, which plots the index on a log
scale. Intervals assume lognormal errors, as in Stock Synthesis, FIMS, BAM,
and Rceattle: uncertainty labeled "se", "sd", or "log_sd" is used as the
log-scale standard error, and a CV is converted with sqrt(log(1 + CV^2)).
Both default to the current behavior (no intervals, linear scale).
…ative = TRUE)` `relative = TRUE` divides each fleet's observed and predicted index (and intervals) by the mean of its observed index and plots all fleets on one panel, colored by fleet, so that trends can be compared among indices (r4ss SSplotIndices subplot 9). Facet variables with one value for each fleet (e.g., the month of each survey) do not split the panel.

`relative = TRUE` divides each fleet's observed and predicted index (and
intervals) by the mean of its observed index and plots all fleets on one
panel, colored by fleet, so that trends can be compared among indices
(r4ss SSplotIndices subplot 9). Facet variables with one value for each
fleet (e.g., the month of each survey) do not split the panel.
@ericward-noaa ericward-noaa changed the title [feat]: Add relative option to plot_index [feat]: Add relative option to plot_index, follows #468 Nov 6, 2026
@ericward-noaa

Copy link
Copy Markdown
Contributor Author

@sbreitbart-NOAA @Schiano-NOAA this is ready for review

Comment thread R/plot_index.R Outdated
#' Options: May include, but is not limited to: "fleet", "year", "area", NULL
#' @param unit_label String. Index of abundance/CPUE units
#'
#' Default: ""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same adjustments apply here. I think it is recognizing this as a new change since I am assuming this branch was made from the last. Sorry for the duplicate work!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@Schiano-NOAA Schiano-NOAA left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just needs the same change the other PR did with the units because they aren't set to "" by default but otherwise good.

Comment thread R/plot_index.R Resolved
ericward-noaa and others added 2 commits November 13, 2026 13:05
Co-authored-by: Sam (Schiano) Bredeck <125507018+Schiano-NOAA@users.noreply.github.com>
@ericward-noaa

Copy link
Copy Markdown
Contributor Author

@Schiano-NOAA Good catch, changed here

@Schiano-NOAA
Schiano-NOAA merged commit 84084a8 into nmfs-ost:main Nov 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants