HHMM with GPs for state transitions


I am trying to build an hierarchical model based on a hidden Markov chain.
First of all, I pray excuses as I am a noob, and this may be a very stupid question.

The part of the model I concern about is the following:

s_i: Hidden States - Where s_{i+1} ~ GP(s_i)
y_i: Observations ~ N(mu=s_i,std=fixed_val)

The GP has been trained previously with the data. And there I want it to predict/sample around the value given from the previous sample.

Something like this:

with pm.Model() as model:    
   s = np.empty(num_nodes, dtype=object)
   s[0] = pm.Normal('s_0', mu=0, sd=.1)
   for i in range(1,num_nodes):
        s[i] = gp.conditional('s_%d'%i, s[i-1], predict_noise=True) # This should be like a Normal based on the mean and std predicted by the gp. 

Unfortunately I am not able to make this run.

Any ideas how this should be implemented?

Here I really care about speed, so I looking forward to run NUTS on the whole problem.

Thanks in advance!

Instead of creating an empty array, try creating an empty list:

   s = []
   s.append(pm.Normal('s_0', mu=0, sd=.1))

But do be aware that HHMM with GP is a pretty difficult problem, so you would need to power through some frustration at some point…