BDF solver crashing Stan 2.18 sampler

rstan

#1

I tried re-running an older model in the newest version of stan, and it crashes. After investigating, it seems the stiff solver is no longer working.

Below is a minimal example that can be run (unsuccessfully, because it crashes,) in rstan. Note that if you switch from integrate_ode_bdf to integrate_ode_rk45, it runs successfully - so the issue may not relate to the integrator, but that’s what makes it happen here.

series = seq(0.1,9.2,1)

data_ode=list(T = 10,
y0 = c(1,0),
t0=0,
ts=series
)

scode_bdf <- "
functions {
real[] sho(real t,
real[] y,
real[] theta,
real[] x_r,
int[] x_i) {
real dydt[2];
dydt[1] = y[2];
dydt[2] = -y[1] - theta[1] * y[2];
return dydt;
}
}
data {
int<lower=1> T;
real y0[2];
real t0;
real ts[T];
}

transformed data {
real x_r[0];
int x_i[0];
}
parameters{
real theta[1];
}
model {
theta ~ normal(0.15,0.1);
}
generated quantities {
real y_hat[T,2] = integrate_ode_bdf(sho, y0, t0, ts, theta, x_r, x_i);
// add measurement error
for (t in 1:T) {
y_hat[t, 1] += normal_rng(0, 0.1);
y_hat[t, 2] += normal_rng(0, 0.1);
}
}
"

fit_bdf <- stan(model_code = scode_bdf, data=data_ode, iter = 10000, verbose = FALSE)


#2

Not nice! Can you please file an issue for this on our Stan-math repository? Thanks a lot!


#3

Done;https://github.com/stan-dev/math/issues/552