mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
712 stars 59 forks source link

Look into supporting INLA #223

Open mjskay opened 4 years ago

mjskay commented 4 years ago

From a cursory glance at the R-INLA API the distribution functions for posterior marginals seem like one place to start: https://becarioprecario.bitbucket.io/inla-gitbook/ch-INLA.html#sec:marginals

Combining these with the new stat_dist_... family seems a logical step. Could also think about point_interval. Not sure what the equivalent of fitted_draws() and predicted_draws() would be in this case.

Would be happy if someone more familiar with INLA was interested in helping with this or had thoughts on what would be useful.

mjskay commented 4 years ago

Also look at inla.posterior.sample()

tmeeha commented 4 years ago

Hi Matthew. I use INLA a lot and would be happy to help with this. I am not a great package developer but can write R functions and know INLA posterior sampling well. Let me know if I can help. Best, Tim

mjskay commented 4 years ago

I'd love that! I believe @dpsimpson had mentioned looking into it at some point but my guess is he had better things to do :)

There's a couple of natural directions to go I think...

  1. Implementing tidy_draws for INLA so that spread_draws / gather_draws / etc work
  2. Implementing fitted_draws and/or predicted_draws
  3. Implementing something new for outputting analytical distributions. Something like a tidy_dist, fitted_dist, and/or predicted_dist, which would return distribution vectors that build off of the {distributional} package that could be visualized by the stat_dist_ geoms (which I just recently moved to ggdist). This is something I have had in the back of my mind for awhile but haven't built for any packages yet. If you're interested in that the relevant issue on ggdist to check out is here: https://github.com/mjskay/ggdist/issues/14
dpsimpson commented 4 years ago

Yes! I’ve been clobbered by other work. But I’m happy to chat with you if you want a sounding board / rubber duck / or general INLA stuff

On Wed, Jun 17, 2020 at 19:37 Matthew Kay notifications@github.com wrote:

I'd love that! I believe @dpsimpson https://github.com/dpsimpson had mentioned looking into it at some point but my guess is he had better things to do :)

There's a couple of natural directions to go I think...

  1. Implementing tidy_draws for INLA so that spread_draws / gather_draws / etc work
  2. Implementing fitted_draws and/or predicted_draws
  3. Implementing something new for outputting analytical distributions. Something like a tidy_dist, fitted_dist, and/or predicted_dist, which would return distribution vectors that build off of the {distributional} package that could be visualized by the statdist geoms (which I just recently moved to ggdist https://mjskay.github.io/ggdist/). This is something I have had in the back of my mind for awhile but haven't built for any packages yet. If you're interested in that the relevant issue on ggdist to check out is here: mjskay/ggdist#14 https://github.com/mjskay/ggdist/issues/14

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mjskay/tidybayes/issues/223#issuecomment-645681229, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRICBWSIHUTAGV4WIGT7G3RXFHTRANCNFSM4KN2OQ3A .

tmeeha commented 4 years ago

I have already written some clunky but functioning wrappers to inla.posterior.sample and can get the samples into an mcmc object. I am studying now how to work with mcmc objects in tidybayes right now. I have only used this with brm models in the past.


From: Matthew Kay notifications@github.com Sent: Wednesday, June 17, 2020 5:37 PM To: mjskay/tidybayes tidybayes@noreply.github.com Cc: Meehan, Tim Tim.Meehan@audubon.org; Comment comment@noreply.github.com Subject: Re: [mjskay/tidybayes] Look into supporting INLA (#223)

I'd love that! I believe @dpsimpsonhttps://github.com/dpsimpson had mentioned looking into it at some point but my guess is he had better things to do :)

There's a couple of natural directions to go I think...

  1. Implementing tidy_draws for INLA so that spread_draws / gather_draws / etc work
  2. Implementing fitted_draws and/or predicted_draws
  3. Implementing something new for outputting analytical distributions. Something like a tidy_dist, fitted_dist, and/or predicted_dist, which would return distribution vectors that build off of the {distributional} package that could be visualized by the statdist geoms (which I just recently moved to ggdisthttps://mjskay.github.io/ggdist/). This is something I have had in the back of my mind for awhile but haven't built for any packages yet. If you're interested in that the relevant issue on ggdist to check out is here: mjskay/ggdist#14https://github.com/mjskay/ggdist/issues/14

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/mjskay/tidybayes/issues/223#issuecomment-645681229, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACIZCKASUKN7DTXS24T4XQDRXFHTRANCNFSM4KN2OQ3A.

mjskay commented 4 years ago

Cool! Thanks both. @tmeeha if you hit a snag figuring out stuff on the tidybayes side let me know

becarioprecario commented 4 years ago

Hi,

I use ggplot for all the figures in my INLA book but I believe that the code is very ad-hoc. I do not have any general functions but I will happy to help and test any code on the examples.

Best,

Virgilio