Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #419 +/- ##
=======================================
Coverage 98.66% 98.67%
=======================================
Files 35 35
Lines 5864 5904 +40
=======================================
+ Hits 5786 5826 +40
Misses 78 78 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Fantastic, thank you! I will doubtlessly have a use case for this in the next two weeks, and I will report if there's any issues. |
|
@behramulukir, sorry for the basic question, but how do I get to the function? I don't see it when I install the latest development version of bayesplot. |
|
Did you install the correct branch @mhollanders? As the changes are not merged to the master branch yet, you should install the branch I am working on. You can do it with |
|
Thank you, and pardon for my ignorance. It works great! |
|
No worries! I'm glad that you liked it |
|
Thanks @behramulukir and thanks @mhollanders for testing it out!
Does |
Among the existing PPC count plots, I think You can also check Visualizing Count Data Regressions Using Rootograms paper by Christian Kleiber and Achim Zeileis. The paper contains an example case where "a well-known data set from ethology, for which excess zeros and, more generally, overdispersion require treatment". If you find a solution that you think is worth implementing in bayesplot, please let me know! I would be interested in implementing it (unless you don't want to do it yourself, of course) |
|
I would highly recommend using Teemu's discrete rootogram. Using square scaling on both x and y axis improves readability in case of high proportions and counts, and discrete nature of the data and model is more emphasized. Also for zero-inflation part you should use binary target calibration plots as illustrated, for example, in Nabiximols case study |
|
Thanks! The rootograms in bayesplot are those rootograms, right? |
|
Yes, |
|
@behramulukir I had a chance to come back to this and I have two different ideas for handling the
Then inside the plotting function do something like this: and then use Then later:
One issue with this approach is we can't control the style of the interior axes, they just follow the general theme:
|
|
Thank you so much, @jgabry! I was also thinking about this and wasn't able to come up with anything new. It's great that you had fresh ideas. I think your first idea is similar to what I proposed in the previous message, which didn't fully convince me.
I personally prefer to have a gap between the dots and the x-axis line, and I felt like removing it led to worse results aesthetically and felt rather cluttered. It also broke the consistency of the graphs by having an unignorable visual difference between the grouped and non-grouped versions of the same plot. However, I quite liked the second idea. I wasn't aware of the possibility of drawing interior axes natively, and I liked it. I think it looks nice in the image you shared. Compared to the interior axes of other grouped plots, it seems like the only difference is the existence of tick marks in the axis lines. I think that's a smaller difference than the gap between dots and the x-axis line, and the one which I would prefer. What's your opinion, though? Do you have a preference between the two options? |
I believe it would look quite confusing without the little hack you suggested. However, since using that hack would solve the issue, I am positive about this workaround. That is especially if you feel like it wouldn't result in undesired consequences in edge cases.
To be honest, I am more positive about this solution. The main question I have is what changes do we apply to the style of the added axes compared to the general theme?
force_axes_in_facets <- function() {
thm <- bayesplot_theme_get()
annotate(
"segment",
x = c(-Inf, -Inf), xend = c(Inf,-Inf),
y = c(-Inf,-Inf), yend = c(-Inf, Inf),
color = thm$axis.line$colour %||% thm$line$colour %||% "black",
linewidth = thm$axis.line$linewidth %||% thm$line$linewidth %||% 0.5
)
}Looking at the code above, it seems like the |
You're right, but when you look at the plots of the two options I put above the axes look different. The interior axis in option 1 is thinner than the main axis. I'm not entirely sure why, but this is what always happens with the interior axes when using the default bayesplot theme (maybe other themes too) with If we go with option 2 then the new interior axes have tick marks, which is inconsistent with all of the other plots that do use So I think if we accept that the interior axes for the facets will look a little different for this plot than the other plots then option 2 is preferable. |
Yes, and that's why I was confused. Looking at the code, it seemed like there shouldn't be any difference, but it's visible that there is.
Personally, I am fine with this as the difference is rather small, and it may be possible in future to tackle this inconsistency. However, if you feel like the consistency here is critical, I think that's a fair argument. In that case, I am also okay with going with the little hack you suggested 2 comments ago. |
|
I’m ok with the small inconsistency too. I think it’s probably better not to use the hacky solution I came up with. |
|
Cool! I just increased the ggplot version to 3.5.0+ and added your solution for |











This PR adds
ppc_rootogram_groupedfunction requested at #377. If you have any feedback, I am happy to hear @mhollanders.ppc_rootogram_groupedsimply creates multiple facets (plots) of the rootogram based on the grouping user passes to the function as an argument.Something to note here is that in
ppc_bars_grouped,force_axes_in_facetsfunction is used to make sure all facets have axes. This was resulting in errors when used withppc_rootogram_grouped(style="discrete")since-Infresults inNaNwhen used withscale_y_sqrt(). It was still used in other rootogram styles, but so far, I hadn't managed to get it working for discrete style. I'll mark this PR as ready once I find a solution to that.Tasks:
discretestyleExamples