-
Notifications
You must be signed in to change notification settings - Fork 3
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
Request for help #12
Comments
Will look into it today. |
I think it is an issue with AD producing NaNs or similar. Ideally one would investigate, but I added a quick fix in the form of a wrapper, I made a PR in the repo. Please review and let me know if this works. |
Also, you can investigate corner cases of log densities with |
As I mentioned in the SR pull request comment, will try several more models and compare the results. I wonder if rejecting the cases where AD produces NaNs might influence the resulting densities. Maybe stress testing will help out here. If that's ok, I'll try some more models before closing this issue. |
That's fine, keep it open as long as you like and feel free to ask if there is anything I can help with. |
Tamas, in trying to dig a bit deeper into the posterior draws from m10.4d.jl, I have tried to apply stresstest:
P in this case uses:
Interestingly, interchanging the ∇P options in m12.6d.jl is spot on (and unaffected), which I interpret as some support for my earlier hypothesis that the rejection errors might create a bias. Am I correct to assume that stresstest, if applied correctly, would show parameter values where NaNs occur? I was hoping to be able to plot those regions as part of the debugging proces. |
You should try |
As you suggest as well, I'd commented out the LogDensityRejectErrors line and replaced it with the vanilla ADgradient:
and it fails on the I'll experiment a bit more. |
Tamas, as I noticed (and tested) your updates to DynamicHMC and LogDensityProblems, can I ask for a little push to get stresstest() to work in trying to resolve the only model that continues to give different results in DynamicHMC vs. Turing & CmdStan? In m10.4d1.jl (results illustrated in m10.4d1) I've tried to use stresstest() and different AD methods. If I enable do_stresstest it will show:
Using LogDensityRejectErrors provides very stable results and the plots of the chains look reasonable (I've also tried 3 and 4 chains). It is true that the pooled estimate of a[2] is a bit higher in scale. But it is surprising this is the only model where I've seen a problem. Particularly the sd values are vey high, in Turing, using NUTS, usually an indication that the adaptation draws are included but I don't think the posterior includes those in DynamicHMC. |
If I understand correctly, there are two issues:
Did these happen after the recent (minor) updates to LogDensityProblems and DynamicHMC, or did you have them before? |
Correct, w.r.t. issue 2), normally (for all other models) I use W.r.t. issue 1), only for the m10.4d1.jl model I have experimented with stresstest by |
Are you using the latest LogDensityProblems and DynamicHMC? I could not reproduce the errors above. Also, I am not sure how I would detect the discrepancy, should I look at the plots? |
In the script the results from Turing and CmdStan are included:
I tried this morning with:
in Manifest.toml. |
The results I'm getting:
or, just printing the means of the posterior vector (from another run):
|
Tamas, when you say "I could not reproduce the errors above." does that path (with |
Apologies for not getting back to you about this yet, this is a busy time for me. I really appreciate this test case. Various other users have reported subtle (or not-so-subtle) maladaptation and bias issues. I have a couple of guesses about this:
To investigate 3 and 4, I will be working on tpapp/DynamicHMC.jl#30. I ask for your patience in the meantime. The test cases are greatly appreciated. |
Thank you Tamas. Absolutely no apologies needed! I simply can't think of anyone contributing as much to the Julia community as you do! Any time I notice an update to one the various packages I will continue to try it. For now I will always compare the results to at least Turing and Stan. When I started the work on StatisticalRethinking I had a time frame of about 2 years in mind so from that point of view I'm not even halfway. |
Tamas, I was wondering if you would mind to take a look at m10.04d.jl?
Until chapter 10 in StatisticalRethinking.jl I've had no trouble adding the DynamicHMC versions in addition to Turing and CmdStan versions, e.g. m10.04t.jl and m10.04s.jl for. model 10.4.
I followed the approach I'd used successfully for m10.02d1.jl, which works fine, but in this case I get
Different starting values in
θ = (β = [1.0, 0.0], α = [-1.0, 10.0, -1.0, -1.0, -1.0, 0.0, 2.0])
do not solve the issue, thus I wonder if this way of modeling such problems is correct.Thanks for you help (if doable!),
Rob
The text was updated successfully, but these errors were encountered: