-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Plot method for class brmsprior #694
Comments
I like the idea and will think of a good implmentation. |
@mjskay how far is the prior plotting feature in tidybayes developed? Perhaps a separate brms implementation may not even be required. |
Hmm good question. Depends on how low-level you want to be writing code. E.g. if you take this model from the "tidy-brms" vignette in tidybayes: m = brm(response ~ (1|condition), data = ABC, control = list(adapt_delta = .99),
prior = c(
prior(normal(0, 1), class = Intercept),
prior(student_t(3, 0, 1), class = sd),
prior(student_t(3, 0, 1), class = sigma)
)) You can do something like this: m %>%
prior_summary() %>%
parse_dist(prior)
That function adds on the m %>%
prior_summary() %>%
parse_dist(prior) %>%
ggplot(aes(y = class, dist = .dist, args = .args)) +
stat_dist_halfeyeh() Of course, there's some issues here:
I think the approach above is reasonable for a lower-level approach like in tidybayes so that people could build custom plots of priors; the expectation would be that they might have their own desires/needs as far as how they want to set up the chart. But for a quick summary it might be valuable to have something that does more automatic mappings of class/coef/group/etc onto some aesthetics and such. Even combining them into single labels as a rough first step: m %>%
prior_summary() %>%
mutate(label = pmap_chr(select(., -prior), paste)) %>%
parse_dist(prior) %>%
ggplot(aes(y = label, dist = .dist, args = .args)) +
stat_dist_halfeyeh() Then you could do the small multiples version as well (not sure if unaligned axes are a good idea here, drop the m %>%
prior_summary() %>%
mutate(label = pmap_chr(select(., -prior), paste)) %>%
parse_dist(prior) %>%
ggplot(aes(y = 0, dist = .dist, args = .args)) +
stat_dist_halfeyeh() +
geom_text(aes(label = prior), x = 0, y = .97) +
facet_wrap(~ label, scales = "free_x") So I'd say it probably depends on the use case if you think there needs to be something more automatic. Currently I'd say tidybayes has most of the necessary primitives but expects a bit of work from the user. |
Nice! This is impressive! I don't think brms needs anything more than this on its own, especially since tidybayes does so much of the hard stuff already. For brms users of this tidybayes feature, please note that you can put any brmsprior %>%
parse_dist(prior) and it will work. That is, the model does not need to be fitted in order for priors to be plotted. |
Cool, will do! |
Thanks! Although I didnt intend to ask you to note that, more to note that
to users reading this thread. But of course you nothing that somewhere will
be even better :-)
Matthew Kay <notifications@github.com> schrieb am So., 2. Feb. 2020, 16:23:
… Cool, will do!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#694?email_source=notifications&email_token=ADCW2ACMF6GNH25IM4CHNFTRA3QPZA5CNFSM4H4IRPB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKRZKAA#issuecomment-581145856>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2ABV46FORBZ2C45IKN3RA3QPZANCNFSM4H4IRPBQ>
.
|
I'm closing this since this functionality will live in |
I think it is very useful, and educational, to plot prior distributions. To that end, a useful addition to
brms
could be to have aplot.brmsprior
method, so one can simply do e.g.:Or even multiple plots (or small multiples) for all priors:
If you'd be interested I could try to have a look at an implementation, although it may take me a couple of months to get around to it.
The text was updated successfully, but these errors were encountered: