I have a question about the viability of using Stan as an implementation of HMC/NUTS for an MCMC kernel - but used in combination with other MCMC kernels that I would like to write myself.
There are a few interesting applications such as:
* a way to handle discrete parameters (i.e. do that bit outside Stan) - although sounds like this will be solved shortly anyway...
* infinite dimensional models.
* applying kernels to annealed distributions e.g. annealed importance sampling
* explicitly using tricks like this: http://andrewgelman.com/2011/10/19/an-interweaving-transformation-strategy-for-boosting-mcmc-efficiency/
On Monday, July 21, 2014 9:40:47 PM UTC-4, david...@gmail.com wrote:I have a question about the viability of using Stan as an implementation of HMC/NUTS for an MCMC kernel - but used in combination with other MCMC kernels that I would like to write myself.
Any kind of an external subroutine would be challenging. For continuous unknowns, at a minimum, you have to get the gradient information from the external subroutine back into the Stan internals, and there is no way to do that except to write custom C++ code.
To clarify here is some code:
library(rstan)
m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}')
f <- sampling(m, iter = 1,chains=1)
for (s in 1:1000) {
f <- sampling(m, iter = 1,chains=1,init=list(list('y'=extract(f)$y[1],'lp__'=extract(f)$lp__[1])))
// apply another kernel to f here (or more likely p(z,f) to update z and pass z back as data.)
// recompute lp__
}
Is this not valid?
--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Aside from the technical difficulties that Ben notes, it’s probably not going to be a goodidea in practice. For example, see the references he noted for why simulated annealing(and simulated importance sampling) do not scale well and why interweaving parameterizationswon’t help much for a proper joint sampler (what good taste in papers, Ben!).
My hope was primarily to deal with models changing dimension and with discrete latent variables... but I put in a couple of other suggestions ... (I agree the annealing bit is particularly questionable)... On the other hand Mark Girolami actually recommends interweaving here: http://www.dcs.gla.ac.uk/publications/PAPERS/9382/tech_rep_lgms.pdf . Iain Murray argues running HMC on the full posterior for latent variable Gaussian process hierarchical models doesn't work so well - but I must admit I don't understand why.
It is fairly common that a published algorithm uses HMC as a kernel in combination with standard Metropolis-Hastings or Gibbs kernels... it would be surprising if this were _never_ a good idea.... It would really be wonderful to be able to use Stan to make the HMC part easier... but it looks like that is at least not easy right now... although I am still a little puzzled as to why...
Thanks again, for the feed back and for Stan!
I certainly defer to you, Girolami and the rest of the Stan team on these issues. From a quick skim of the paper it seems the argument is that centring is only possible under limited circumstances... I agree it is a good paper, and will go back to it when I get the chance... so far I have read Murray's and Filippone's paper - rather than yours. Filippone's paper recommends interweaving using HMC for latent variables and plain old random walk Metropolis for hyperparameters.
Obviously conditional Gibbs sampling or single component Metropolis sampling is a compromise - but its a compromise that has served some of us quite well at times.
I would like to implement the model described here. http://people.ee.duke.edu/~lcarin/PoissonProcess.pdf
It doesn't have to be using their sampler which involves both Metropolis Hastings and HMC steps - and involves trans-dimensional steps - but my first thought was to just use their sampler, and I thought Stan could help with the HMC part - but right now this appears to be not easy.
OTOH If you think it can be completely done in Stan then I would be fascinated!
BTW for reference it seems that you have been over this issue just a few weeks back (sorry) see Krzysztof Sakrejda's post and the responses which gives some detail about why the above doesn't work...
https://groups.google.com/forum/#!topic/stan-users/HBewhdW1u88
Random walk on the hyperparameters isn't going to do anyone any good. Certainly in the worst case HMC reduces to a random walk, so why not just use it in the first place?
Of course any algorithm will work well in some circumstances, but we're (okay, maybe I should just speak for myself) interested in algorithms that work well with great generality,and Gibbs is not going to be that algorithm, especially for modern applied problems.
Thanks for the responses Michael,
I certainly defer to you, Girolami and the rest of the Stan team on these issues. From a quick skim of the paper it seems the argument is that centring is only possible under limited circumstances... I agree it is a good paper, and will go back to it when I get the chance... so far I have read Murray's and Filippone's paper - rather than yours. Filippone's paper recommends interweaving using HMC for latent variables and plain old random walk Metropolis for hyperparameters.
Obviously conditional Gibbs sampling or single component Metropolis sampling is a compromise - but its a compromise that has served some of us quite well at times.
I would like to implement the model described here. http://people.ee.duke.edu/~lcarin/PoissonProcess.pdf
It doesn't have to be using their sampler which involves both Metropolis Hastings and HMC steps - and involves trans-dimensional steps - but my first thought was to just use their sampler, and I thought Stan could help with the HMC part - but right now this appears to be not easy.
OTOH If you think it can be completely done in Stan then I would be fascinated!
BTW for reference it seems that you have been over this issue just a few weeks back (sorry) see Krzysztof Sakrejda's post and the responses which gives some detail about why the above doesn't work...
https://groups.google.com/forum/#!topic/stan-users/HBewhdW1u88
Thanks for your code Krzysztof, I didn't expect this!
It doesn't run out of the box for me, I will try tweaking it to try to work out what you have done.
I hadn't thought about using splines, but it is not clear to me if doing so solves everything. Maybe you can analytically integrate under a non-negative function of them which would change things....
For this model, the likelihood contains the following terms
1 ~ poisson(sigmoid(lambda))
0 ~ poisson(sigmoid(-latent))
lambda is the size of the data set, where latent is of variable size (which is the big problem for Stan I think).
The reason for the use of the 1/0 is that for a point process there is a small number of locations where a single event happens and everywhere else nothing happens - you never evaluate the poisson with a count greater than 1.
it looks to me like you are instead modelling
count[ii] ~ poisson(lambda(ii))
which appears at face value to be a different model. Apologies, in advance if I have misunderstood... Maybe we should talk more about this out of the thread... my email is david...@gmail.com.