-
Notifications
You must be signed in to change notification settings - Fork 4
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
Constructor for SBC_results object #76
Comments
Iterating over the list of I am asking can we please carve it out into a separate function(s) and export this functionality to be able to construct the results without using the rest of the engine. This would have to be done if SBC plots would ever be spun off into a separate package (like SBCplots) or merged into the Your answer could be "write a custom backend for your sampler" (fmcmc in my case, but can be my own sampler tomorrow). It's a good argument and worth doing for stable MCMC engines. However, there's still an argument for using my own engine (say, in |
I agree that more modularization would be sensible and playing more nicely with target is definitely something we'd like to have. The good news is that I think that most of what you need is already implemented, although not very well documented. Regarding the plots, all the plotting functions (and some more) support at least
If you for some reason really need the
and get the statistics in the format used by SBC_results (you only need to additionally supply Finally, you can construct a minimal
Note that in both cases, I can use Some of the solutions are not ideal and potentially a bit fragile (the final code chunk relis on |
This is definitely very useful! Thank you.
The first item is quite urgent, while the second can very well wait until the next big release. |
I am happy to invest some energy into moving this forward, but I'd like to understand your use case better before delving into this. Are you interested only in producing the plots from computations done outside the package? Or is there something else you have in mind? Note that I cannot "just" decouple the logic - Also, if you just need the plots and not the extra baggage our package has, N_sims <- 500
true <- rnorm(N_sims)
fits <- matrix(rnorm(N_sims * 100, sd = 2), nrow = 100, ncol = N_sims)
bayesplot::ppc_pit_ecdf(true, fits, plot_diff = TRUE)
# Manually computing ranks, a bit ugly
SBC_ranks <- array(N_sims)
for(i in 1:N_sims) {
SBC_ranks[i] <- SBC::calculate_ranks_draws_matrix(
posterior::draws_matrix(x = true[i]),
posterior::draws_matrix(x = fits[,i]))
}
rank_df <- data.frame(sim_id = 1:N_sims,
variable = "x",
rank = SBC_ranks,
max_rank = 100)
SBC::plot_ecdf_diff(rank_df) Our implementation differs in minor aspects from the bayesplot one (most of it are minor tweaks/fixes that may at some point make it to bayesplot), so the plots will not always be identical, but the differences should not generally matter (e.g. the above code with |
SBC today is a combination of SBC engine and a plotting package, which do not have to be under the same umbrella if the interface is clearly defined. I want use the excellent rank plots (thank you @TeemuSailynoja!) without using SBC to run the calibration.
I would like to be able to construct a minimally acceptable
SBC_results
object fromposterior
objects (I prefer draws_arrays). The samples originate fromcoda
format, so they are fitted not with Stan, but with some other software. Therefore my objects might be missing some of the useful metrics like Rhat and ESS.I would ideally like to see something like
which will return a (lean) results object, which can be acceptable for plotting functions (e.g.
plot_rank_hist()
,plot_ecdf()
, etc).The text was updated successfully, but these errors were encountered: