I have a large function of several random variables (ep1,ep2,d,s1,l1,s2,l2), which produces as an output a vector like,

def toFit(ep1,ep2,d,s1,l1,s2,l2)

…

a lot of code

…

return np.asarray([s0s[0], s0s[1], s0s[2], emi])

Then I implement it in the PyMC3 framework,

def f(ep1 = ep1, ep2 = ep2, d = d, s1 = s1, l1 = l1,s2 = s2, l2 = l2):

return toFit(ep1,ep2,d,s1,l1,s2,l2)

This function works properly like this,

f(ep1 = 2, ep2 = 4, d = 0.025, s1 = 0.002, l1 = 0.02,s2 = 0.002, l2 = 0.02)

returning an array([-14.25180297, -1.17028161, -2.21212258, 0.96023043]) as output.

But when I try to define the Deterministic function as,

with model:

function_pm = pm.Deterministic(‘s0f’, f())

I get this error,

ValueError Traceback (most recent call last)

in

1 with model:

----> 2 function_pm = pm.Deterministic(‘s0f’, f())

~\miniconda3\envs\bayes\lib\site-packages\pymc3\model.py in Deterministic(name, var, model)

1595 “”"

1596 model = modelcontext(model)

→ 1597 var = var.copy(model.name_for(name))

1598 model.deterministics.append(var)

1599 model.add_random_variable(var)

ValueError: order must be one of ‘C’, ‘F’, ‘A’, or ‘K’ (got ‘s0f’)

There is clearly something wrong, since it is assuming that the ValueOrder is the function name.

The funny thing is that if I just return the last element (‘emi’) or the vector ‘s0s’ there is no error. So, the error is in the stacking of s0s and emi. I tried concatenate, hstack, stack and append from numpy, and I also tried some theano equivalents. Nothing seem to work.