Dear
Stan-folks,
I've been tinkering at some code for a non-linear regression model (which I have
posted about before), and have gotten stuck with horribly
mixing chains. This problem has appeared since I upgraded to rstan 2.1.0 and
2.2.0.
Sometime in August 2013, I got the model running successfully and managed to
fit it to a dataset with the latest version of rstan available then (can't tell
the version from what I've saved). Back then, not all distributions had yet
been vectorized, so upon the release of rstan 2.1.0 I thought I might try and
vectorize everything and see if things would speed up. Coding up the
vectorization was no problem, but as it turned out, since rstan 2.1.0 (I've
tried 2.2.0 as well) the sampler simply does not seem to converge to the right mode
anymore, churns out a handfull of effective sample sizes (N < 20) no matter
how much brute force applied, and is v e r y slow at
sampling. When sequentially sampling multiple chains, upon completion of the
first chain, R sometimes even freezes completely (even with as few as 1K
iterations). Reverting back to the unvectorized code did not change these
findings. I have also tried implementing the "Matt trick" for the
log-normally distributed random effects (defining unbounded raw random effects,
sampling these from standard normal distribution, and transforming these in the
transformed parameters block into lognormally distributed random effects - no
correction for posterior curvature required, right?) - the sampler either
slowed down to a grinding halt, or spitted out an endless stream of red
Metropolis rejections.
Anyhow, to start afresh, I've coded up a script that simulates data such as the
model would predict it, and I have tried to fit the model to these simulated
data. The result remains horrible mixing. Any advice that you may have would be
highly appreciated. I'm about to bash my head into a wall. For your
convenience, I've attached:
And via google drive:
Big fat thank you in advance to anyone who wants to chip in.
Luc
P.s.: I'm working Mac OSX 10.7.5, R 3.0.2, rstan 2.2.0, Rcpp 0.10.6
sysname "Darwin", release "11.4.2", version "Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64"
In response to Michaels' q's:
Thanks for thinking with me!
Luc
Interestingly, rstan v2.2.0 does seem to manage when I give it the stan-fit S4 object from v1.3.0 to work with (rather than compiling the model in v2.2.0).
So in v2.2, it would recompile
On Tue, Feb 18, 2014 at 9:12 PM, Jiqiang Guo <guo...@gmail.com> wrote:
So in v2.2, it would recompile
I meant to say it would NOT ...
Took me a while to understand what you said, but it makes sense to me now. I assume that iterations that fail after a single leapfrog step are reflected by treedepth = 0, or is it -1?
The funky tail business can be explained by the cyclical pattern in the regression line. You could theoretically shift the regression line by one period and scale it by the reproduction factor so that it still fits the data. I tried to anchor the model to prevent this (by making sure that the log CDF would be close to -Inf for unlikely values), but apparently this now backfires with the mass matrix no longer being normalized. I guess another way to do it would be to truncate some of the distributions; there is reasonable prior knowledge of what the parameter values should(n't) be and maybe I just wasn't telling it very well to the model :).