-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support for Stan, Soss, and Gen #29
Comments
@ParadaCarleton (and @itsdfish) Carlos, I am wondering what you mean by this. I'm using it all the time now with Stan and it is very simple to generate the required input data for ParetoSmooth.jl. Unfortunately, in Stan you typically generate the required ParetoSmooth input data (I usually call it the Yes, for StatisticalRethinking I need to do a bit extra and will complete that work in v4 of StatisticalRethinking (and that is primarily an issue of presenting the results). It is possible to add an example to the tests but we discussed that a while ago and it would require building Stan's It is also possible to add a doc section with an example of how to use ParetoSmooth from StatisticalRethinkingJulia. |
@goedman, perhaps @ParadaCarleton wants something similar to R. It looks like R uses some sort of model object returned from Stan to compute loo. My guess is that is uses |
Thanks Chris. Currently the
So in a call such as It's very likely I can (and will) improve above formulation as I do further work on StatisticalRethinking v4. But that will be hidden from users. It's also tempting to add a loo_compare method passing in a vector of KeyedArray chain objects as in many cases that will be returned from previous calls to read_samples(). I do know Richard McElreath adds a generated quantities block to the Stan model when the log_lik matrix is needed for model comparison. In the latest Stan docs (for the new cmdstanR option) a listed goal is to prevent directly calling C++, just executables. And as you know in StanJulia I have always stayed away from the Just my $0.02. |
@goedman, I understand your reluctance to work with the C++ code. Even in the example with R, they use generated quantities as you noted. So there is a minor step of extracting the log likelihoods from the Stan output. That leads me to believe dealing with the C++ code would be more trouble than it is worth. Would you mind providing a link to code where you extract the log likelihoods from a Stan model and pass it to loo in Paretosmooth? That might allow us to determine whether there is any room for a convenience function. If not, we can use your example in the documentation as an example with Stan. |
Hi @itsdfish , In above method I do (for each model):
Above method is used here. |
Oh, thanks -- I didn't notice that. Makes sense. That being said, doesn't the StatisticalRethinking library use Stan? I believe it's possible to check whether your package breaks another package's tests using CI. @yebai mentioned something about testing whether changes in AdvancedHMC break Turing. Or perhaps Turing already runs tests comparing Turing and Stan, in which case we could maybe piggyback off of that? |
Something like this would actually be pretty much exactly what I need! I think with a bit of cleanup this would work -- we'd just need to fix the overly-strict typing. Apart from that I think we'd also need a method to perform LOO-CV on a single model, but that's about it. |
This is likely how it is going to end up in StatisticalRethinking v4 (provided StanSample v4 has been loaded):
I haven't worked out the details for StatisticalRethinking v4 when Turing is loaded. But that will mostly follow what Chris did. |
In StatisticalRethinking v4, with StanSample loaded, for LOO_CV I will use:
which typically is called as:
|
@goedman I just had a thought -- would you be willing to add that code to StanSample.jl with a couple tests, then? (And Requires.jl so that you don't have the dependency on ParetoSmooth.jl, I assume.) That way we can have out-of-the-box model comparison functionality in Stan. |
Hi Carlos (@ParadaCarleton), Apologies for the delay in answering. StanSample is a relative lightweight package on a lower level (it has no notion of comparing models). I would prefer to keep it that way. ParetoSmooth based model comparison really fits into (the very much simplified) StatisticalRethinking.jl v4.0. The simplifications come from dropping usage of @reexports ... and all graphics The code is included here and tested here in SR v4.0.3. As I mentioned before, for the SR course clips in StatisticalRethinkingStan I will follow the book and present the results in a different format and re-introduce some columns and fields into the SR's version ModelComparison object (likely more like the old LooCompare object), also to improve presentation in Pluto notebooks (e.g. the Pareto_k value warnings currently show up in the console). All graphics are now handled in StatisticalRethinkingPlots which does contain an option to plot the Pareto_k values. And in the future similarly in StatisticalRethinkingMakie. |
Currently, only Turing is supported; support for Stan, Soss, and Gen would be great.
The text was updated successfully, but these errors were encountered: