Posterior predictive simulation by subgroup

The way to do this in Stan is lump the data from all five things into one vector and then include an array of integers indicating which group the elements of the vector correspond to.

So you might original have:

vector[2] v1 = [ 1.0, 2.0 ]';
vector[2] v2 = [ 3.0, 4.0 ]';

And you can recode that like:

vector[4] v12 = [ 1.0, 2.0, 3.0, 4.0 ]';
int group[4] = { 1, 1, 2, 2 };

So like the first two elements of v12 belong to group 1 and the next two to group 2.

You can also do a ragged array sorta encoding, where again you store things in one big vector but instead of having an array of which value belongs to which thing you write down the start position of each group (this requires that your values be organized in groups and not scattered randomly).

Example here: Binomial_lpmf: Probability parameter[1] is 1, but must be in the interval [0, 1] - #12 by bbbales2 , and docs here: 8.2 Ragged Data Structures | Stan User’s Guide