How to add_values in MultiTrace for multi-dimensional values

Let’s say I have a multi-dimensional random variable b which are the slopes of a hiearchical linear regression. Each store have it’s own slope.

b = pm.Normal('b', mu=mu_b, sd=sigma_b, shape=(len(uniqueStores), X.shape[1]))

Using pm.traceplot, the plot for variable b will contain both predictors I am using. I would want to be able to visualize both separately in the traceplot.

trace_binomial[‘b’].shape returns (10000, 589, 2).

So I thought let’s add this to the trace with add_values:

trace_binomial.add_values({ 'Shift1Score': trace_binomial['b'][:, :, 0] }) trace_binomial.add_values({ 'Shift2Score': trace_binomial['b'][:, :, 1] })

trace_binomial[‘b’][:, :, 0].shape returns (10000, 589) which is the same thing as trace_binomial[‘intercept’] which is another hierarchical variable with the same # of group.

Like we can see in this image, my intercept is fine it plots it for each store, but for Shift1Score and Shift2Score there’s only one.

If I check trace_binomial[‘Shift1Score’].shape, it returns (5890000,). The array was forced to one dimension. What should I do to split my multi-dimensional variables in the trace?

Thank you!

There are some corner cases .add_values doesnt handles really well, try reshaping the shape into (10000, 589, 1) or (10000, 1, 589).