# Convergence within chains, but not across chains

**URL:** <https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364>\
**Category:** Modeling\
**Tags:** stan, fitting-issues\
**Created:** [March 18, 2021, 4:40pm UTC](https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364 "2021-03-18T16:40:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scijens](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/scijens/32/9695_2.png) [@scijens](https://discourse.mc-stan.org/u/scijens)\
**Post date:** [March 18, 2021, 4:40pm UTC](https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364/1 "2021-03-18T16:40:16Z")

</div>

Hello everyone,

I am running a Hidden Markov Model in Stan where some covariates drive the transitions between the latent states. Running the model on larger samples, I am still having issues with poor convergence in most of my parameters (as indicated by Rhat; in another post, it was recommended to apply the non-centered parameterization, which unfortunately didn’t solve the problem).

Looking at the summary output of the 2 chains I was running (each with adapt delta=.90, max\_depth=12 num\_samples=2000), convergence appears to be quite poor:

![grafik](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/b/b8cf1e4d39bdbc73d050770cbc18142f00c2c2c2.png)

Looking at the summary of each chain separately, it looks ways different:

Chain 1:  
 ![grafik](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/a/aeb06e9c66198c8297e774f1adfac0605ea93d9f.png)

Chain 2:  
 ![grafik](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/6/6a1a2dbc9e7ab8fb962b67c448052e6457b6c747.png)

Now the traceplots of the 2 chains show what’s going on. Most of the parameters converge within a chain, but they converge to “slightly” (there is a difference, but this difference does not change the content-related implications I want to draw from this model) different values.

 ![grafik](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/8/822856c34cc2df25bf8862de024b2f0554e82658.png)

My questions are:

- Am I correct in assuming that running this model again with adjustments to the computational parameters (iterations, adapt\_delta, etc.) would do no good at all?
- Is the convergence problem really as big as it seems if it doesn’t change the insights I want to generate with the model?
- Any other recommendations on what I should try?

---

<div class="post-metadata">

**Author:** ![mike-lawrence](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mike-lawrence/32/59_2.png) [@mike-lawrence](https://discourse.mc-stan.org/u/mike-lawrence)\
**Post date:** [March 18, 2021, 5:38pm UTC](https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364/2 "2021-03-18T17:38:47Z")

</div>

You have encountered a common pathology whereby the posterior is multimodal and chains get “stuck” exploring only one mode. Often this occurs when two or more parameters in the model are “non-identified”, meaning an increase in one can be offset by a decrease in the other to yield the same likelihood as if neither had changed. Take at the pairs plots of the posterior samples; non-identified parameters will show a strong correlation.

---

<div class="post-metadata">

**Author:** ![scijens](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/scijens/32/9695_2.png) [@scijens](https://discourse.mc-stan.org/u/scijens)\
**Post date:** [March 18, 2021, 8:03pm UTC](https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364/3 "2021-03-18T20:03:52Z")

</div>

Thank you. I have a follow-up question: Let’s take these two parameters mu and nu (state-dependent intercepts of two equations in the 2-state model) as an example:

 ![Rplot02](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/9/94ef984edef5f97ab2c37f2e65511dc1f0048b3f.png)

Is it necessarily problematic that mu[1] is correlated with mu[2] and nu[1] and nu[2]? In my specific example it would only mean that if the intercept of state 1 is higher in that equation, the intercept of state 2 is higher, too.

Or is the correlation between two parameters an issue per se?

---

<div class="post-metadata">

**Author:** ![Funko\_Unko](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/funko_unko/32/10786_2.png) [@Funko\_Unko](https://discourse.mc-stan.org/u/Funko_Unko)\
**Post date:** [March 20, 2021, 12:02am UTC](https://discourse.mc-stan.org/t/convergence-within-chains-but-not-across-chains/21364/4 "2021-03-20T00:02:55Z")

</div>

> [@scijens](#):
>
> Or is the correlation between two parameters an issue per se?

I’ve been wondering the same thing, and I don’t know whether I have heard a good answer yet.

I guess the simplest example would be just a two parameter problem where prior and posterior are multivariate gaussians, but the prior looks like a circle, while the posterior looks like an extreme ellipse.

But even then, the posterior may either have shrunk considerably in all directions, which I guess would make the correlation unproblematic, or it may have only contracted in one direction, which would tell you that you have no information whatsoever about the other direction?
