Hello All,

I am trying to fit a mixed effect model using rstan. Rhat value of corr[1,1] is Nan but not cor[2,2] or corr[3,3]. I would really appreciate if anyone clarify this. I have also attached the snapshot of my output.

Marimuthu.

Hello All,

I am trying to fit a mixed effect model using rstan. Rhat value of corr[1,1] is Nan but not cor[2,2] or corr[3,3]. I would really appreciate if anyone clarify this. I have also attached the snapshot of my output.

Marimuthu.

One reason this can happen is when a parameter is fixed to a specific constant value, in which case there are no draws for it, often times this is in a model for identifyibility reasons. If you share you stan code it would be easier to see if this is the case or if there is another reason. Here I am assuming you are using standardized random effects in which the variance (the diagonal of Omega) is 1, and tau is the actual variance. In this case I would have expected all Omega diagonals to have NaNs for se_mean, ne_eff and Rhat - you are not estimating these parameters.

1 Like

As commented by @Ven_Popov, the diagonal elements of a correlation matrix should all be constant 1. If you have defined

```
corr_matrix[3] Omega;
```

then also the Stan output should have constant 1 for diagonal elements. Stan does not indicate in output which variables are constant by definition, and which variables happen to get only one unique value, for example, due to sampler getting stuck. Because of this, the diagnostic can’t make the difference between constant by definition and seemingly constant due to chain being stuck, and then the diagnostic is not available and NA is reported.

As you do observe something else than NaN, there is some part of computation constructing Omega introducing noise due to limited accuracy of floating point computation in the matrix operations.

1 Like

Thank you, @Ven_Popov and @avehtari.

@Ven_Popov, you are right. Omega is a correlation matrix and tau is standard deviation. I expect all the diagonals (Omega[1,1], Omega[2,2] and Omega[3,3]) are Nan but Omega[2,2] and Omega[3,3] are not. That’s why I am wondering that is there any specific reason for that.

Thanks again for your prompt response.

Marimuthu