Identifying causes of divergences

74 views
Skip to first unread message

David J. Harris

unread,
May 3, 2017, 10:45:47 AM5/3/17
to Stan users mailing list
Hi all, I was hoping you could help me with a question about divergences.

My understanding (from the "Brief Guide to Stan's Warnings" and the manual's section on "Diagnosing and Eliminating Divergences") is that, when divergences occur, experienced HMC operators can often figure out which parameters are to blame from model diagnostics and "pairs" plots. My question is, what are we looking for? 

Do we just look for funnel shapes, or is there more? Do the XY coordinates of the red points in the pairs plot tell us anything? If the number of parameters is large (and the number of parameter pairs is even larger), are there ways to narrow down the search space? 

Sorry if this is written down somewhere and I just missed it!

Thanks in advance,

Dave

Ole Petter Hansen

unread,
May 4, 2017, 6:47:56 AM5/4/17
to Stan users mailing list

Hi, 

I'm sure the developers have better answers for you, but here is two general steps I might use:
- Build models from something simple (that works), and add complexity. Chances are you will identify the step where the added complexity gives you problems, and you can from there think of ways to overcome the divergences. 
- Along a similar vein is to estimate your full model, but using tight priors - maybe even "unreasonably" tight - and then slacken them one at the time. E.g. you might find that estimated covariance matrices give you divergences with too uninformative priors. 

Finally, make sure you use the recommended functions and transformations as opposed to writing things yourself (example: not ln( theta*exp(l1) + (1-theta)exp(l2)). Use the built in log_mix(theta, lp1,lp2). 

best,
Ole-Petter

Bob Carpenter

unread,
May 4, 2017, 2:40:13 PM5/4/17
to stan-...@googlegroups.com
You're looking for where the divergences happen. Are
they in the neck of a funnel? Are you getting a banana-shaped
posterior (multiplicative non-identifiability) or long narrow
ridges (additive non-identifiability). Are all the errors showing
up on a boundary of parameter space?

What you're looking for ideally is a posterior that is independent
standard normal in every dimension. Reparameterization can help with
independence and standardization can help with the scaling.

And I'll second Ole Petter Hansen's general advice on starting
simple and building up. You can use our built-ins, which sometimes
give you more arithmetic stability---sometimes the cause is
floating-point arithmetic, not the model itself per se.

- Bob
> --
> 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.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David J. Harris

unread,
May 4, 2017, 4:25:27 PM5/4/17
to Stan users mailing list
Thanks both!

To clarify, Bob, when you say that I'm looking for "where" they happen, does
this refer to their xy coordinates in the pairs plot, or to something else?

Thanks again,

Dave

Andrew Gelman

unread,
May 4, 2017, 4:55:15 PM5/4/17
to stan-...@googlegroups.com
Do we have a case study illustrating good practice in such a situation?

Bob Carpenter

unread,
May 4, 2017, 5:00:10 PM5/4/17
to stan-...@googlegroups.com
To their position in N-dimensional parameter space. The
only good way we have to look at that is with pairs plots or
three-way plots in ShinyStan.

- Bob
Reply all
Reply to author
Forward
0 new messages