I want to use the function ‘diag_matrix’ to create a diagonal matrix by indexing one row from a matrix, for example, I have a matrix
and I want to create n diagonal matrix (with a dimension of p*p) that uses each row of the matrix X as diagonal entries for computing such as for i in (1:n)
diag_matrix(X [i,]) ;
but it seems the stan did not allow the above syntax. Anyway to solve this? Thanks!