Weibull regression failed to converge in Rstan

273 views
Skip to first unread message

Yuxin Chen

unread,
Mar 3, 2015, 10:27:44 PM3/3/15
to stan-users

Dear Stan Users,


I built a weibull model in RStan 2.6.0 to do tree survival analysis but got a convergence issue. Can anyone please spare some time to help me out?


I have tried to run it both with simulated data and a subset of my full dataset (e.g. 1/4), the chains converged well under these situations. But when I ran it with the full dataset or with larger subset data (e.g. 1/2), the chains got crazy and I could never see the trend for convergence after running for about 200,000 iterations. I couldn’t figure out the reasons for bad mixing since they did work well both in simulated data and small subset data.


I attached my stan model on this email. Is there something wrong or inappropriate in my stan code?


Thanks,

Yuxin 

weibull_fd_stan_0303.stan

Bob Carpenter

unread,
Mar 4, 2015, 2:03:14 AM3/4/15
to stan-...@googlegroups.com
You want better priors for a start. We have a few sections in
the regression chapter of the book, which summarize some of
Andrew's papers on the topic which provide more info on why
things like gamma(0.001,0.001) are so bad.

You may also need to reparameterize some of this in order
to get efficiency.

I don't see anything intrinsically wrong with the model, but
it's rather dense reading.

One thing to do (after trimming the 200K iterations down to
something reasonable) is to do a pairs plot to see if there
are lots of correlations among variables, as they can indicate
non-identifiability. The other thing I'd recommend is
lowering the initial step size and the target acceptance
rate --- both of these can make the sampler more stable.
Are you getting warning messages now?

The other thing to do is insert print statements to see if
some of the calculations are underflowing or overflowing
or otherwise arithmetically unstable --- this can happen in larger
data sets even if smaller ones are OK.

- 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.
> For more options, visit https://groups.google.com/d/optout.
> <weibull_fd_stan_0303.stan>

Krzysztof Sakrejda

unread,
Mar 4, 2015, 6:02:47 AM3/4/15
to stan-...@googlegroups.com
I've had a similar experience with a different Weibull model, but I think the problem is more general than the Weibull model.  In my case subsetting the data worked well but with the full data most chains would give a much broader posterior (restricted mostly by the prior) .  Sometimes one out of ten chains would find the true posterior which was very narrow.  My understanding is that in the failed cases Stan adapted to exploring the much broader space and managed to skip over the true, very sharp, peak in the posterior.  Decreasing the initial step size helped but without good starting values it was still unreliable.  Optimization (I recall) had a similar problem though it was more likely to complain of numerical issues.

I resolved it by running a series of models with increasing amounts of data.  For more complex models this required doing stratified subsets of the data to make sure each group had enough data to be estimated.  I ended up using something like a series of three or four models, each with an increasing amount of data, and always took the inital values from samples of a previous model.  I think the same could be achieved by raising the posterior to a power during adaptation but adaptation is hairy enough as it is so I never got around to messing with it. 

On a side-note, this issue goes away if your model is complex enough in the right way---that is you spread out that data over enough parameters.

Hope that helps,

Krzysztof


Andrew Gelman

unread,
Mar 4, 2015, 4:37:52 PM3/4/15
to stan-...@googlegroups.com
Just a reminder: once you add informative priors, you might well have to set the inits to reasonable values so Stan doesn’t get lost in the warmup phase.
Reply all
Reply to author
Forward
0 new messages