I’m still feeling uncomfortable about which block variable declarations should be put. For example, I want to create a vector to do element-wise operation in a later loop:
vector[N] Z = A*B
where A is a matrix containing data and parameter and B is a vector containing data. Then I use Z to do element-wise operations in a loop, e.g.
for (i in 1:N){
D[i] = (Y[i] <= Z[i] ? 1:0);
}
Then I received a message that “Variable “vector” does not exist”.
So I wonder where should I put the declaration?