MCMC algorithm standard output datatype (MCMCChains or others?)

I’ve got an MCMC algorithm I want to do some research on. It’d be great if I could hand my functions some model function, and get back a data type that fits well into the ecosystem. Since I haven’t had the opportunity to use Julia in one of my real-world Bayesian data analysis projects I’m hoping the community here can tell me what is the “standard” datatype for output from a MCMC sampler? Is it the MCMCChains stuff, or is that just Turing related, and other packages use other things? What kind of object should my sampler return to give the most useful (compatible) output?

I don’t know if there’s a standard output as such. But it’s very easy to save your output as an MCMCChains chains. And you get automatic diagnostics and plotting recipes for free.

1 Like

MCMCChains is the Turing-ecosystem one. SampleChains is the Soss-ecosystem one, but not stable at this point afaik.

1 Like

This is exactly the kind of thing I was looking for. I guess I’ll start with this.

Will take a look at this as well. Thanks

If your code produces an array, you can easily convert it to an MCMCChain, and then get information and a plot:

chn = Chains(chain, ["β", "γ", "ρ₁", "σ₁", "ρ₂", "σ₂", "nss"])
plot(chn)
display(chn)

For making predictions etc. with the posterior, I made an interface package between Turing and MonteCarloMeasurements.jl

It’s most likely not working atm since it was a while ago I touched it, but it provides for a quite convenient way of working with the full inference result as if you were working with just a single sample.

With MCMCChains suppose I have output as an array, I’ve run the algorithm 3 or 4 separate times, I want to create an MCMCChains object with multiple parallel runs. How?

a = myrun(...)
b=myrun(...)
c=myrun(...)

ach=Chains(a,names) #easy

allchains = ??? ##what do I put here to make an MCMCChains object with a,b,c as separate parallel chains?

By dumb luck I came upon the “chainscat” function is this the usual way?