which compiled but returned an initialization error. To remove an initialization error, I provided good initial values, but I got lots of sampling errors.
Hi,
I think this specific case should be possible, but to do this, you will need to implement the constraining transform + Jacobian adjustment yourself. I’ll take the default transformation as a starting point 10.9 Correlation matrices | Stan Reference Manual
Conjecture: the cholesky decomposition of a correlation matrix with all positive elements has all elements positive. Trivially all positive elements of cholesky decomposition means all positive matrix. Not sure about the converse, can’t quickly prove it. If the converse does not hold, the construction below will be overly restrictive.
Note that in the construction of w (the cholesky decomposition) in the Stan manual link, the diagonals are ensured to be positive (to make the decomposition valid) and the sign of off-diagonal w_{i,j} equals the sign of z_{i,j}. So we need to ensure z_{i,j} = \tanh y_k > 0 which is equivalent to y_k > 0. So if you can reimplement the constraint and Jacobian yourself, but start from parameters constrained to be positive, you will get a correlation matrix with all entries positive.
@martinmodrak I will read the suggested chapter to understand the math behind the correlation matrices. @spinkney Thank you very much for providing your code. It is greatly appreciated and helped me a lot.