# Ode_rk45 solving for only one time point

Dear all,
I am trying to solve an ODE at one time point T1 in future hence I feed a single value of solution time to the integrator by:
real T1 = times[i];
however I got data type error:

Semantic error in ‘string’, line 48, column 9 to column 51:
Ill-typed arguments supplied to function ‘ode_rk45’. Expected arguments:
(real, vector) => vector, vector, real, real[]
Instead supplied arguments of incompatible type:
(real, vector, vector) => vector, vector, real, real, vector

Then I tried to define an array of length 1 for solution time by this command:
array real T1 = times[i];
but I failed to assign a real value to this array:

Semantic error in ‘string’, line 47, column 4 to column 32:
Ill-typed arguments supplied to assignment operator =: lhs has type real[] and rhs has type real

Here is my stan code:

``````functions{
vector PK3cmt(real t, vector states, vector theta){
real ka = theta;
real CL = theta;
real Vc = theta;
real Q = theta;
real Vp = theta;
real gut = states;
real cent = states;
real peri = states;
vector dif;
dif = - ka * gut;
dif = -ka*gut - ((CL / Vc) + (Q / Vc))*cent + (Q * peri) / Vp;
dif = (Q*cent)/ Vc - (Q*peri)/Vp;
return dif;
}
}
data{
int N;
//vector<lower = 0>[N] time;
array[N] real times;
int evid[N];
int cmt[N];
vector<lower = 0>[N] amt;
int nObs;
int iObs[nObs];
vector<lower=0>[N] cObs;
}
transformed data {
int nTheta = 5;
int nCmt = 3;
}
parameters{
vector[nTheta] theta; //{ka, CL, Vc, Q, Vp}
real<lower = 0> sigma;
}
transformed parameters{
vector[nCmt] U;
U = 0;
U = 0;
U = 0;
array[N] vector traj;
for(i in 1:N){
if (evid[i] == 1) U[cmt[i]] += amt[i];
else {
//real T1 = times[i];   // doesn't work
array real T1 = times[i];  // also doesn't work
U = ode_rk45(PK3cmt, U, times[i-1], T1, theta);
traj[i] = U;
}
}
vector<lower=0>[N] concentrationHat = traj[] ./theta;
}
model{
theta ~ lognormal(log(10), 0.25);
theta ~ lognormal(log(15), 0.5);
theta ~ lognormal(log(35), 0.25);
theta ~ lognormal(log(105), 0.5);
theta ~ lognormal(log(2.5), 1);
sigma ~ normal(0, 1);
cObs ~ lognormal(log(concentrationHat[iObs]), sigma);
}
``````

Any help is apprecaited.
Hassan

This would need to be `array real T1 = {times[i]};`

There seem to be more errors after fixing this, but they seem more related to the structure of your model so it’s less clear to me what solution to recommend

Thanks a lot, it fixed my problem. :)