Repository navigation
parametrize test, use smaller n_grp to (try to) expose numerical issue - #4414
jbrockmendel wants to merge 3 commits into
Conversation
|
CI errors reflect the PR being correct and the existing code being problematic. |
|
@jbrockmendel thanks for working on this. Here are a couple of ways to make the test problem a bit easier: Option 1: Comment out this line at around line 108 of the test file: Option 2: Change this line at around line 135 of the test file: to something like this For me, doing either of these things makes the gradients accurate to at least 10-4 or better, based on monitoring I don't know what fundamentally is going on here, but I suspect that there may be some roundoff errors creeping in when calculating the log likelihood and/or score far from the MLE. The changes above make it so that the test points are closer to the MLE. The MLE for cov_re is It would be nice to know whether the analytic score or numerical score are closer to the truth here, but I have no way to assess that. Fortunately, it probably doesn't matter much because the gradient doesn't need to be highly accurate until you get close to the MLE. I doubt that there is an actual error in the analytic score, because if there were, I think the values would be off by much more and would be off more consistently. On the other hand, there is a lot of room for numerical error to creep into these calculations. I haven't reviewed the code to try to identify places where algebraic rearrangement could improve numerical accuracy. |
|
@kshedden Not sure if this is mutually exclusive with your hypothesis, but AFAICT there is a code-consistency issue and a numerical stability issue. For the next block of code I'm going to assume that you've run the contents of the test up until the first AssertionError (for me this happens at The test is checking that a numerical derivative of loglike matches score, but it also is computing these using different representations of the parameters. It looks like the parameters part is problem: I'm assuming these should match; is that assumption incorrect? I think that the mismatch is related to the hard-coding of Calling Then there's the issue of numerical stability. Let's approximate a numerical derivative in the relevant coordinate of This seems like the sort of thing that could be a problem. |
|
Closing; #5802 can take over for discussion of this flaky test. |
No description provided.