How to plot credible intervals for MCMCChains?

Is there a way to get plots of intervals given mysample::MCMCChains.Chains?

I’m looking for something like the following from stan:

1 Like

This type of plot is a density plot over your parameter samples. If you want to do something similar, you can start with something like this:

stack_chn = select(DataFrames.stack(DataFrame(chain)), [:your, :parameters, :go, :here])

plot(stack_chn, ygroup=:variable, x=:value,
    Geom.subplot_grid(Geom.density)
)

These don’t have the fun interval highlights but you can visualize your favorite CI by finding the appropriate rank in your (sorted) samples and using Geom.vline (ie 10% = get the 10th percentile parameter and plot a vline there).

Easier but you won’t have control, you can use the traceplot recipe that’s built into turing/mcmcchains:

4 Likes

I use Econometrics/npdensity.jl at master · mcreel/Econometrics · GitHub which gives you a plot like what you see in Econometrics/posterior.png at master · mcreel/Econometrics · GitHub

3 Likes

thanks @BradGroff, I’ve been trying to figure out how to tweak these MCMCChains plots for a while now!