-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Feature]: Better QQ plots #11
Comments
?residuals.sdmTMB
https://pbs-assess.github.io/sdmTMB/articles/web_only/residual-checking.html
On the topic of QQ plots, I fixed a bug in |
Check that Q-Q plots are unique to a model because changing the distribution doesn't appear to change the resulting figure even if the model has a difference in likelihood. An additional thought, from an email request ... A plot of quantile residual (y axis) vs predicted would be a useful diagnostic. |
Thanks @seananderson for updating the codebase. I see that the recommended And, @okenk the figures that were placed on the network originally were only the qq plots for the first model component, not the rate model. I have updated to plotting both of them on the same figure. These are qq plots from canary for 2023 with the lognormal on the left and the gamma on the right. |
Thanks! Also great that lognormal looks better since we had already picked that one. :) |
Also tagging @brianlangseth-NOAA so he sees this. |
@kellijohnson-NOAA Thank you for continuing to work on improving our diagnostic tools. Providing a QQ line for each of the models makes it easier to identify the error structure that best fits the data. Can I request that on the plot we modify the labeling in the legend from model 1 and 2 to "presence-absence" and "rate"? I don't think there is a pressing need to modify this now but I think long-term that labeling would be the clearest for users and reviewers. |
You bet @chantelwetzel-noaa, I altered the legend text (see below). And, for those at large I investigated |
* stop using `abline(0,1)` and use the results of `stats::qqline()` * color by model component * return the ggplot2 object * increase documentation * fix code to run it in diagnose * stop calculating the residuals ten thousand times * pass just the data frame of residuals and raw data to `map_residuals()` rather than the fit object that was altered Part of #11
This is great, thank you @kellijohnson-NOAA. Will it be possible to get these plots for a model that's already been run, or is it easier to just update the package once you've completed this change and re-run the models? If you're taking more requests, can I request that the colors not include yellow which is just hard to see when projected on a screen? |
I just pushed the code @iantaylor-NOAA to main so you just need to reinstall and run
I am for sure open to discussion about the colors but they have strategically been chosen by {viridis} to be easily accessible to those with disabilities or when printed in black and white. |
Sometimes when {viridis} when only plotting two items where the colors default to that purple and yellow, I have modified the begin and end inputs to be: begin = 0 and end = 0.5 that modifies the two colors to be that purple and a teal instead of the yellow. However, I don't recall any projection issues using that default yellow to date, so perhaps that is not entirely necessary. |
On residuals, I assume you've seen it, but just in case: https://pbs-assess.github.io/sdmTMB/articles/web_only/residual-checking.html Yes, you can do MCMC residuals (with fixed effects at their MLE) with delta models. That's what they did in this paper. Those are currently set up for each model part independently. Those will be slow for large models. You may be able to get away with fewer iterations than the default and keep in mind that only the last iteration is kept as the residuals. I need to rethink the interface, because it currently forces you to sample from the model for each model component. You could sample yourself and then grab as many sets of residuals as you want all at once. I can point you to code if you are interested—it's basically pulling code out from the residuals.sdmTMB function. There are DHARMa residuals ( There are also one-step-ahead residuals, which aren't set up right now. |
I'm not sure what the evolving best practice is here. These (randomized quantal residuals with the Laplace approximation) and DHARMa residuals with the Laplace approximation can definitely look off even if the model is consistent with the data. MCMC residuals with fixed effects at their MLE seem to work well but take longer. That's what they used here.
?residuals.sdmTMB
https://pbs-assess.github.io/sdmTMB/articles/web_only/residual-checking.htmlNote that because of esoteric problems on CRAN, we had to split that out into its own (non-CRAN) package.
In a perfect world you'd sample with more MCMC iterations first.
Originally posted by @seananderson in #10 (comment)
The text was updated successfully, but these errors were encountered: