Substracting vector arrays

Hi everyone,

Perhaps a silly question, but I have two vector arrays:

array[N] vector[2] X; 
array[N] vector[2] Y; 

I want to subtract the vectors of observations within X from the vectors of observations in Y and assign them to a another array Z like this for subsequent use:

array[N] vector[2]  Z  = X - Y;

However, I am getting an infix error: “Ill-typed arguments supplied to infix operator -.”. What would be the best approach to solve this and derive the vectors within Z, as for instance Z[1]?

Thanks in advance!

You have to loop over the arrays:

array[N] vector[2]  Z;

for (n in 1:N) {
  Z[n] = X[n] - Y[n];
}