I have a model, for which some parameters can be updated using the Gibbs sampler, but others require the MH sampler.
How can I add or combine a Metropolis-Hastings step with an existing JAGS model (which uses the Gibbs sampler)? (Or do I have to manually write the full MCMC algorithm in R?)
If you have any working example that would be great?
P.S. I can send you my existing model if that helps.
I'm not sure that this is possible. JAGS will use MH updates for certain types of parameters (eg multivariate Gaussian, where the parameters are blocked together) but you can't add an MH step on to the model in parts that you specify or in general.
On the other hand, so long as you can specify your parameters through a series of conditional relationships then you can do Gibbs sampling. By "require", do you mean that MH is mandatory or that Gibbs sampling is slow?
You don't really have control over the sampling methods used by JAGS. You definee the model and JAGS chooses (hopefully) the most efficient sampling method among those available. Like BUGS, it is supposed to be a black box.
Thanks Martyn, Velocidex
Thanks for your responses.
I'm assigning a prior distribution to each element of a constrained covariance matrix, where one or more elements are fixed. In this case, I cannot draw directly from a inverse Wishart. Obviously, for each iteration when drawing values for each element, we need to make sure these values result into a positive definite matrix. I would like to add an extra step to the sampler to check the matrix is positive definite (if not, re-draw values). How could I pursue this?