Here is a model that causes hangs such that even CTRL-C won’t stop it. I’m in R 3.2.1 and rstan 2.16.2 on ubunutu. Adding the print statement allow CTRL-C to work (and prints mu alternatively as 3.3 and -nan).
library(rstan)
rstan_options(auto_write = TRUE)
modelcode <- "
data {
}
transformed data {
}
parameters {
real<lower=3.3,upper=3.5> mu;
}
model {
target += 1/(mu-3.3);
//print(mu);
}
"
fit <- stan(model_code=modelcode, data=list(), iter=1000, thin=10, chains=1)
print(fit)
How many is “many times” :)? I’ve held it down for a few minutes and it doesn’t catch (whereas the print will print out many times a second). I’ve also had a sampler in this state gobble lots of memory in /tmp, although the example that I posted doesn’t seem to (I’ll try to make one that does).
model {
y ~ uniform(1,2);
target += y/(mu-3.3);
//print(mu);
}
The stan display hangs after this and doesn’t seem to respond to CTRL-C:
Gradient evaluation took 1.4e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.14 seconds.
Adjust your expectations accordingly!
Oh I see, in /tmp it outputs this message into a file (but seemingly infinitely):
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: uniform_lpdf: Random variable is -nan, but must not be nan! (in ‘model20e5abb126_fba77484d34fca647ce617c1c39ac9ec’ at line 14)