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
Deprecate ggplot functions in future rstan? #1051
Comments
Yes |
Agreed. We can remove them from both v2.26 & the experimental branch. Though, not sure if any dependency is using them right now. This won't affect the release of |
I think there may be a few dependencies using them, but not many. How about just a deprecation warning at first and then removing them entirely at some point in the future? If that sounds good I can make a PR against the experimental branch adding the deprecation warnings. |
@andrjohns Can you work on this for the experimental branch? I'll backport to v2.26 and run reverse dependency checks. |
That works, but we could also depend on
Alternatively, we could remove them completely and contact the maintainers to switch to |
I vote for removing them completely, if the number of dependencies is small. We can easily fix it for them. |
That's true, although I think there are a lot of users who got accustomed to using the plotting functions in RStan and giving them one release with a message pointing them to bayesplot would be nice (instead of them just getting an error from R that the function doesn't exist). @bgoodri and @andrjohns what do you guys think? |
If it's going to require fixing other package dependencies, I'd prefer to wait until 2.31 is on CRAN before removing. At the moment the submission path for 2.31 is relatively clear, with all dependencies having patches either submitted or released to CRAN. I'd rather not add an additional source of delay/breakage on that side of things |
@andrjohns That makes sense. Are you ok if I add deprecation warnings? That way everything continues to work (no breaking dependencies) but we warn them of the change coming in the future? |
I'm on board with deprecation warnings |
I can make a PR. Is the right place to do that the |
Yes. That's the target for v2.32 after releasing |
It occurs to me that the one thing we lose by removing these functions from rstan is the ability to automatically unconstrain parameters if the user wants (I think this is why we haven't already deprecated them, if I remember previous discussion accurately). bayesplot can't unconstrain the parameters automatically, so the user would have to unconstrain and then pass to bayesplot if they want plots of unconstrained parameters. Are we ok with that or is that sufficient reason to keep plots in rstan itself? |
Could the |
The idea being not to remove existing functionality, in case it's needed in a workflow somewhere |
Maybe the first option. I think if we can keep bayesplot as separate as possible and not call rstan::unconstrain_pars inside bayesplot that would be ideal. This is only really an issue for complicated transformations. For a standard deviation, for example, it's easy to get bayesplot to do the transformation: bayesplot::mcmc_hist(x, transformations = list(sigma = "log")) but you have to know the function to specify. For more complicated transformations it would be tough for the user to do this without relying on unconstrain_pars. So yeah maybe we should do it in rstan and then call bayesplot instead of deprecating the rstan functions. I'll look into that. |
@andrjohns What's the best way for me to build the experimental branch locally? Seems like I need StanHeaders 2.31.0, right? |
I either just |
(and yeah I normally use StanHeaders 2.31 with it as well) |
Ok thanks. I’ll give that a try later (got to hop on a few zoom calls
first)
…On Thu, Mar 16, 2023 at 1:00 PM Andrew Johnson ***@***.***> wrote:
(and yeah I normally use StanHeaders 2.31 with it as well)
—
Reply to this email directly, view it on GitHub
<#1051 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3PQQ5AMRVBP3JPKCQELBDW4NPNPANCNFSM6AAAAAAV5RFEJQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@andrjohns I successfully built the experimental branch, and it's a good thing I tried it because I think the existing code for plotting unconstrained parameters breaks, potentially due to changes in the generated C++ code in newer versions of Stan. In the past this (admittedly hacky) helper function was able to get the names of the variables declared in the parameters block: rstan/rstan/rstan/R/stan_plot_helpers.R Lines 198 to 204 in d9a7521
(I think it would get data + parameters and then drop the data by intersecting with But now it seems that grepping for Do you know of a way to get the names of variables just in the parameters block that I could use instead of this? |
Ooh good question. Wouldn't it be easier to grep the Stan code in the stanfit object for the entries of the |
I think there was some reason we didn’t do that before but I can’t remember
and now I can’t think of a good reason not to do that, so maybe I’ll give
that a try.
…On Thu, Mar 16, 2023 at 3:15 PM Andrew Johnson ***@***.***> wrote:
Ooh good question. Wouldn't it be easier to grep the Stan code in the
stanfit object for the entries of the parameters block? Then it wouldn't
be dependent on the C++
—
Reply to this email directly, view it on GitHub
<#1051 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3PQQ5UBOAHJKOQEPT6QPDW4N7IPANCNFSM6AAAAAAV5RFEJQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Is there a way to run stanc3's auto formatter (I don't see it as an option to |
The auto-formatting option generates Stan code while |
Thanks! I'll try |
The easiest way is to set the option: options(stanc.auto_format = TRUE) We could enable it by default (which would help |
But actually I guess auto formatting doesn't remove user code comments (so the word "parameters" can appear anywhere in the Stan file even after auto formatting). I need a way to figure out which variables are declared in the parameters block (as opposed to transformed parameters and generated quantities). @andrjohns suggested grepping the Stan code itself but that seems potentially error prone if the word "parameters" can appear anywhere in user comments. |
You could use a C++ preprocessor to remove the comments; something like |
For Stan code, could we request this in |
Is there a way to use stanc3's existing |
Sure. We can pass any argument to model_info <- stanc_ctx$call("stanc", model_cppname, model_code, as.array("info"))
|
Awesome, thanks. That works. I can get the following now:
|
Great! I suggest that you wrap it with
|
Good idea |
Also, if the info is in a standard format ( |
|
No. I'd create a simple helper function to convert the JSON info, if it's safe to do so. Otherwise, adding the dependency could be helpful depending on the value of the ability to automatically unconstraint the parameters. |
We could also use the info in other places, replacing a lot of |
I'll see how much of a pain it is to parse the JSON without adding a dependency, but yeah it could be worth adding the dependency if we can use this info elsewhere. |
the info should be in standards-compliant JSON. Do ping me if there is anything you wish |
Thanks @WardBrian! That would be great. We could rely on |
After playing around with all of this for a while, I think the fundamental issue here is that Basically what we need is something like unconstrain_draws(stanfit, pars = "tau") which returns all of the posterior draws for tau but unconstrained. If we had this then we wouldn't need to maintain any plotting code in RStan. The user could just do something like this stanfit %>%
unconstrain_draws(pars = "tau") %>%
bayesplot::mcmc_trace() @andrjohns You know more about unconstrain_pars than I do (or I assume so since you figured it out for CmdStanR and I haven't spent much time with it). How hard do you think this would be to do for RStan? |
That's a good-looking syntax! Yeah it wouldn't be too hard to implement, the main thing is making a "sane" structure for the return (I'm not overly happy with how I'll be getting back to |
Cool, sounds good!
…On Mon, Mar 20, 2023 at 12:41 PM Andrew Johnson ***@***.***> wrote:
That's a good-looking syntax!
Yeah it wouldn't be too hard to implement, the main thing is making a
"sane" structure for the return (I'm not overly happy with how cmdstanr
returns them now - a list of vectors per chain). A discussion I had with
@n-kall <https://github.com/n-kall> a while back was to implement the structured
format for unconstrained pars
<stan-dev/cmdstanr#730> in the draws_* format,
so that we can easily handle multiple chains in a syntax/structure
consistent with how users interact with the constrained draws.
I'll be getting back to cmdstanr development later this week (now that
there's not much more do for rstan for a bit), so I can implement that in
cmdstanr and then port the approach over to rstan. It will be easier to
do in cmdstanr first since the plumbing for unconstraining everything is
already in place, it's just a structure/format change
—
Reply to this email directly, view it on GitHub
<#1051 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3PQQYW35SV67GDMEX2ENDW5CQHFANCNFSM6AAAAAAV5RFEJQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This may be an inappropriate place to ask, but since all the major stakeholders seem to be participating here: Is there a good place to follow along with the general status of RStan 2.26, CRAN updates, etc? |
For 2.26 you can follow #1034, that's tracking the progress of the downstream packages and their patching, as well as the submission decision For 2.31+ you can follow #1046 |
The next step is to release |
Does that mean it could be a matter of days (rather than weeks, months, etc.) for RStan 2.26? Or would you expect it to still be further off |
@bgoodri how have CRAN normally been for |
There's a reason there hasn't been a new RStan release in years. I believe the choke point is lack of dependency management in CRAN. Without that, Stan's policy of not maintaining low-level backward compatibility of internals has made it impossible to get a new release out that is compatible with old and new versions of Stan, which would be needed to release without pinning dependency versions. |
We've actually got all of that in place for 2.26 and then 2.31 (sans ~10-15 packages yet to merge and release patches I've submitted), it's just a matter of the actual submission now and whether that's enough notice to maintainers for CRAN to accept breaking their packages |
This is a good question for @bgoodri :) He could submit it now and provide notes to justify the failed dependencies.
Originally, dozens of packages failed until we implemented Stan/Math patches for backward compatibility and notified the package maintainers about the required changes (and even submitted PRs to fix them) months or years in advance. CRAN is ok with the notices alone, and we've already fixed the majority of dependencies. Only two packages fail now with segfault due to the incompatibility of the new |
@bgoodri @andrjohns @hsbadr Should we deprecate all the ggplot functions in rstan? Maybe in conjunction with the release of 2.26 or another future version? The ggplot functions in rstan were added before bayesplot existed and I'm not sure if there's any reason to keep supporting both. We could deprecate and point users to bayesplot. Thoughts?
The text was updated successfully, but these errors were encountered: