Hi everybody.
I a new in using Stan. I searched in the FAQ but did not find a solution for my problem.
My model is not very complicated, but I have an error I do not understand. In my model block, when I specify the likelihood, it seems that the binomial function requires a real. The delta parameter is for me a vector of real numbers, so I do not understand the problem.
data {
int<lower=1> N;
vector[N] n0;
vector[N] n;
}
// The parameters of the model.
parameters {
vector<lower=0>[N] lambda;
}
// Transformed parameters. Here theta and delta calculated from lambda
transformed parameters {
vector[N] theta;
vector[N] delta;
theta = cumulative_sum(lambda);
delta = exp(-theta);
}
// The model to be estimated.
model {
vector[N] logitlambda;
real temp;
logitlambda = logit(lambda);
// prior
for (i in 1:61){
logitlambda[i] ~ normal(0, 1000);
}
temp ~ normal(0, 1000);
for (i in 62:N){
logitlambda[i] = temp;
}
// likelihood
for (i in 1:N){
n0[i] ~ binomial(n[i], delta[i]); // here the error, with the index i of delta underlined with a tilde
}
}
Should I use an array instead of a vector for delta? But I think it would be less efficient.
I also tried to replace the loop of the likelihood by
n0 ~ binomial(n,delta);
``
But I still have the same error with delta underlined.
Any help would be appreciated.