I have a quite complex hierarchical model for which I'm estimating parameters and producing posterior predictive using STAN (rstan) for some psychophyiscal data.

I'm (sometimes) observing some strange behavior:


These are traceplots and diagnostics of two different variables (group means). As can be seen, three chains mix nicely, but the forth is getting stuck. It is not highly implausible that there is some local optimum (and by restricting parameter ranges I can avoid it) but I'm a bit surprised that it is always the same chain even on different variables. These variables are not connected by any model structure and the data is from independent experimental conditions.

The only connection could be that the real values in the participants are correlated. The parameter describes some rate of information processing. A person with a high rate in one condition will also have a high one in the other condition.

So my question is: (without considering any other details of the model) can such a relation in the data, or some other factor, lead to autocorrelated behavior in the same chain for different variables (which are not connected by any model structure and are estimated from non-overlapping data)?

Many thanks and best regards Jan

[P.S.: One alternative explanation that I have not looked at yet comes two mind: Maybe the trace plots decide the colors of the chain based on the average value and not on the chain id? That could be misleading ... ]

  • $\begingroup$ Is it a question about how Stan interface works or about statistical issues..? If it is about Stan interface than it is off-topic on CV and I would suggest stan-users mailing list, see list of online resources about Stan here: meta.stats.stackexchange.com/a/2498/35989 $\endgroup$
    – Tim
    Commented Sep 4, 2015 at 14:38
  • $\begingroup$ Btw, since the chains are "random" talking about "always the same chain" makes no sense since every time it is a different chain. If you mean something like "chain colored in blue on the plots" then it is worth checking how exactly does Stan label the chains. $\endgroup$
    – Tim
    Commented Jun 14, 2017 at 14:53

1 Answer 1


Yes, it makes sense that all the parameters within a particular chain have high autocorrelation.

A "stuck" chain is a Markov chain that hasn't reached the typical set and is not effectively making draws from the correct posterior distribution. When this happens, the tuning parameters are estimated to the region of the posterior that has been seen, which isn't where it should be. The difficulty is finding the typical set so we can tune, but without tuning, the typical set can't be found. In Stan, all parameters are jointly sampled, so it makes sense that all parameters have high autocorrelation.

One (practical) solution is to fit a better model by providing more information through priors on the parameters.

  • $\begingroup$ Dear Daniel, many thanks for the reply! What is confusing me is the following: I would totally understand it if the chain gets stuck at a particular value for one parameter. Then proposals are rejected and the chain becomes stationary also in other independent parameters (due to Stan sampling parameters jointly). But what I see is that the chains move a bit close to the value (so they are not stuck at a single value) .... $\endgroup$ Commented Oct 15, 2015 at 21:15
  • $\begingroup$ In my imagination (which obviously is not matching reality) the chain could proceed with larger jumps in the unrelated parameters while being caught (jumping small steps only) in the problematic dimension. That is why I thought the small jumps in one dimension may lead to some adaptation of internal properties that concern all chains. $\endgroup$ Commented Oct 15, 2015 at 21:16
  • $\begingroup$ By now I have started trying some reparametrization (what I saw sometimes calledthe Matt trick). I'm not sure yet if it will work. $\endgroup$ Commented Oct 15, 2015 at 21:17
  • $\begingroup$ Hi Jan, this is in response to your second comment. You're right: the MCMC algorithm could jump in the unrelated dimensions. The problem is that we're only using gradients and not the Hessian. Once we extend Stan past Euclidean HMC and go to Riemannian manifold HMC, then the problem you're describing is mitigated. But, that's much more computationally expensive and we're still not there with all the higher order derivatives. $\endgroup$
    – syclik
    Commented Oct 21, 2015 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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