Append multiple vectors with append_row in generated quantities

I have what I assume to be a simple question about the Stan language and the use of append_row in generated quantities. Basically, I have three separate vectors, dubbed X and Y and Z. I need to combine them into a single, longer vector.

Similar to rbind, the append_row[] function works great for this when there are only two objects. However, an error message occurs when trying to append three (or more) vectors simultaneously, as in:

generated quantities {
vector[N] FINAL;
FINAL = append_row[X, Y, Z];
} 

Is there a straightforward way to do this?

Perhaps append_row(X, append_row(Y, Z))?

Thanks, @mcol. That’s a good solution … except that instead of 3 vectors, it’s actually more like 35 (I kept things simple for the example).

In principle, I could string together 34 append_rows in the generated quantities, but it would be ideal if there were a function that could do this more easily.

I see… Well, all append_row functions only accept two arguments:

I can think of two alternative approaches:

  1. Write a for loop or specialized function to do the appending manually in the generated quantities (which may be ok if all vectors have the same size, but a nightmare if they don’t).

  2. Give these vectors the same prefix, so that after sampling you can extract them in R/python/whatever with a regular expression as a single matrix. This would be my option of choice, as it doesn’t store duplicate data in the stanfit object, and extraction is trivial.