Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add index comparisons and residual plots #67

Open
iantaylor-NOAA opened this issue Jul 10, 2015 · 6 comments
Open

add index comparisons and residual plots #67

iantaylor-NOAA opened this issue Jul 10, 2015 · 6 comments

Comments

@iantaylor-NOAA
Copy link
Contributor

Make it easier to compare multiple indices, with or without fits, and also add plots of index residuals (either obs - exp or weighting by index uncertainty).

@allanhicks
Copy link
Contributor

I just wrote some code to do this for the Widow assessment. I'll start a branch and provide the code. Here is an example from the Widow assessment.
hakecpuefits
It will leave the fitted line off with an argument so you can simply plot the data.

The function will need some work.

@iantaylor-NOAA
Copy link
Contributor Author

Hi Allan,
This looks excellent. It might be good to have a log vs. non-log switch as
well.
-Ian

On Sat, Jul 11, 2015 at 2:20 PM, allanhicks notifications@github.com
wrote:

I just wrote some code to do this for the Widow assessment. I'll start a
branch and provide the code. Here is an example from the Widow assessment.
[image: hakecpuefits]
https://cloud.githubusercontent.com/assets/6164069/8635438/d10f1e52-27d7-11e5-8805-a94252f65ff3.png
It will leave the fitted line off with an argument so you can simply plot
the data.

The function will need some work.


Reply to this email directly or view it on GitHub
#67 (comment).

@allanhicks
Copy link
Contributor

It does inherently. The "..." in the argument list allow you to enter log="y", which is how the above plot was produced. Without that the axis would be in real space. But, are thinking someone may want to plot the actual log of the indices?

@iantaylor-NOAA
Copy link
Contributor Author

The use of log="y" in ... sounds like a great solution.

Also worth considering (thanks to Aaron Berger) would be some optional scaling to mean or max or a user-input vector of scaling factors for each fleet (or each index) that would allow you to line up the exploitable biomass even when selectivity differs among fleets. However, I think that sounds like an idea for the future, not immediately necessary.

@iantaylor-NOAA
Copy link
Contributor Author

Thanks @allanhicks -- the plotIndices function in the indicesPlot branch at https://github.com/r4ss/r4ss/blob/indicesPlot/R/plotIndices.R is great.

It would be good to include this in the set of plots called automatically by SS_output.

Here are a few suggestions for future changes. I'm happy to leave this to you or make some changes myself if you prefer (and think they are good ideas):

  • Apply scale to ylim and tmp$Exp
  • Add ylab
  • Either make a sub-function of SSplotIndices or document inputs using roxygen2 comments at the top (similar to other r4ss functions)
  • Add things like pngfun and caption to facilitate integration with other the HTML view option used by other r4ss functions.

Additionally, here are a few thoughts regarding some of the notes in the code

  • would be nice if it could use the readDat to only plot the data I assume the goal would be to evaluate or debug inputs without having to run the model. This seems useful but it's probably worth waiting until SS_readdat_3.30 is working. Also, I would prefer that this the data file not be read by default as none of the other functions called by SS_output depend in the SS input files.
  • should a change in q have a broken line? This also seems like a good idea but not necessarily to have the function be really useful.
  • plot input and output confidence intervals to show effect of additional variation This is included in SSplotIndices and the code could either be copied into plotIndices or plotIndices could be used directly if plotIndices is included as a sub-function of SSplotIndices. Also not needed for the function to be useful.

@iantaylor-NOAA
Copy link
Contributor Author

Changes made in a9b0da2, now available in the development branch add new default plots in the "Index" tab showing two types of index residuals:

  • Residuals: (log(Obs) - log(Exp))/SE where SE is the total standard error including any estimated additional uncertainty
  • Deviations: log(Obs) - log(Exp) and thus independent of index uncertainty

Indices with normal error don't have the log.

For models with rapid dynamics and many index observations, as in the example plots below, these should be a helpful diagnostic.

Thanks to Michelle Masi and Erik Williams for inspiration on this, and to @James-Thorson for advice.

Example index fit plot where it's hard to track any misfit:
image
Example residual plot that's easier to look for bad patterns:
image

e-perl-NOAA added a commit that referenced this issue May 26, 2023
* change r-version to 4.2.3

---------

Co-authored-by: egugliotti <egugliotti@gmail.com>
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

No branches or pull requests

2 participants