Kalman filter vs. scan?

Hello,

This is a very general question, but I’m wondering what the trade off is, if any, of using the Kalman filter for state space models vs scan (e.g. in terms of efficiency, sampling time, etc.), and whether or not that answer changes depending on whether the state space is linear-gaussian, nonlinear-gaussian, or nonlinear-nongaussian.

Also, and this is specific to numpyro, there’s a library for state space models using jax (see probml/dynamax: State Space Models library in JAX (github.com)), and I’m wondering if there is anything that would prevent it from being used to together with numpyro?

Thanks in advance.

I think using filtering is better because it marginalizes the latent space. I think you can use dynamax with numpyro if you want to perform inference over some global random variable. Something like

def model(data):
    global_params = numpyro.sample(...)
    log_likelihood = run_dynamax(global_params, data)
    numpyro.factor("likelihood", log_likelihood)

Thanks!