-
-
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
Add convergence methods for draws objects #278
Comments
Perhaps, we can actually make method for draws objects that automatically compute these arguments for each variable. The default would continue to work as now but would no longer be used for draws objects. |
Making a sensible method for draws would indeed be a better option. |
While working to add these methods, I thought a sensible option would be for new convergence methods such as I'm not sure what the best approach would be to get around this, but it seems that |
You could try to use summarize_draws but have to check how much overhead this function creates if your sole purpose is to compute a single diagnostic (say, rhat) per variable. |
Good point. However, even if new |
I see your point. @mjskay do you have an idea by any chance how to deal with this case? |
Hmmm... What if summarise_draws passed a single-variable rvar down to convergence functions instead of a draws_array? |
Perhaps. It would have to be tried out, I think. |
I'll try it out and make a PR if it seems to work |
Thank you for trying it out. If it works, before you spend time on a PR, we perhaps need to think about if this has other consequences, we currently do not see. |
The suggestion of passing rvars to the summary functions seems to work, especially as there are already |
Ah yeah. I think this kind of relates to other questions about modifying summarise_draws to support things like weighted draws. See this comment: #273 (comment) That is, if we're going to change the contract that summarise_draws has with summary functions, we should probably do it in a way that also allows us to solve the issues mentioned in the comment above. Otherwise we'll just have to do it again later. Alternatively, summarise_draws could be the "simple" (possibly even "legacy") summary function, with few expectations on the implementation of summary functions (basically: accepts an array?) and we could create a new summary function that solves the above issues without breaking existing code. |
Another solution might be to check for an rvar implementation on the summary function generic and pass that format if present, and otherwise use an array. That way rvar support is opt-in. Actually, this approach (essentially the summary function "declaring" its input format via a generic function implementation) could be used in the future to solve the other issues without making a new summarise_draws function. e.g. if rvar gets support for carrying weights around (which it really should), that would give us a way for summary functions to declare that they accept weights. |
I like this suggestion. When I get some more time for this I'll try it out |
Thanks! if it helps, we had to do something similar in Line 51 in e23467b
|
I've played around with detecting and using rvar methods here. It seems to work ok (need to fix the issue of functions that return a named vector like quantile2 losing names). It is limited to detecting methods from functions and strings (not formula syntax) but that's probably ok. For example in |
Yeah, good point... That could lead to counterintuitive behavior for users (and hard to track down bugs) if they start with a summary function then add arguments to it by changing to a formula or anonymous function. Not sure how I feel about that... |
Yes, this inconsistency could be an issue, e.g. if weights are suddenly not taken into account because of a change in syntax. Perhaps this change would really need to make rvar methods the default (if they exist) and pass array as fallback, maybe with a warning message that weights (or other attributes) are not necessarily considered. I suppose such a change would make sense only after rvars have weighting functionality, to justify a change in defaults for added functionality. But this discussion is now probably more related to issue #184. I currently don't see an easy fix for adding |
Yeah good point. This lends some priority to #184 then. I can take a stab at that when I next have time... |
Currently the diagnostic functions
rhat
,ess_tail
andess_bulk
are intended to be used on a single variable matrix or rvar, e.g. as part ofsummarise_draws
. However, they can be applied (incorrectly) to adraws
object (all work ondraws_array
, some work ondraws_df
too), and then return a single numeric value which is not meaningful.In contrast
rstar
takes a multivariatedraws
object as input and returns an interpretable value. Asrhat
andrstar
are somewhat similar in interpretation, the different expected inputs could be confusing.Although it is specified in the documentation that these functions expect certain input, maybe it is worthwhile doing some type checking for these functions and returning a warning / error when used incorrectly (especially when used on a
draws
object) and pointing tosummarise_draws
.Example:
The text was updated successfully, but these errors were encountered: