Consider a model with a prior p(\theta) = \alpha \delta(\theta) + (1-\alpha), \theta\in[0,1], where \alpha is a known parameter and \delta is Dirac’s delta, and possibly other unknown parameters as well. The particular form of the likelihood doesn’t matter much here I think.
The goal is to be able to compute expectations w.r.t. the posterior \theta|D.
Are there any tricks to encode this in Stan, or to encode only the continuous part and then somehow combine with the discrete part outside of Stan? All I can come up with requires calculating the total evidence p(D).
If you want to know how a Dirac delta can be encoded in a Stan model there is a HGP example from Stancon 2017 which makes use of the Dirac function here:
Could you perhaps try put it into a Stan model with some example data and point out what isn’t working for you? It’ll make it much easier to help. So far as I can tell the Dirac delta function is actually a valid continuous density distribution so I can’t see what the problem is right now; but perhaps I’m missing something.
Well, the closest pseudocode would be something like
data {
real<lower=0,upper=1> alpha;
...
}
parameters {
real<lower=0,upper=1> theta;
...
}
model {
if (theta == 0)
target += Infinity + log(alpha);
}
It is not; the density is zero almost everywhere and yet it integrates to 1 (hence Infinity above). It can be approximated with a very narrow Gaussian (or in this case Beta), but (1) a fixed approximation means there will be no convergence to the target posterior no matter how many samples you draw, and (2) I’m not sure Stan will handle such a narrow Gaussian well.
In plain English, the prior belief I am trying to express is “there is probability \alpha that p is exactly zero; and with probability 1-\alpha it’s somewhere else in [0,1]”.
Interesting, and so specific . I’d be interested to know how this is solved but don’t have an answer for you . I’ll look into zero-inflated continuous distributions particularly the zero inflated beta distribution given your constraints.