vech: Vectorise a symmetric matrix

Description Usage Arguments Value Examples

View source: R/aux_funs.R

Description

Vectorise a symmetric matrix by stacking the elements on its lower triangular matrix including the diagonal.

Usage

1
vech(mat)

Arguments

mat

An (M x M) matrix with arbitrary dimensions M.

Value

A column matrix of dimension (M^2 + M)/2 x 1.

Examples

1
2
3
mat <- matrix(1:8, 4, 4)
mat[upper.tri(mat)] <- t(mat)[upper.tri(mat)]
vech(mat)

nielsaka/zeitreihe documentation built on March 17, 2020, 8:38 p.m.