Thank you both for your answers.

Borrowing the ODE example from the stan documentation, I have an ODE system with two time dependent parameters to be inferred. I just assume a normal prior over the parameters theta. I have changed the code as below but cannot make it work:

functions {

real[] sho(real t,

real[] y,

real[] theta,

real[] x_r,

int[] x_i) {

real dydt[2];

dydt[1] = y[2];

dydt[2] = -theta[1:t]*y[1] - theta[(t+1):(2*t)]* y[2];

return dydt;

}

}

data {

int<lower=1> T;

real y[T,2];

real t0;

real ts[T];

}

transformed data {

real x_r[0];

int x_i[0];

}

parameters {

real y0[2];

vector<lower=0>[2] sigma;

real theta[2,T];

real a[T];

real b[T];

}

model {

real y_hat[T];

sigma ~ cauchy(0, 2.5);

a ~ normal(0, 1);

b ~ normal(0, 1);

y0 ~ normal(0, 1);

theta[1:T] = a;

theta[T+1:2*T] = b;

y_hat = integrate_ode_rk45(sho, y0, t0, ts, theta, x_r, x_i);

for (t in 1:T)

y[t] ~ normal(y_hat[t], sigma);

}

I know my syntax is wrong but was hoping that you can point me to the correct solution.