Hey,

I am currently trying to fit a system of differential equations to some data using Stan. I am pretty sure that the model should be able to describe the data properly but my model only works sometimes, meaning I can not run it with multiple chains at all because there I always get the error message that the E-BFMI is zero for at least one chain. Running it with only one chain gives me sometimes a fit and sometimes the same error message. If I get a fit it looks very good but my problem is that it does not work all the time and I do not understand why that is the case.

I am using Pystan and the system of differential equations I am trying to fit looks like that:

\frac{dT_C}{dt} = -k_1 T_C + k_2 T_P

\frac{dT_P}{dt} = k_1 T_C - k_2 T_P - V_M T_P

The stan model I am using is the following

```
functions {
real[] sho(real t,
real[] y,
real[] theta,
real[] x_r,
int[] x_i) {
real T_C = y[1];
real T_P = y[2];
real k_1 = theta[1];
real k_2 = theta[2];
real V_M = theta[3];
real dydt[2];
dydt[1] = -k_1*T_C + k_2*T_P;
dydt[2] = k_1*T_C - k_2*T_P - V_M*T_P;
return dydt;
}
}
data {
int<lower=1> T;
int<lower=1> D;
int<lower=1> K;
real y[K,T];
real t0;
real y0[K,2];
real ts[T];
real parameters_log[D];
real std_log[D];
real volume_init[2];
real volume;
}
transformed data {
real x_r[0];
int x_i[0];
}
parameters {
real<lower=0> sigma;
real<lower=0> theta[4];
}
model {
real y_hat_log[T,2];
real y_hat_log_volume[T];
sigma ~ normal(0.08, 0.01);
for (d in 1:D){
theta[d] ~ lognormal(parameters_log[d], std_log[d]);
}
for (k in 1:K){
y_hat_log = integrate_ode_rk45(sho, y0[k], t0, ts, theta, x_r, x_i);
for (t in 1:T){
y_hat_log_volume[t] = y_hat_log[t, 1]/theta[4];
}
for (t in 1:T){
y[k,t] ~ normal(y_hat_log_volume[t], sigma*sqrt(y_hat_log_volume[t]^2));
}
}
}
```

The data I am trying to describe looks like that. I am fitting all of them at the same time to get one set of parameters our. Doing one indiviually gives me the same error as when I am doing them all at the same time.

It would be very nice if someone maybe has an idea how I could get this better to run or maybe sees an error I am not seeing at the moment.

Best regards,

akkarin09