I’ve been experimenting with Stan recently. I’ve been working in Stan rather than Jags because I’m doing some work on pooling the polls properly — that is, where levels of support are drawn from a multivariate normal distribution jury-rigged so that draws sum to one. That jury-rigging requires a singular covariance matrix, which can’t be inverted to give the precision matrix that Jags needs. (And no, pseudo-inverses don’t work).
Whilst experimenting with Stan, I’ve found out a number of things about simplexes and just how picky Stan is about its covariance matrices being positive definite — but I had thought I was getting places.
Until today. I thought I should start simple, and try and getting a simple univariate poll-pooler going. I busted out the Jackman BASS code, and wrote up a quick implementation in Jags, omitting the house effects.
Now I find that I can’t replicate that in Stan. I can get a model which samples — but it just gives me back my initial values. If I don’t supply initial values, the model won’t initialize. I’ve eliminated the obvious suspects — confusing precision and variance, for example, or dealing with Stan’s inability to handle inputs that are part-missing.
My code (for both Jags and Stan) is at GitHub. Any ideas?
Update: Ben Lauderdale kindly pointed out that Stan uses the standard deviation for the normal, rather than the variance, so I was off by an order of magnitude. He also took a red pen to the code, meaning that the resulting much cleaner code (which is entirely to Ben’s credit if it works efficiently, and entirely my fault insofar as it doesn’t) is now on GitHub.