Implementing stan model in pymc3

Hello,

I was wondering if anyone has experience translating Stan models into pymc3.

In particular, I am interested in translating this model into pymc3:

I have already included random effects etc in the model, but I was confused as to how to implement the Gaussian process prior on the time index, especially when the time index doesn’t match the index of the observations.

Would anyone be able to help with the Gaussian Process part?

Also, using the list indexing in Stan does not seem to cause computational slow-downs where as it does seem to cause slow-downs with pymc3 and theano. Is this anyone else’s experience or just mine?

Is it recommended to use list indexing in model construction with pymc3?

From my experience, list indexing is okay but instantiating many random variables within a for loop is not a good idea. Do you have some starter code or additional documentation to help make sense of the Stan model?

I’ve been following along here:

http://htmlpreview.github.io/?https://github.com/lauken13/Beginners_Bayes_Workshop/blob/master/stancon2019-intro.html

The author iteratively builds a model based off of the inadequacies of the previous model at each step. The final step is the model that I’m interested in, unfortunately.

The observations are the number of complaints for each building, month. The gaussian prior is on the month index of which there are multiple observations for each index. The model itself is a varying effects, varying slope model with the building as the second level in the hierarchy.

I was unable to recreate the gaussian prior part in pymc3.

I see. I’m happy to help you add some features on and build up to the GP part. What do you have implemented so far for your model? If you have a self-contained code snippet that I can run, then I’ll be able to help you much more rapidly.

I also was wondering if there was any general advice for translating a Stan model into Pymc3? I’ve tried an example discussed here: Insurance Loss Reserving Model

but it’s not quite right and i’m unsure of whether this is due to differences under the hood or that i’ve simply misspecified the model. More likely the latter… but it would be good to know how?