stephens999 / ashr

An R package for adaptive shrinkage
GNU General Public License v3.0
80 stars 36 forks source link

Include sanity check before warmstarting g #96

Closed willwerscheid closed 5 years ago

willwerscheid commented 5 years ago

To summarize, the problem is that we need warmstarts to guarantee the monotonicity of flash, but if you initialize using a very bad value of g then ash will crash (this occurs when there is a data point that has a numerically zero likelihood of appearing in any of the components of g). I initially considering expanding g's grid, but this turns out to be very complicated given our implementation. I think the simplest fix is to include a sanity check on g. If the check fails, then g will simply not be used. So we no longer have an absolute guarantee of monotonicity, but the sanity check will only fail when the previous value of g was very bad, so it's reasonable to expect that we'll see an increase in the objective function even when g needs to be re-estimated.

This PR also includes revisions to the handling of grange, which was a bit buggy before (this fixes #95 ), and a bit of reorganization of part 2 of the main ash function, which I found very difficult to read.