Hi, there. I’m a beginner of stan. Now I face a problem and I have no idea to figure it out.
I have a model, looks like:
data{
int<lower=0> N;//number of participants
int<lower=0> T;//number of trials
array[N,T] int<lower=0,upper=1> Z; //participants' choices
array[N,T] real<lower=0> S; //conditions
array[N,T] real<lower=0> O; //conditions
array[N,T] real<lower=0> P; //conditions
}
model {
// omit something unimportant
for (i in 1:N){
real X;
real Y;
for (t in 1:T){
X = alpha[i] * S[i,t] + beta[i] * O[i,t] - gamma[i] * P[i,t];
Y = 0;
Z[i,t] ~ bernoulli_logit(IT[i] * (X-Y));
}
}
}
I want to rewrite these code by using reduce_sum. But I have no idea to solve these nested loop. Is there anyone could give me some advices? Thanks a lot~