State Space Models in PyMC

Because I have no idea what I’m doing.

More specifically, I had trouble with getting the update function onto the computation graph. This is what lead to declaring that theta tensor variable inside the compile_aesara_function, so that I could call update, then call the Kalman filter. Since the Kalman filter just reads off the state space matrix member variables from the model, there needs to be some way to get the PyMC RVs into them. Compiling was my solution, although I agree it’s inelegant.

I will try to think about how to change the design to avoid compiling the functions before the model actually runs. I will note that will be helpful to have compiled functions to get the mean and covariance trajectories for post-estimation routines. Impulse response functions in particular. Is there a performance benefit to passing a compiled vs un-compiled function to pm.Potential?

2 Likes