Hello,
I think there is an inconsistency/error in the Stan reference manual for the LKJ inverse transform for correlation matrices.
The manual gives 2 formulations for the transform. I refer to them in the order in which they appear in the manual.
Let’s first focus on w_{2,2}. The first formulation gives us:
w_{2,2} = (1 - z_{1, 2}^2)^{1/2}
The second formulation gives us:
w_{1,2} = z_{1, 2}
w_{2,2} = z_{2, 2} * w_{1,2} * (1 - z_{1, 2}^2)^{1/2}
w_{2,2} = z_{2, 2} * z_{1,2} * (1 - z_{1, 2}^2)^{1/2}
z_{2, 2} = 0 in the upper triangular matrix above these expressions. Therefore, w_{2,2} = 0, which is incorrect as the diagonal terms need to be >0. In addition, these expressions are not consistent as z_{1,2} is not necessarily 1.
Now let’s focus on w_{2,3}. The first formulation gives us:
w_{2,3} = z_{2, 3} * (1 - z_{1, 3}^2)^{1/2}
The second formulation gives us:
w_{1,3} = z_{1, 3}
w_{2,3} = z_{2, 3} * w_{1,3} * (1 - z_{1, 3}^2)^{1/2}
w_{2,3} = z_{2, 3} * z_{1, 3} * (1 - z_{1, 3}^2)^{1/2}
These two expressions are inconsistent as z_{1, 3} is not necessarily 1.
Please let me know if I have misunderstood the documentation and if not, which is the correct formulation.
Anirban