Closed dizyd closed 3 years ago
Hi @dizyd,
The reason why this does not work is that your model contains discrete variables (i.e., the z's). To use bridge sampling in this case, you need to marginalize out the discrete parameters in the log_posterior
function yourself and then remove the z's from the samples object before you pass the samples to the bridge_sampler
function. This is mentioned in our JSS paper (p. 22). One explanation of how to marginalize out the mixture indicator variable can be found here.
Cheers, Quentin
Hello @quentingronau,
thank you very much for your fast response and the references!
Cheers, David
Hello,
first of all thank you for your work and the very helpful package you created. Now to my problem (this might be a pure user-related problem):
I get the following error when I run the
bridge_sampler
function based on samples from JAGS-Model with a latent mixture structure and I am not sure how to fix it:The example model and data I used are
And the
log_posterior()
function is:The problem has to do with the
z
variable, since the functions work when I replaceifelse(z == 1,mu1,mu2)
inlog_posterior()
with e.g.ifelse(sample(c(0,1),0.5) == 1,mu1,mu2)
.I haven't found anything in the manual or other issues regarding this error. I already tried running more samples and chains as recommended in another Issue. Therefore, my question, if you have any idea what I am doing wrong?
The full example script is: