When solving the code below, I get the following error message:
Ill-typed arguments supplied to function ‘ode_bdf_tol’. Expected arguments:
(real, vector) => vector, vector, real, real[], real, real, int
Instead supplied arguments of incompatible type:
(real, vector, vector, vector, vector) => vector[], vector, real, real[], vector, vector, vector
I do not know why since in the function of model3 I do not have any real parameters or int, why is the program expecting something different? And why on the left-hand side I can see that is also expecting a real and a vector?
functions {
vector [] model3(real t, vector y, vector pAB, vector uAB, vector uASC) {
vector[rows(y)] dAB_dt = pAB*y[2]-uAB*y[1];
vector[rows(y)] dASC_dt = -uASC*y[2];
vector[rows(y)] out[2];
out = {dAB_dt, dASC_dt};
return (out);
}
}
data {
int <lower=1> nobs;
real t0;
vector[2] y0;
array[nobs] real ts;
int <lower=1> indivs;
array[nobs] real antib;
real <lower=1, upper=indivs> subj[nobs];
}
parameters {
real <lower=0> pAB0;
real <lower=0> uAB0;
real <lower=0> uASC0;
real <lower=0> sigma;
vector[indivs] rpAB;
vector[indivs] ruAB;
vector[indivs] ruASC;
}
transformed parameters {
vector[indivs] pAB;
pAB = pAB0*rpAB;
vector[indivs] uAB;
uAB = uAB0*ruAB;
vector[indivs] uASC;
uASC = uASC0*ruASC;
vector[nobs] yhat[2] = ode_bdf_tol(model3, y0, t0, ts, pAB, uAB, uASC);
}
model {
rpAB ~ lognormal(-2, sqrt(4));
ruAB ~ lognormal(-1, sqrt(2));
ruASC ~ lognormal(-0.1, 0.44);
sigma ~ normal(0, 1);
//for (i in 1:nobs) {
//antib[i] ~ lognormal(yhat[i,1], sigma);
//}
antib ~ lognormal(log(yhat[ : , 2]), sigma);
}
generated quantities {
array[nobs] real z_pred;
for (j in 1:nobs) {
z_pred[j] = lognormal_rng(log(yhat[j,2]), sigma);
}
}