I am trying to write a function that does simple aggregation by group.
Suppose I have two variables, groupid and values:
The output I want is 2x1 vector,
Is there any easy way to go about this?
Are you trying to do this in Stan? It’s easy to work on rows or columns by slicing in Stan, but I’m not sure what 9 and 7 are supposed to represent. In general, if you have two variables:
array[N] int x;
array[N] int y;
vector = [foo(x), bar(y)]';
bar are the functions to apply to