Easiest file format (or loading files with custom R code) to use custom MCMC chain with shinystan

I am interested in using shinystan and related visualization tools for MCMC chains generated from custom code (i.e., not from a standard MCMC DSL).

Given that shinystan seems to support multiple backends, I suspect this is possible. Are there any complete examples of how to do this? Is there a simple text-based file format that we could generate which would make this especially easy to do?

For example, if we had a CSV file such as:

iteration, chain, variable_1, variable_2
1, 1, 0.37, 0.28
2, 1, 0.55, 0.33
1, 2, 0.55, 0.282

Then is that enough for shinystan or Plotting for Bayesian Models • bayesplot to use? If so, are there examples of that?

Hi,
I think you would need to transform the CSV manually into an mcmc.list object or other format supported by ShinyStan - see http://mc-stan.org/shinystan/articles/shinystan-package.html (which should be relatively straightforward, as all the information you need is already in your CSV)

Best of luck
Martin

Thanks. Can you think of any publicly accessible code that is using that API?

Also, Is there something similar with bayesplot as well (or one of the other visualization packages)?

From Getting Started • shinystan

If you have an mcmc.list object called my_mcmc then you can use the as.shinystan function to convert my_mcmc into a shinystan object that can then be used with launch_shinystan :

my_sso <- launch_shinystan(as.shinystan(my_mcmc, model_name = "my_model"))

Or do you need something more?

Most (all?) bayesplot functions work with base R arrays/data frames, so not sure what API are you missing/expect… Plots for Markov chain Monte Carlo simulations — MCMC-overview • bayesplot