Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stan models for positive definite transforms #31

Merged
merged 19 commits into from
Aug 12, 2022

Conversation

sethaxen
Copy link
Collaborator

Adds Stan models with the following 2 transforms for positive definite matrices:

  • Cholesky
  • Matrix exponential

The transforms and derivations of the log Jacobian determinants are already in the paper.
For now I have placed the transforms in a model with a target Wishart distribution. @mjhajharia what's a good approach for the transforms to be reused for the other target distributions listed in #15?

Relates #15

@mjhajharia
Copy link
Owner

at the moment we're using a function in stan and just using it as a dictionary of sorts that gives out the logprob term for a given distribution. so once the transform's stan file is merged I'll create that. don't put the distribution in the model section for now

@mjhajharia
Copy link
Owner

btw @sethaxen I was cleaning up the paper and in the augmented-softmax section I find the notation a little unclear, is x_ the whole vector or -ve? this is dumb but i often get very confused with notation. also ig, should we be mentioning the paper's example you thought of this from ?

@sethaxen
Copy link
Collaborator Author

at the moment we're using a function in stan and just using it as a dictionary of sorts that gives out the logprob term for a given distribution. so once the transform's stan file is merged I'll create that.

Cool! I'm interested to see an example because I don't know how to do that in Stan.

don't put the distribution in the model section for now

Done!

There's at least one more positive definite transform to add, but it needs to wait for Stiefel transforms, so I'll add it in a separate PR. PSD matrices will also be handled separately, even though there may be some code duplication.

btw @sethaxen I was cleaning up the paper and in the augmented-softmax section I find the notation a little unclear, is x_ the whole vector or -ve? this is dumb but i often get very confused with notation.

Not dumb at all! Notation is hard, and I'll refine the notation a few times in the end. In this case, x_ is defined in the softmax (non-augmented) section as all but the last entry of x. But I think @bob-carpenter's suggestion of adopting a more programmer-friendly notation should be adopted in the two softmax derivations (e.g. here x[1:n-1]), though that may not work well in later sections (e.g. Stiefel).

also ig, should we be mentioning the paper's example you thought of this from ?

I don't think so. The route from that paper to this transform was convoluted, and where we ended up (softmax) is better motivated just by mentioning softmax. But if in the results we find it helps to explain results, then we could explain that geometric intuition. (unconstrained space -> positive orthant of sphere -> simplex) and mention that paper (already cited elsewhere).

@mjhajharia mjhajharia force-pushed the main branch 2 times, most recently from 83976e8 to e4e4bdc Compare July 21, 2022 00:47
@mjhajharia mjhajharia force-pushed the main branch 3 times, most recently from 50ff505 to e543e75 Compare August 12, 2022 02:03
@mjhajharia mjhajharia merged commit a77521d into main Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants