LKJ prior throwing positivity exceptions

This is almost surely an overflow issue where the value is overflowing to 1 in which causes the diagonal to be 0 and triggers the warning. As @kyle.hofmann noted the mathematics say this is impossible but with finite-precision computing this happens.

In the original model, the dimension of the correlation matrix is only 2. I almost never use the built-in Cholesky factor of correlation matrices for this. Since you can easily parameterize it with 1 parameter yourself as

real<lower=-1, upper=1> phi;

We, the Stan devs, need to update the parameterization to something like Updated cholesky corr parameterization testing which shouldn’t have this issue.