Hi everyone, I am trying to build a hierarchical regression model, but the observed data are discrete and I am struggling to figure out what distribution should I use on the observed data.
I am trying with Multinomial, but I am not sure to fully understand how this should work.
In the image, I have used a normal dist for the outputs, but I guess it is a really weak fitting.
This is the current model I am trying, but it gives the error below.
with pm.Model():
a_0 = pm.LogNormal('a_0', mu=pm.math.log(init_nu), sigma=0.1, shape = (X.shape[1],))
w_0 = pm.Dirichlet('w_0', a=a_0, shape = (X.shape[1],))
w_k_ = []
for i in range(n_categories):
w_k_.append(pm.Dirichlet(f'w_{i+1}',
a=w_0,
))
w_k = tt.stack(w_k_)
act_out = tt.batched_tensordot(pm.math.log(w_k[c].reshape((c.shape[0], X.shape[1], ))), #c is the categories' index array
X, axes = [[1],[1]] )
out_det = pm.Deterministic("oup_det", act_out)
out = pm.Multinomial( "out",
value=act_out,
n=y.sum(),
p=out_det,
observed=ann_output)
I am having this error at the moment, but I think there is more that I am not understanding
SamplingError: Initial evaluation of model at starting point failed!
Starting values:
{'a_0_log__': array([-1.28775636, -0.93606029, -1.81451977, -2.47462444, -3.41155315,
-2.81283299]), 'w_0_simplex__': array([ 0.81813326, 0.15554985, 0.66529345, 0.88937281, -0.90418284]), 'w_1_simplex__': array([-4.5531904 , 2.05080364, -1.98760618, -5.38623783, 2.24851364]), 'w_2_simplex__': array([ 2.95381451, -1.25284196, 1.98640321, 1.65540121, 1.71594464]), 'w_3_simplex__': array([1.20801965, 4.39257921, 0.51940015, 3.1436691 , 0.89849361])}
Initial evaluation results:
{'a_0': 5.91, 'w_0': -12.37, 'w_1': -20.89, 'w_2': -12.73, 'w_3': -13.53, 'out': -inf}
Thanks a lot in advance, any type of help would be very useful!