Skip to content

relax tolerance for composition data sum = 1? #1669

Description

@iantaylor-NOAA

While working on the sardine case study (edit: here's the link to the line causing the error: https://github.com/NOAA-FIMS/case-studies/blob/render-case-studies-separately/content/SWFSC-sardine.qmd#L135), I got a series of errors starting with

  Group-level information for age composition errors
* type = age_comp
* fleet = fleet1
* timing = 2005
* unit = proportion
* uncertainty = 124.28
! Errors are as follows:
x The sum is equal to 1.0000001158674, not 1.0.

This is frustrating because the case-study code explicitly divides by the sum to create proportions and also because for purposes of R's typical rounding, the result IS equal to 1, so it's not clear how to fix the problem:

data_4_model |> dplyr::filter(type == "age_comp", timing == 2005, fleet == "fleet1") |> dplyr::pull(value) |> sum()
[1] 1

I know the integer vs decimal proportion debate is still ongoing in #326, but will it break anything if we relax this tolerance value a bit without breaking anything for the sake of avoiding unnecessary frustration:

if (all(units == "proportion") && abs(sum_of_value - 1.0) > 1e-8) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage_neededThis is not approved for this milestone, do not work on it yet

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions