Closed mattwigway closed 2 years ago
Looking at this further, I get slightly different results each time I run.
If I run with a single thread, I consistently get something close to the top result, so this does appear to be a threading issue.
Not an issue in HaltonSequences. If I prematerialize the sequences I get the same problem.
Could be a numerical issue due to order of adding things.
It does appear to be due to order of addition. If I modify code to make addition order deterministic (by accumulating each group likelihood in an array then summing), I always get a consistent result (close to the top one).
I think the squaring of the coefficients may be causing this by creating a saddle point that the optimization may or may not get stuck in depending on tiny differences due to floating point errors. Note that in the less-desirable solution, Bhw_sqrt(sigma) is always exactly 0. Squaring is to keep them positive, gonna try exponentiating instead - since that's a monotonic transformation.
Confirmed that exponentiating rather than squaring solves the problem, with only very slight variations now due to numerics.
Fixed in 879b0df
I once got this results from the Apollo-derived mixed logit example:
Usually I get this result:
This should be deterministic. Possibly a race condition somewhere.