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?
I don’t know what version of RStan started using the new compiler - the old compiler required all variable declarations to come at the beginning of a block - this rather looks like the error message that would have been generated if that were the case.
also note: the variables in the model block are local variables and are not written as part of the output.