Hi,

I’m new to PyMC3 and currently working on a multivariate-multinomial logistic regression. I came across the iris data set problem and using it as a template. I have the following questions

- I ran into convergence problems when I specified the shape for the alpha and beta (The rhat statistic is larger than 1.4 for some parameters. The sampler did not converge.). Does PyMC3 determine the shapes of the alpha and beta internally based on the shape of data in x?
- If I were to use different sampling distributions (like beta_1, beta_2, beta_3 and beta_4) for each of the four features in my data, how do I specify the linear equation in mu?
- Can anyone please share a snippet of code for performing posterior predictions? Basically I would want to specify values to the four features and get a probabilities of outcome for the three classes

Here’s my code. Any help is appreciated and thanks for your time

data = pd.read_csv(‘data.csv’)

data[‘TYPE’]= label_encoder.fit_transform(data[‘TYPE’])

y_obs = data[‘TYPE’].values

x_n = data.columns[:-1]

x = data[x_n].values

ndata= x.shape[0]

nparam = x.shape[1]

nclass = len(data[‘TYPE’].unique())

with pm.Model() as hazmat_model:

alfa = pm.Normal(‘alfa’, mu=0, sd=10, shape=nclass)

beta = pm.Normal(‘beta’, mu=0, sd=100, shape=(nparam,nclass))

alfa = pm.Normal(‘alfa’, mu=0, sd=10)

beta = pm.Normal(‘beta’, mu=0, sd=100)

mu = tt.dot(x,beta) + alfa

p = tt.nnet.softmax(mu)

yl = pm.Categorical(‘y_obs’, p=p, observed=y_obs)

trace = pm.sample(niter, step = pm.Metropolis())

pm.traceplot(trace)