Vector and vector half operators
vector.RdThe vec (vector) operator takes a \(d \times d\) matrix and stacks the columns into a single vector of length \(d^2\). The vech (vector half) operator takes a symmetric \(d \times d\) matrix and stacks the lower triangular half into a single vector of length \(d(d+1)/2\). The functions invvec and invvech are the inverses of vec and vech i.e. they form matrices from vectors.
References
Magnus, J.R. & Neudecker H.M. (2007) Matrix Differential Calculus with Applications in Statistics and Econometrics (3rd edition), Wiley & Sons. Chichester.
Examples
x <- matrix(1:9, nrow=3, ncol=3)
vec(x)
#> [1] 1 2 3 4 5 6 7 8 9
invvec(vec(x))
#> [,1] [,2] [,3]
#> [1,] 1 4 7
#> [2,] 2 5 8
#> [3,] 3 6 9