Subset two non-consective columns of a Matrix

I have a nx7 matrix in stan. I need to access the 1st and 7th column if a condition is met, but access the 2nd-7th columns under another condition. I am basically running a regression model like a seemingly unrelated regression but some of the terms are irrelevant for the sub regressions. In R I would do this with mat[,c(1,7)] but how would I do that in stan?


data {
  matrix[m,n] M; 
} 
1 Like

Could you use M[{1, 7}] ? Iirc, you can’t, but I couldn’t find it in the docs in my cursory glance.

If not, then in transformed data, just add

int my_subset[2] = {1,7};

Then later:

... M[my_subset] ...
1 Like