greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
518 stars 63 forks source link

Tidyverse/tidymodels compatibility #257

Open eteppo opened 5 years ago

eteppo commented 5 years ago

Hey! Thanks for the awesome package.

A feature request: could the mcmc, calculate, etc. optionally return data as tidy data.frames? This particular problem could be fixed pretty easily in the broom package too, though. It would just make custom visualization and so on easier in the tidyverse.

goldingn commented 5 years ago

Yeah, supporting tidy analysis would be great.

The output is a coda mcmc.list object, which is the de facto standard for storing mcmc output in R. I'd be reluctant to have more arguments to those functions, and summarising/plotting/doing things with mcmc outputs is beyond the scope of the package.

I'd rather there were a function in another package that would transform the mcmc.list output to something tidy. And I think tidybayes::tidy_draws() does that. So you should be able to do something like:

draws_coda <- mcmc(m) 
draws_tidy <- tidy_draws(draws_coda)
draws_tidy %>% tidy_things

Does that do what you are after?

It would be great to have a worked example of a full tidy analysis on the greta website, in case you're interested in contributing to something like that!

eteppo commented 5 years ago

Thanks for the fast reply.

Oh boy I totally missed that. I'll try to write a decent demo, it seems like tidybayes does the trick.