-
-
Notifications
You must be signed in to change notification settings - Fork 84
Add ppc_loo_pit_ecdf #345
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
base: master
Are you sure you want to change the base?
Add ppc_loo_pit_ecdf #345
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #345 +/- ##
==========================================
- Coverage 98.66% 98.60% -0.06%
==========================================
Files 35 35
Lines 5466 5533 +67
==========================================
+ Hits 5393 5456 +63
- Misses 73 77 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Maybe we don't use the
where
It would be nice to have the same signature, but I agree with you that your new one is more clear. Since the new one is better, it's ok with me to have a different signature for now until we can also update the one for |
man/PPC-loo.Rd
Outdated
eval_points = NULL, | ||
K = NULL, | ||
prob = 0.99, | ||
plot_diff = FALSE, | ||
interval_method = c("interpolate", "optimize") | ||
interpolate_adj = NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also unified the arguments for now, to keep the code more simple.
I suggest that, when I work on the documentation and possibly need to rearrange how the PPC function pages are grouped, I will add the clearer argument names and add a deprecation warning to the old ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, with this rearranging, the template could come back to use with ppc_loo_pit_intervals()
.
It would probably make sense to have ppc_(loo)_pit_ecdf()
, ppc_loo_pit_qq()
, and ppc_loo_pit_overlay()
share a documentation page, and move ppc_loo_intervals()
, and ppc_loo_ribbon()
join their LOOless counterparts on the PPC intervals documentation page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also unified the arguments for now, to keep the code more simple.
I suggest that, when I work on the documentation and possibly need to rearrange how the PPC function pages are grouped, I will add the clearer argument names and add a deprecation warning to the old ones.
Sounds good, I like that plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, with this rearranging, the template could come back to use with
ppc_loo_pit_intervals()
.It would probably make sense to have
ppc_(loo)_pit_ecdf()
,ppc_loo_pit_qq()
, andppc_loo_pit_overlay()
share a documentation page, and moveppc_loo_intervals()
, andppc_loo_ribbon()
join their LOOless counterparts on the PPC intervals documentation page.
That also sounds good. When I first included those LOO-based plots I thought it made sense to put them all together. But I think you're right that this reorganization makes sense at this point. I think we'll just want to link between the documentation pages, pointing out that there are other LOO-based plots in various locations.
The code looks great. I will try to make some time later today to actually try using the function. One minor request for now: can you mention this function in the "Plot Descriptions" section of the documentation? |
tests/testthat/test-ppc-loo.R
Outdated
expect_equal(p1$labels$x, "LOO PIT") | ||
expect_equal(p1$labels$y, "ECDF") | ||
expect_equal(p1$data, p2$data) | ||
expect_gg(p3 <- ppc_loo_pit_ecdf(y, yrep, lw, plot_diff = TRUE)) | ||
expect_equal(p3$labels$y, "ECDF difference") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for future compatibility with ggplot2 we probably need to do what was done in https://github.com/stan-dev/bayesplot/pull/337/files#diff-d31e64955d39a8924be5d979cb21c5e96514987aeff9ca8cf2af067e98f3b156 with checking for the get_labs()
function and using it if found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I just noticed that I haven't done this for the tests for ppc_loo_pit_qq
either. If you want you can do it with this PR but I can also do it separately since it's not related to your PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also add the part for ppc_loo_pit_qq
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function works great. I made one small comment on the tests and then there's mentioning the function in the "Plot Descriptions" section of the doc, but otherwise I think this is ready without any other changes.
One strange thing is that two of the visual tests are failing for me locally but apparently not on Github Actions. But they're not your tests for the new function, they're ppc-loo-pit-overlay-default.svg
and ppc-loo-pit-qq-default.svg
. Does everything pass for you locally?
For me, all tests are passing. I have now added the forward compatibility for the tests of |
Made an implementation of the
ppc_pit_ecdf()
for LOO-PITs. This is mostly a convenience function, as one could already pass LOO-PITs to theppc_pit_ecdf
in itspit
argument. Now works directly with for examplebrms::pp_check(brms_fit, "loo_pit_ecdf")
I have two questions:
prob
argument.ppc_loo_pit_intervals
already imports theargs-prob-prob_outer
template, which has a different doc string forprob
. This template is used outside the ppc_loo functions, so I don´t think adding text specific to this new function there is the best solution. How should this be handled?ppc_loo_pit_ecdf
have a slightly different signature toppc_pit_ecdf
. Namely, instead ofK
, this new function uses a more informativeeval_points
, and instead of the booleaninterpolate_adj
, now I haveinterval_method = c("interpolate", "optimize")
. Should I hold on to this change and have the functions share their signature? I think the new one is more clear andppc_pit_ecdf
should also move towards that eventually.