Learn R Programming

TFORGE (version 0.1.16)

vech: Flatten a symmetric matrix into a vector.

Description

The vech operator as defined by @Section 3.8 @magnus2019maTFORGE flattens symmetric matrices into vectors. Columns are extracted from left to right with entries above the diagonal ignored. The function inv_vech() is the inverse of vech(). The dimension of the matrix can be obtained from its flattened form by dim_vech().

Usage

vech(m, name = FALSE)

inv_vech(x)

dim_vech(x)

Value

vech() returns a vector. inv_vech() returns a matrix. dim_vech() returns an integer.

Arguments

m

A symmetric matrix

name

If TRUE vector elements are named eij where i is the row and j is the column.

x

A flattened symmetric matrix (as a vector).

Details

The extraction is conveniently performed by m[lower.tri(m), diag = TRUE]. The matrix m is not checked for symmetry.

References

Examples

Run this code
m <- inv_vech(1:6)
dim_vech(1:6)
vech(m)

Run the code above in your browser using DataLab