-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Adding generics of general Bayesian methods #39
Comments
Maybe this is the wrong place for this, but I wonder if part of putting those generics here might include some more standardization in their interfaces. At present there are some idiosyncrasies across brms and rstanarm that make the functions a bit harder to program against (I have to special-case stuff in As a very selfish wishlist item for me, thinking about things like |
@mjskay yeah I'd like to see more standardization in the interfaces too. the rstantools package (which includes lots of generics) was an initial attempt to get some of unification of method names but @paul-buerkner and I have also discussed other ways that we could share more between the packages. feedback on that is definitely welcome! |
@paul-buerkner I added |
Following on this issue from brms (paul-buerkner/brms#552), I think it would be nice to make sure these interfaces have enough standardization that we could add a marginalization interface within posterior that could cover these three cases identified by @paul-buerkner:
I think this might require being a bit more prescriptive about arguments to functions like pp_expect and/or providing functions that can inspect a model (e.g. get info about predictors, random effects, etc). For example, I'd love to think about what a better alternative to the somewhat cryptic |
Following this thread from the brms marginalizing thread, i think this makes a lot of sense, since Integrating out/over a distribution is a generic idea. I think the tricky part is extracting standardize information about the distribution family used for the random effect For 90% of use cases, it'll be a normal distribution centered at 0 I think the flexibility of brms is interesting since users might experiment with non-normal distributions (but this is rare, as the cited McCulloch paper argues that it's not that useful) Nevertheless, if you wanted to fully support 'integrating out' non normal distributions, i think brms / stan / your favorite bayes software, would need to tell what type of distribution was used for the random effect, to be used as
I think you'll need to ask the bayes software to meet you half way and do the heavy lifting of returning simulations from the specified re distribution (for monte carlo integration) or alternatively give you enough information about the distribution to generate a templated r-side wrapper function to write a closure function to be integrated, used in variants of https://stat.ethz.ch/R-manual/R-devel/library/stats/html/integrate.html |
Thinking more about the generics above, I think there is one conceptual issue, which we need to resolve related to #8 and #13. The conceptual problem arises because we have thought of #13 as being resolved as part of the rv-like interface in #8. However, I am not sure if we should enforce usage of Essentially, I think we have two options:
@mjskay I lnow you won't have time to work on the |
This is a really tough call! I think my instinct is to have fewer redundant ways of doing things if at all possible (lots of friction happens from a user's perspective when their data needs to be in one format and they have it in another, especially when the formats are superficially similar). FWIW my long-term goal for the corresponding functions in tidybayes is that they be built on the generics in posterior and give long-format tables with rvars in them instead of (or perhaps as alternative to) the current long-format data frames, and then to modify the existing geoms and stats in tidybayes to accept rvars directly. I suspect this will end up being a particularly powerful and flexible approach for building custom visualizations. The counter-argument to this is that if someone needs to do custom operations on the underlying array and then take advantage of our summary functions they would have to wrap/unwrap that data structure using |
Your points make a lot of sense. I guess what I am worried about is that their are a lot of potential custom operations which only work on the underlying array directly. For example, if I want to use a By having common methods such as |
Ah yeah, that makes sense. Some of those functions are already covered, including everything in the Math generic, which includes So perhaps it is a question of if the Math generic (perhaps plus some other reasonable set of functions we can wrap) provides enough coverage for the majority of users? I could see the answer being no... |
Having every method in the math generic page is quite good already. I think we need to see There are more decisions to be made with regard to the generics, for example, whether to add more arguments to the generic to enfore their consistent use, and what defaults the should have (e.g., the Depending on when we need to first release posterior, the generics, |
We discussed at some point, that we want to have a common place where a lot of the generics should life that packages such as rstanarm, brms, etc. use. Right now, a lot of them are in rstantools but I don't think this is a good place for them as the methods are not only relevant from rstan based packages. Some methods are better suited for special packages and as such should life there, for instance, in bayesplot for all plotting related generics and in loo for all cross-validation related procedures.
Please amend this initial comment to add more methods that we may want to put into posterior.
posterior_predict
compute predictions and return an arrary of drawsposterior_linpred
compute linear predictor values and return an arrary of drawsposterior_epred
compute means of the posterior predictive distribution and return an array of draws (see Rename the 'fitted' method paul-buerkner/brms#644)predictive_error
computed differences between observed and predicted responses and return an array of drawsposterior_interval
basically summarise_draws with just two quantilespredictive_interval
basically summarise_draws with just two quantiles after callingposterior_predict
The text was updated successfully, but these errors were encountered: