Hierarchical Modeling Labels

Wow, this is exactly a use case for arviz. There’s an open PR to make this work automatically for you, but right now, I would first pip install arviz, and then (I’m guessing based on what you provided):

import arviz as az
import pymc3 as pm

with my_model:
    ...
    trace = pm.sample()

data = az.from_pymc3(trace=trace, 
                     coords={'departments': list_of_department_names}, 
                     dims={'intercept': ['departments']})

az.plot_trace(data, var_names='intercept')

1 Like