Metropolis Hastings in Stan?

380 views
Skip to first unread message

Andrew Gelman

unread,
Mar 21, 2014, 10:29:44 AM3/21/14
to Weber, Sebastian, stan...@googlegroups.com
Hi, Sebastian.   We discussed this at the Stan meeting and the sense is that this is doable, that the best way to do this will be for the user to supply a covariance matrix for the Metropolis jumping kernel (with an identity matrix as the default) and then Stan-Metropolis would autotune the scale of the matrix to a 0.234 acceptance rate.  It would be too much of an effort to auto-tune the entire covariance matrix (because of the possibility of introducing instability) but it should be no problem to adapt a single scalar multiplier.  The user could then do more tuning as desired by simply calling Stan-Metropolis more than once (e.g., running it a the default cov matrix, then using the simulations thus far as a scaling matrix for the next step).  According to Bob, we pretty much already have Metrop implemented within Stan, so if someone wants to implement the scalar auto-tuning and do all the testing, I guess it would be good to go.
A

On Mar 20, 2014, at 4:55 PM, Weber, Sebastian <sebasti...@novartis.com> wrote:

Hi!
 
I have no clue on how to optimize this. But having Metropolis Hastings in Stan would make it simple to compare the performance of HMC to what is the defacto standard so far. However, the best and most convincing comparison would be some sort of integration with the best performing Metropolis Hastings software out there. I mean with this I want to show how bad Hastings is and using a known to be good engine for that is certainly a good trust building thing to do. Have you thought about translating Stan models to … I don’t know… maybe cppBugs?
 
However, I also agree that our time is better spent in optimizing HMC/NUTS for the sake of getting this even further… (but for selling “why stan” we need this comparison)
 
Best,
Sebastian
 
From: Michael Betancourt [mailto:betan...@gmail.com] 
Sent: Mittwoch, 19. März 2014 14:55
To: Bob Carpenter
Cc: Andrew Gelman; Daniel Lee; Weber, Sebastian
Subject: Re: Metropolos Hastings in Stan?
 
Oh, sorry, missed the "finishing up".
 
I'd be happy if we just implemented the identity proposal covariance -- the others aren't hard to code just hard to automate
and, more importantly, harder to use.

 

On Wed, Mar 19, 2014 at 1:49 PM, Bob Carpenter <ca...@alias-i.com> wrote:


On Mar 19, 2014, at 2:45 PM, Michael Betancourt <betan...@gmail.com> wrote:

> Pretty sure Peter Li already did this in a branch --

Absolutely.  That's what I meant when I said he could "finish it up".

I think it was probably pre-new-command structure.

But even if we can't get adaptation working fully, it'd be nice
to have as a comparison, even if it required specifying the covariance
matrix of the normals from which proposals are made or running for
a really long time during warmup just to see what mixing is after
convergence and adaptation for some models.

- Bob


On Mar 19, 2014, at 2:45 PM, Michael Betancourt <betan...@gmail.com> wrote:

> Pretty sure Peter Li already did this in a branch -- the problem was the tuning which is not going to be immediately solvable any time soon.
>
>
> On Wed, Mar 19, 2014 at 1:41 PM, Bob Carpenter <ca...@alias-i.com> wrote:
> No, we haven't implemented Metropolis yet.  We have some
> preliminary demos, but nothing that'll work out of the box.
> The roadblock we ran into was tuning.  We couldn't even make
> it work for all the BUGS examples.
>
> Do you have any idea how to auto-tune it?
>
> We're also less than motivated because we know it doesn't
> sample well in thekinds of problems we care about, even if
> we could tune proposals better.
>
> Adding Metropolis would be a nice project for someone --- it's
> pretty independent in that it can run from the command line.
> Maybe we can get Peter Li to finish it up this summer.  And it'd
> be nice to have these comparisons on a lot of models.
>
> - Bob
>
> On Mar 19, 2014, at 1:12 PM, Weber, Sebastian <sebasti...@novartis.com> wrote:
>
> > Hi Bob!
> >
> >
> >
> > Just a quick question: Can I run the stan models with metropolis hastings as MCMC engine? I am asking because I would like to get a quick comparison of hwo the model would perform if I were to run it with NONMEM BAYES which implements some form of Metropolis Hastings.
> >
> >
> >
> > I would be happy to show that this algo does not do any good in our application…
> >
> >
> >
> > Best,
> >
> >
> >
> > Sebastian Weber
> >
> > Senior Statistical Methodologist, Novartis Oncology
> >
> > Biometrics and Data Management
> >
> > Novartis Pharma AG
> >
> > Postfach
> >
> > CH-4002 Basel
> >
> > SWITZERLAND
> >
> >
> >
> > Phone    +41 61 3246217
> >
> > Fax         +41 61 6961710
> >
> > sebasti...@novartis.com
> >
> > www.novartis.com
> >
> >
> >
>
>


Bob Carpenter

unread,
Mar 21, 2014, 10:50:00 AM3/21/14
to stan...@googlegroups.com
Peter Li implemented random-walk Metropolis, including diagonal and
full covariance matrix adaptation for the jumping. And I'm guessing
a target acceptance rate for step size.

I'm not sure if it's implemented in a way to make it easy to
drop into command, because that's undergone a major change.

My understanding is that it just wouldn't converge for
the BUGS models. Has anyone ever done this kind of large-scale
random-walk Metropolis test and figured out a good way to
adapt the jumping covariance?

I think I see where Andrew was going with Metropolis-adjusted
Langevin (aka MALA) --- if we do just configure Stan to do
1-step HMC, then the effect is

* randomly generate a normal(0,1) momentum

* take 1 leapfrog step in direction of momentum over mass
(step size = time)

That's like taking a normal(0,Sigma) random walk step if step size = 1,
right?

Then we could use Stan to adapt step size to a fixed target
acceptance probability (already implemented), and to estimate
a diagonal or dense mass matrix (or we could set to diagonal).
That's all implemented.

What we still need to do is implement inputs for a diagonal or
full mass matrix, and then you can basically specify a random-walk
Metropolis with normal jumps with a given covariance matrix.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ben Goodrich

unread,
Mar 21, 2014, 12:43:34 PM3/21/14
to stan...@googlegroups.com
On Friday, March 21, 2014 10:50:00 AM UTC-4, Bob Carpenter wrote:
My understanding is that it just wouldn't converge for
the BUGS models.  Has anyone ever done this kind of large-scale
random-walk Metropolis test and figured out a good way to
adapt the jumping covariance?

Some of the BUGS models don't converge with NUTS or Gibbs sampling either, but most do. MCMCpack has random-walk Metropolis that by default uses the MLEs plus a diagonal matrix of scaling parameters to jump.

I don't recall anyone on stan-users wanting to compare Metropolis-Hastings to NUTS, usually it is BUGS to NUTS. I did a few comparisons for my class, and you get pictures like this:

https://groups.google.com/d/msg/stan-dev/_SJBiCaUbt4/MblkpLElI4MJ

Ben

Reply all
Reply to author
Forward
0 new messages