Rstan output warning

Hi all,

Recently I am running a large rstan program with 4 chains: each with iter=10000; warmup=5000; thin=1

However, I got the following warning message:

There were 16 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmupExamine the pairs() plot to diagnose sampling problems
The largest R-hat is NA, indicating chains have not mixed.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#r-hatBulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#bulk-essTail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
http://mc-stan.org/misc/warnings.html#tail-ess

I believe that I have ran enough number of simulations and the Rhat for the paramters in the model are all like 1.00x (less than 1.01). But I am still confused about the following two questions:

  1. Should I ignore the warning message?
  2. Some paramters have relatively small n_eff, such as 3000 but in total I have ran 60000 simulations, will it just because of randomness or my model is misspecified?

Thx!

Also when I repeated the sampling, some of the smallest n_eff have changed from 3000 to around 10000, which makes me quite confused…

You should not ignore the warnings, and you probably should not need to run that many iterations. It’s hard to say More without seeing how you specified your model.

Thx!

Also I found that one of the paramters has n_eff 66314, which is greatly than the total number of simulations (60000). Does it mean that my calculation is wrong?

That is not an error. Effective sample size can be larger than total sample size.

The estimated effective sample size is going to vary from run to run. That’s especially true when mixing is slow because then the adaptation is less reliable.

Thanks so much!

May I ask that is Rstan has some funtion like set.seed() so that I could make sure that every time I ran some Rstan code the output will be reproducible?

The stan() function in rstan has a seed parameter. The documentation says:

seed: The seed for random number generation. The default is generated from 1 to the maximum integer supported by **R** on the machine. Even if multiple chains are used, only one seed is needed, with other chains having seeds derived from that of the first chain to avoid dependent samples. When a seed is specified by a number, as.integer will be applied to it. If as.integer produces NA, the seed is generated randomly. The seed can also be specified as a character string of digits, such as "12345"` , which is converted to integer.

Using R 's set.seed function to set the seed for Stan will not work.`

1 Like