When I run the following program I get the error: ‘‘Identifier expected after type in top-level variable declaration.’’. This error occurs when I have added the loop in the model and generated the quantities statement. Does somebody know what this exactly means? I do not know which variable is giving the error.
functions {
real[] model3(real t, real[] y, real[] theta,
real[] x_r, int[] x_i){
real AB= y[1];
real ASC = y[2];
real pAB = theta[1];
real uAB = theta[1];
real uASC = theta[3];
real dydt[2];
dydt[1] = pAB*ASC - uAB*AB;
dydt[2] = -uASC*ASC;
return dydt;
}
}
data{
int <lower=0> nobs;
real t0;
real y0[2];
real ts[nobs];
int <lower=1> indivs;
real antib[nobs];
//real <lower=1, upper=indivs> subj[nobs];
}
transformed data{
real x_r[0];
int x_i[0];
}
parameters{
//real <lower=0> AB0;
real <lower=0> pAB;
real <lower=0> uAB;
real <lower=0> uASC;
//real <lower=0> z_init[2];
//real <lower=0> sigmaAB0;
real <lower=0> sigma;
}
transformed parameters{
real yhat[nobs,2];
{
real theta[3];
theta[1] = pAB;
theta[2] = uAB;
theta[3] = uASC;
yhat = integrate_ode_bdf(model3, y0, t0, ts, theta, x_r, x_i);
}
}
model{
pAB ~ lognormal(-2, sqrt(4));
uAB ~ lognormal(-1, sqrt(2));
uASC ~ lognormal(-0.1, 0.44);
//AB0 ~ lognormal(-2, 4);
//sigmaAB0 ~ gamma(0.001, 0.001);
//z_init ~ lognormal(5,1);
sigma ~ normal(0, 1);
for (i in 1:nobs){
antib[i] ~ lognormal(yhat[i,1], sigma);
}
}
generated quantities{
real[nobs] z_pred;
for (j in 1:nobs){
z_pred[j] = lognormal_rng(yhat[j,1], sigma);
}
}
****
Thanks in advance.