I am working on implementing a model which uses a precision matrix specification for a multivariate normal model. In this model the precision matrix is tridiagonal. In R, I use the following code to generate the precision matrix once I have calculated the diagonals.
diag(prec)[par_seq_1]<-prec_diag
diag(prec[,-1])<-prec_sdiag
diag(prec[-1,])<-prec_sdiag
Is there an equivalent function to replicate this in stan? I’ve looked at the diagonal matrix functions and slicing but wasn’t sure if there is a similar functionality.
If not, would it be best to implement this with a loop?