Trouble fitting "birats" model from Stan demo BUGS examples

I’m trying to fit the birats example from the Stan demos repository.

The Stan code I’m using is here: example-models/birats.stan at master · stan-dev/example-models · GitHub

and the data is here: example-models/birats.data.R at master · stan-dev/example-models · GitHub

I haven’t changed any aspect of the model, however, I’m getting very poor fit. There are many divergences and the chains are not mixing well. I’ve tried a few things including:

  • Setting adapt_delta to 0.99
  • Setting max_treedepth to 20
  • Running longer chains: 5000 warmup / 5000 sampling

Here is my code and output using these methods: Fitting the birats example

I’m puzzled why a Stan demo example is having such convergence issues. Does anyone have thoughts on how to fit this model more effectively?

It seems like you’re not using the inits also saved in that folder, correct? Specifying them with the file provided seem to dramatically improve the performance of the model.
There is also a commented out noncentered version which seems to perform even better

In general, a warning against using the models from example_models without careful inspection. Many of them are quite old and represent a style of Stan code which is no longer (or perhaps never was) the best way to implement a model. For example, the birats model had its last substantive change nearly 10 years ago. Several things in it could be vectorized if written from scratch now, which could have dramatic impacts on the computational efficiency if not the convergence.

1 Like

Thanks very much @WardBrian! Would you have any recommendation of where to find examples models with the most up-to-date Stan code?

The Stan Case Studies (Stan - Case Studies) are a much smaller set of examples but they tend to be better vetted in my experience, and they’re sorted by date which is helpful. Some canonical models are also presented in the Stan users guide, and those are generally kept up to date as features change.

There may be better examples out there depending on the model or domain you’re interested in, but I don’t know of any one stop shop as it were

1 Like