-
Notifications
You must be signed in to change notification settings - Fork 225
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
Add Slab-and-Spike prior #847
Comments
I could easily be wrong here as I've never used Stan, but as I understand it, they don't allow discrete distributions, so they can't have Dirac deltas making distributions discontinuous. As a result, they have a hack to avoid having a true spike in their slab-and-spike - I think they use a product of two or more normals(?) - Although it would obviously be great to have a true slab-and-spike implemented directly in Turing.jl, my plan is to work on expanding the functionality of Distributions.jl to allow discontinuous distributions in general, and to help with the work to allow discrete distributions have support over any countable set rather than just integers - see JuliaStats/Distributions.jl#925 for both thoughts at the moment. Then the broader question would be how to allow these to be used in Turing, and in particular from the Distributions end, what information would we have to provide you and how for you to be able to automatically handle such distributions? |
This is correct. I'll have to check what the product normal actually does. A real slab-and-spike prior will anyhow only be usable if the user is using any particle-based algorithm. Other methods involve gradients, while SMC and co. only need to be able to sample from the prior using |
Okay. The reason I assumed that might not be the case is that the documentation says that to use a custom distribution you need to define |
True. I think |
We could also dispatch on the |
Yes, that's exactly it. At the moment there is only (log)pdf, which works for both. I'm proposing to replace pdf with pmf for discrete distributions in Distributions.jl but to alias pdf to pmf for backwards compatibility. Then defining both for mixed distributions and dispatching on ValueSupport would work fine for Turing.jl (though I have to admit I still don't really understand how you can handle switching between spike and slab in the likelihood ratio). |
So, any thoughts about this? I would really like to have a go at updating |
Hi, we will not be able to handle discrete distributions over any countable set as we internally assume that values of any distribution are sub-typed by Regarding mixing discrete and continuous distributions in the log joint. I don't see why this would be a problem, but I might easily misunderstand the issue you are raising. For discontinuous distributions (assuming IS based inference) this seems unproblematic too. At least in my opinion. |
Handling non-real values would be great if it's possible, because there is already one PR - JuliaStats/Distributions.jl#916 - to allow non-numeric discrete distributions, and I would be hoping to generalise that. As far as mixing discrete and continuous distributions, again great if it already works - as I've said before I'm simply a user of this stuff and I was assuming that you'd be calculating some kind of acceptance ratio in some MH-like world, and I wasn't sure what that even means if the priors didn't have equivalent terms on the top and bottom - one is a mass and the other is a density. However, are you suggesting that you wouldn't use that kind of approach at all and just sample repeatedly from the prior(?) for some kind of particle-based IS approach? So that kind of ratio never gets in to the equations. Isn't that incredibly inefficient not making proposals based on the current state and the prior ratio? Sorry for being so ignorant, I'm just many years out of touch with this stuff obviously... |
Mixing discrete and continuous RVs in particle-based samplers is not an issue. Thanks for sharing the PR. Having non-numeric discrete distributions would be really nice for many applications. I'm happy to open a PR on the Turing side once your generalisation is in Distributions.jl. Please keep me in the loop. |
Will do. |
Did this ever materialize and left open or was it perhaps downprioritized? Just curious as i think the spike and slab prior is an interesting and useful beast. 😊 |
I was very keen on the JuliaStats/Distributions.jl PRs that might have helped enable it, but after a few months I ran out of time and it seemed that no-one really wanted to merge it anyway, so I gave up (the final version was JuliaStats/Distributions.jl#951 fwiw). I'd love to have it merged, or this worked on independently of that PR... |
I feel this is better done in another package, e.g. Distributions. |
@yebai - in the unlikely event that I have time to take this back up again in Distributions.jl, it would be good to know what actually needs to be implemented for this to work inside Turing.jl... is there a specification anywhere? I know I knew this a couple of years ago, but I'd just like to get myself back up to date... |
thanks, @richardreeve for the message. Turing is compatible with Distributions API, so there is nothing to do from the Turing side! |
This is supported by Distributions nowadays, e.g. However, unfortunately multiple (fallback) definitions still incorrectly assume that the support of |
It might be a good idea to add a slab-and-spike prior into Turing.
Currently, user can only do the following:
In this case the user would have to use SMC, PG or a combination of PG and HMC/NUTS. A custom distribution would allow users to use HMC only, which would be a good feature. Something like:
I should have a look how this is handled in Stan link.
The text was updated successfully, but these errors were encountered: