# How does JAGS deal with state space models?

I am trying to use JAGS to deal with the following multivariate state space model.

$Y_t=X_t\theta_t+\epsilon_t$

$\theta_t=\theta_{t-1}+\nu_t$

JAGS code is neat but JAGS is running too slow when I am monitoring several hundred variables in the model. I decide to use forward filtering backward sampling algorithm (FFBS) to write my own code. I am wondering how JAGS deals with state space model and whether FFBS is more effcient than JAGS.

• You might want to try STAN, from Andrew Gelman's lab - for many types of problems, it's far faster than BUGS or JAGS. – jbowman Sep 28 '13 at 13:29

Depending on the complexity of your model, you could use the dlm package in R. It's pretty user-friendly for standard linear Gaussian state space models (i.e., dynamic linear models). It also allows for both MLE and Bayesian MCMC, which is nice.