I was wondering if anybody has the specific algorithm details for how Stan samples correlation matrices - particularly how it ensures positive-definiteness

Those details are in the Users guide here:

Itâ€™s in the LKJ paper but itâ€™s tough to parse out how to write this algorithm. Iâ€™m still impressed how Ben was able to grok the algorithm and write it in Stan.

Thanks @spinkney and @jsocolar - the section in the manual which @jsocolar linked too (which is the same method as the LKJ paper you reference, I think) doesnt seem like it would be too difficult to implement, as it clearly spells out how to map from the unconstrained parameters (which we can use in the HMC leapfrog integrator to update the estimates) to the correlations and vice-versa? I havent had a chance to attempt to implement it yet though so ill see how it goes and let you know :)

Hi @CerulloE,

Just in case youâ€™re planning on using the implementation as laid out in the Users guide, I want to point out that Section 10.9 of the reference manual contains several mistakes. I described them here:

I submitted a pull request with fixes to github, but it doesnâ€™t seem to have been pushed to the online version yet.

Hi @nspencer ,

Thanks for pointing this out. I noticed that the â€śmanageable expressionâ€ť also wasnt correct but assumed I coded it wrong

Is this part of that section correct?

Thanks

Hi CerulloE,

I think that part you screen-shotted is still fine. If you want my updated version of the â€śmanageable expressionâ€ť, you can find it on the latest version of the manual on github.

Thanks for your response!

From this post (here) it looks like the Stan math library implements a different method than that given in the user guide - is this still the case now? shouldnâ€™t the user guide match/be up at date with the method Stan uses? apparently they result in different correlation matrices