mrc-ide / drjacoby

Flexible Markov chain monte carlo via reparameterization
https://mrc-ide.github.io/drjacoby/
Other
12 stars 5 forks source link

Correlated proposals #104

Open bobverity opened 2 years ago

bobverity commented 2 years ago

Because we work in transformed parameter space (-Inf to Inf for all parameters) we can easily handle proposals from multivariate normal distribution with correlations. These correlations are typically calcualted during the burn-in from the parameter draws. However, this can create a circularity problem in which poor mixing initially causes the MCMC to tune to the wrong place, and then get worse subsequently. Look into this to see if there are simple fixes that can be implemented that improve inference for correlated parameters while avoiding pitfalls.

cwhittaker1000 commented 1 year ago

Just re-upping this, as @pwinskill and I were chatting at ASTMH about the possibility of this and what a cool addition to drjacoby it could be!

Let me know if/how I could potentially help. I've had good experiences in the past using the algorithm from Johnstone-Chang et al (see here, particularly the SI for a detailed description of the algorithm, happy to write up a toy MH-sampler showcasing it if helpful) - broadly does what you describe above except that after initial calculation of the empirical covariance matrix following burn-in, it then iteratively adapts that covariance matrix over time to achieve a desired (pre-specified) acceptance ratio; with the degree of adaptation between each proposal declining over time (so that you eventually end up with a fixed, tuned covariance matrix).

(Very possible this type of covariance adaptation might not play all that well with tempering. If that is the case, could potentially be an option only available to the user when running with a single rung.)

pwinskill commented 1 year ago

@bobverity - how do you feel about the an implmentation whereby correlated proposals were an option only if PT was not being used (1 rung)? This is probably a more generic question regarding future dev options reflecting how the use case for DrJ has evolved (i.e. starting as a specific package to champion PT, but proving to be a very useful package to run vanilla MCMC)

bobverity commented 1 year ago

Thanks for picking this up @cwhittaker1000. I think this could potentially be a useful feature to deal with some relatively simple problems in which there is clearly high and close to linear correlation. Obviously more complex correlation structures and shapes will not really be dealt with by this. What I can't work out is if there are cases where this would actually make things worse? I think not significantly. The problems I had were all around getting everything to converge together reliably, but if you can fix that then great. @pwinskill my preference would be to have this as an option that can be turned on or off, and then would apply over all rungs. So could be used without PT, but we can also explore with PT.

pwinskill commented 1 year ago

@cwhittaker1000 - just to flag, as we propose in transformed space (all parameters are transformed to be on the real line) we currently adjust for this individually for each parameter. With the correlated proposals you have to do a "joint" adjustment - The Jacobian transformation, which adds a little bit of complexity