Helpful Stan Functions
Vectorization operations on matrices

Functions

vector lower_elements (matrix mat)
 

Detailed Description

vector lower_elements(matrix mat) {
int N = rows(mat);
int K = (N * (N - 1)) %/% 2;
vector[K] out;
int count = N;
int pos = 1;
for (k in 1 : N - 1) {
count -= 1;
out[pos : pos + count - 1] = sub_col(mat, k + 1, k, count);
pos += count;
}
return out;
}
vector lower_elements(matrix mat)
Definition: vectorization.stanfunctions:16

Function Documentation

◆ lower_elements()

vector lower_elements ( matrix  mat)

The strictly lower triangular elements of a matrix.

Copyright 2025, Sean Pinkney

Parameters
matMatrix
vectorof lower triangular elements