Hello, all. I am asking this question in not necessarily a "subjectively recommend something for me" approach, but with a clear focus on just an accessible beginner's reference. My situation is I have been learning the theory behind Bayesian structural time series, or state space models estimated using Bayesian methods (some variant of MCMC), but have found it extremely difficult to find succinct guides on implementing them through code.

Books on cross-sectional Bayesian coding abound, are excellent, and are well-known, such as Bayesian Methods for Hackers, and Doing Bayesian Analysis.

However, the single resource I located on Bayesian time-series that is both 1) relatively new, 2) features more complex models (HMM, non-linear, non-Gaussian), and 3) has full implementing code is Basic and Advanced Bayesian Structural Equation Modeling. Though featuring examples in BUGS, they seem more included for fullness, and the book does not attempt to explain how to code them.

So what do you all think is the best resource for coding more sophisticated Bayesian structural models, focusing on guiding you through its tool of choice (Stan, JAGS, OpenBUGS, some random R library...) rather than focusing on the theory? I hope the experienced Bayesians here can offer some pointers on where to get started.


I would say Stan (disclosure: I am one of the Stan developers). For most of the models you mention, there is not going to be a Gibbs sampler with known full-conditional distributions for all of the parameters and even for the exceptions, the chains might not mix well under Gibbs sampling.

That said, here are some links:

  • $\begingroup$ Thank you for your answer. I will be sure to check out those resources, especially the github for the unfinished book! I do have one question, still. I understand a non-linear, cauchy-distributed, 6-regime HMM (or some other crazy models) possibly can't be done efficiently. However, moderately more complex models should be possible that include some non-normal noise, or involve a couple of regimes, as evidenced by the BUGS book in the 3rd link. $\endgroup$ – Coolio2654 Aug 18 '18 at 15:13
  • $\begingroup$ For ex., imgur.com/a/9cAAxim is a random screenshot I took from it that states a Metropolis–Hastings approach could handle non-linearity. Are such approaches planned for stan at some point? $\endgroup$ – Coolio2654 Aug 18 '18 at 15:13
  • $\begingroup$ Anything that can be done under Metropolis-Hastings (that is differentiable with respect to the parameters) can be done much better using Stan's No U-Turn Sampler and requires the same thing from the user: defining the log posterior kernel. $\endgroup$ – Ben Goodrich Aug 18 '18 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.