have built an unpooled model in PyMC3:
with pm.Model() as unpooled:
# PRIORS
alpha = pm.Uniform('alpha',lower=-5,upper=5, shape=len(set(Y.values)))
beta = pm.Normal('beta',mu=0,sd=1, shape=len(set(Y.values)))
sigma = pm.Uniform('sigma',lower=0.01,upper=3)
# LIKLIHOOD
e = X['flavanoids'].values * beta[Y.values.astype(int)] + alpha[Y.values.astype(int)]
y = pm.Normal('y',mu=e, sd=sigma, observed=Y.values)
# SAMPLE AND PLOT TRACE
trace = pm.sample(2000)
I know that if the shape of beta
was 1, I could have gotten the max probability estimate using:
ppc = pm.fast_sample_posterior_predictive(trace, samples=1_0000, var_names=['beta'])
preds = ppc['beta'].mean(0)
but since the shape is more than 1, I should get more the 1 value for it. how can I extract that value?