What does cholesky_factor_corr[J, K] where J != K do?

Hey all,

Just discovering an interesting end of the language that I don’t see talked about in the manual at all. Apparently this is valid Stan:

  cholesky_factor_corr[4, 7] L_Sigma;

The generated code will read in an unconstrained vector based on the number of rows and not at all based on the number of columns. I assume this is fine because we’re reconstructing a square matrix; what happens to the extra space in the resulting matrix on the constrained space? Why do we allow this?

For covariance matrices, the answer is semidefiniteness (reduced rank). But the whole thing gets read in.

Ask @bgoodri for details—I’ve never used it.

Woops, I made a mistake - cholesky_factor_cov can take two size arguments, but cholesky_factor_corr cannot, and the former does pass both of them to the reader when reading. Everything lines up, sorry about that!

Yes, in principle you can have a short-rank covariance matrix whose Cholesky factor has more rows than columns. But that doesn’t make sense as a correlation matrix, or at least we don’t have any reasonable priors for a short-rank correlation matrix.

1 Like