lindermanlab / ssm

Bayesian learning and inference for state space models
MIT License
540 stars 196 forks source link

Time-varying C matrix? #162

Open jmasis opened 1 year ago

jmasis commented 1 year ago

Hi there,

Is it currently possible to fit data with a time-varying observation matrix?

I have a simple bandit-type experiment I'm trying to fit with a Kalman filter where subjects choose one of two bandits on every trial and then perform a task linked to that bandit. This means that on every trial, I can only observe the choice and the result from one of the bandits and there are missing values for the other bandit. To fit both bandits jointly (because I'm interested in how performance in the tasks influences the choice of bandit on the following trial), I thought I could have a time-varying observation matrix. I know that the pykalman package allows this, but I'd like to use ssm if I can.

If this isn't currently possible, is there a fairly simple way to implement it?

Thank you!

Javier

slinderman commented 1 month ago

The low level Kalman filtering/smoothing algorithms do support time-varying emission matrices. If you already know the C matrices (and other LDS parameters) for each time step, you can call those functions to infer the latent states given observations.

If you need to estimate the emission matrices, then you'll have to implement a more sophisticated model. Please let me know if that answers the question!