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

ppc_stat for discrete test statistics? #330

Open
santikka opened this issue Oct 14, 2024 · 1 comment
Open

ppc_stat for discrete test statistics? #330

santikka opened this issue Oct 14, 2024 · 1 comment

Comments

@santikka
Copy link

It seems that ppc_stat always assumes that the test statistic defined by stat is continuous, and thus draws a histogram, which is fine but sometimes looks quite ugly, for example:

set.seed(0)
y <- rbinom(20, 1, 0.2)
yrep <- matrix(rbinom(2000, 1, prob = 0.4), 1000, 20, byrow = TRUE)
bayesplot::ppc_stat(y, yrep, function(x) sum(abs(diff(x))))
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2024-10-14 with reprex v2.1.1

Is there an option (or another function) to specify that the test statistic is discrete, so that ppc_stat would produce a barplot instead?

@jgabry
Copy link
Member

jgabry commented Oct 14, 2024

Yeah you're right that it would look nicer as a bar plot when the test statistic is discrete. There's not a way to tell ppc_stat to do that right now, but I think it's a good idea. If you or anyone else is interested in adding it I would be happy to review a pull request. Otherwise I can certainly do it myself when I have time, but I'm not sure when that will be at the moment.

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