Yes you can do this. All statespace matrices except x0
and P0
are allowed to have a time dimension on the far left. There is some discussion about how this works here.
To take advantage of this, you will need to register sigma_eta
with a time dimension. You don’t know how long that is going to be until you see the data, so put None
like this:
sigma_eta = self.make_and_register_variable('sigma_eta', shape=(None, self.k_posdef,))
To allocate this into state_cov
, you will need to make it into a stack of covariance matrices. You can do this with pt.diag
, but you need to vectorize it:
self.ssm['state_cov'] = pt.vectorize(pt.diag, '(a)->(a,b)')(sigma_eta)
Finally, add the dimension TIME_DIM to sigma_eta
. If you’re feeling fancy you can also update the info to note that it needs to be time-varying.
Two final comments:
- The statespace model itself doesn’t know anything about the time dynamics, so you have to give
sigma_eta
a prior that encode that information (viapm.GaussianRandomWalk
or whatever) - Small quibble with names: your parameter is called
sigma_eta
, but it’s being put directly into the covariance matrix, so it’s actuallysigma_eta_squared
. This is important if you are doing a replication study/communicating your results.