Skip to content

Scale uncertainty intervals if relative = TRUE for B and SB plots#230

Open
sbreitbart-NOAA wants to merge 1 commit intodevfrom
fix-rel-b
Open

Scale uncertainty intervals if relative = TRUE for B and SB plots#230
sbreitbart-NOAA wants to merge 1 commit intodevfrom
fix-rel-b

Conversation

@sbreitbart-NOAA
Copy link
Copy Markdown
Collaborator

Address #218

Comment on lines +125 to +126
estimate_lower = estimate_lower / ref_line_val,
estimate_upper = estimate_upper / ref_line_val
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.

@sbreitbart-NOAA I am not sure if I fully understand what is going on here because I have not looked too terribly hard at the code but I just wanted to let you know that the uncertainty should be the uncertainty based on the actual derived quantity and not just the scaled uncertainty. For example, the uncertainty of biomass comes from the calculation of the confidence intervals of biomass using the standard deviation of biomass estimate. The same should be true for unfished biomass, where the uncertainty of what is being plotted should be from a standard deviation.

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 am not following. Here we are scaling down the uncertainty when relative = TRUE where all values on the plot are getting scaled by the reference line value. Are you saying that here the confidence intervals should be based on the error for the reference line?

Are the current calculation for error correct in filter_data?

stockplotr/R/utils_plot.R

Lines 680 to 689 in 0397a61

estimate_lower = dplyr::case_when(
grepl("se", uncertainty_label) ~ (estimate - (1.96 * uncertainty)) / scale_amount,
grepl("sd", tolower(uncertainty_label)) | grepl("std", tolower(uncertainty_label)) ~ (estimate - uncertainty) / scale_amount,
grepl("cv", tolower(uncertainty_label)) ~ (estimate - (1.96 * (uncertainty * estimate))) / scale_amount,
TRUE ~ NA
),
estimate_upper = dplyr::case_when(
grepl("se", uncertainty_label) ~ (estimate + (1.96 * uncertainty)) / scale_amount,
grepl("sd", tolower(uncertainty_label)) | grepl("std", tolower(uncertainty_label)) ~ (estimate + uncertainty) / scale_amount,
grepl("cv", tolower(uncertainty_label)) ~ (estimate + (1.96 * (uncertainty * estimate))) / scale_amount,

After review, I think they aren't correct except for SE, but I get confused with error calcs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@kellijohnson-NOAA thank you for noticing this- I remember discussing this a while back. I don't know the proper method to use here. Maybe the steering committee would know?

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.

If you were multiplying or dividing by a constant it would be fine but we aren't instead we are dividing my a calculated value that has its own uncertainty. There are ways to calculate the uncertainty of the result but more typically, you just output the derived quantity, e.g., time series of spawning_biomass/unfished_biomass, as another derived quantity and you get the uncertainty of the time series.

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.

Ah okay I see. This is jogging my memory now thanks!

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.

[Bug]: plot_biomass not plotting relative error values when relative = TRUE

3 participants