Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

vector

Vector and vector half operators


Description

The vec (vector) operator takes a d x d matrix and stacks the columns into a single vector of length d^2. The vech (vector half) operator takes a symmetric d x 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.

Usage

vec(x, byrow=FALSE)
vech(x)
invvec(x, ncol, nrow, byrow=FALSE)
invvech(x)

Arguments

x

vector or matrix

ncol,nrow

number of columns and rows for inverse of vech

byrow

flag for stacking row-wise or column-wise. Default is FALSE.

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)
invvec(vec(x))

ks

Kernel Smoothing

v1.12.0
GPL-2 | GPL-3
Authors
Tarn Duong [aut, cre], Matt Wand [ctb], Jose Chacon [ctb], Artur Gramacki [ctb]
Initial release
2021-02-06

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.