Skip to content

[feat]: get index error distribution from SS3 models #471

Open

Description

@iantaylor-NOAA

Is your feature request related to a problem? Please describe.

Thanks to @ericward-noaa for adding index intervals in #468. This is an important feature that is important to be able to interpret the index fits.

One refinement needed in the future is to account for the fact that SS3 has multiple options for error structure for indices:

  • -1=normal;
  • 0=lognormal;
  • 1=lognormal with bias correction;
  • >1=df for T-distribution

Of these, lognormal probably covers at least 95% of models, but the normal error is used for models that include an environmental predictor of recruitment deviations.

The plot below was created loading stockplotr from Eric's fork associated with #468 and running the following code which relies on a petrale sole model with an index of recruitment deviations posted by @okenk. The "env" fleet uses normal error since the index spans zero so the intervals should be symmetric around the points and not tiny for observations close to zero.

petrale <- r4ss::SS_output('https://raw.githubusercontent.com/okenk/recruit_index_sims/refs/heads/main/simulations/petrale/0.2_30/30/em/')
petrale_converted <- convert_output(petrale)
plot_index(petrale_converted, interval = 0.95, module = "cpue")
Image

Describe the solution you would like.

I don't think that convert_output() is currently getting the information on error structure. In Report.sso that's in a separate table from the main table of index output.

Currently, r4ss::SS_output() returns the table $cpue (which is converted and serves the basis for the plots) as well as two vectors $survey_units (which is probably not needed for plotting), and $survey_error, which contains the codes above.

I'm happy to modify r4ss::SS_output() to merge those vectors into $cpue so that units and error were just additional columns. These would then need to be somehow integrated into the table created by convert_output(), ideally in a format that is similar to what FIMS will use to store index error structure assuming that in the future there will be additional uncertainty options beyond the current ~ dlnorm() option.

Describe alternatives you have considered

stockplotr::convert_output() could also do the merging of the separate SS3 tables

Additional context

No response

Activity

  1. JZahner1 commented on Nov 9, 2026

    @JZahner1
    Collaborator

    @iantaylor-NOAA is it sufficient to simply store the error structure as a string in a new column (e.g., "uncertainty_structure"), and change the calculation of "estimate_lower" and "estimate_upper" performed in filter_data to account for the the error structure and interval size? I think the code in #468 is close, but could be integrated directly into filter_data (rather than overriding the lower/upper estimates afterwards) and be made to generalize to other error structures (e..g. normal and lognormal; not sure how it would work for more complex distributions where uncertainty is based on multiple parameters).

  2. iantaylor-NOAA commented on Nov 10, 2026

    @iantaylor-NOAA
    ContributorAuthor

    @JZahner1, yes, I think that would work fine (acknowledging that I haven't studied #468 closely at all).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions