-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
BUG: LKJCorr breaks when used as covariance with MvNormal #7101
Comments
The initial point problem happens because of jittering and the insufficient IntervalTransform that is being used. I assume |
See also discussion in pymc-devs/pymc-experimental#13 |
@velochy We just merged pymc-devs/pytensor#614, which lets us now use |
Depends on how urgent it is :) currently pretty swamped but should be able to get to it within a month or so |
Hi - I'm at Pydata London and will a look at this. |
For anyone in the pymc hack, I'm in the back middle of the room |
Hi @johncant , let me know if anything isn't clear about how to proceed |
@jessegrabowski thanks a lot! Nothing is clear and I am out of my depth. However, it's great learning and I still intend to fix this issue. @twiecki and @fonnesbeck were there and helped me understand more about pymc than I would have learned from days of hacking on it myself. Here's what we found:
I think it's obvious to you that the problem is the default transformation for LKJCorr and it needs to be replaced with this. For me to do this, the next steps are:
[1] Replicates issue as long as n is high enough
[2] Replacement with LKJCholeskyCovariance - it samples without error (but with divergences)
|
Progress tracking comment
|
I decided to post my progress from yesterday as a jupyter notebook: https://colab.research.google.com/drive/1UNkgxEuy6j_Eww0aMFnsfzQfQmlxG2-d?usp=sharing . Basically, I now also understand why the transform on LKJCorr is the problem and can start understanding and porting the TF transform. |
Describe the issue:
LKJCorr backwards sampling is currently broken and does not properly constrain values to a positive semidefinite matrix early enough. This leads to compilation randomly failing when providing it as a covariance matrix for MvNormal and other similar multivariate distributions. The failure is inherently random, but it gets increasingly likely with larger n values and fails almost always with n>=10 and can in theory be seen with n as low as 3.
Error message is informative, as it is easy to verify the matrix reported in error has negative eigenvalues, proving it is not PSD.
This only affects the backwards sampling (i.e. logp computations), with .eval() and predictive sampling working as they should.
Reproduceable code example:
Error message:
PyMC version information:
pymc 5.10.3
Context for the issue:
This arose in discussion with @ricardoV94 and @jessegrabowski in https://discourse.pymc.io/t/using-lkjcorr-together-with-mvnormal/13606/29 . Thread has more useful context
The text was updated successfully, but these errors were encountered: