Stata 15 help for mf_vec

[M-5] vec() -- Stack matrix columns

Syntax

transmorphic colvector vec(transmorphic matrix T)

transmorphic colvector vech(transmorphic matrix T)

transmorphic matrix invvech(transmorphic colvector v)

Description

vec(T) returns T transformed into a column vector with one column stacked onto the next.

vech(T) returns square and typically symmetric matrix T transformed into a column vector; only the lower half of the matrix is recorded.

invvech(v) returns vech()-style column vector v transformed into a symmetric (Hermitian) matrix.

Remarks

Remarks are presented under the following headings:

Example of vec() Example of vech() and invvech()

Example of vec()

: x 1 2 3 +-------------+ 1 | 1 2 3 | 2 | 4 5 6 | +-------------+

: vec(x) 1 +-----+ 1 | 1 | 2 | 4 | 3 | 2 | 4 | 5 | 5 | 3 | 6 | 6 | +-----+

Example of vech() and invvech()

: x [symmetric] 1 2 3 +-------------+ 1 | 1 | 2 | 2 4 | 3 | 3 6 9 | +-------------+

: v = vech(x) : v 1 +-----+ 1 | 1 | 2 | 2 | 3 | 3 | 4 | 4 | 5 | 6 | 6 | 9 | +-----+

: invvech(v) [symmetric] 1 2 3 +-------------+ 1 | 1 | 2 | 2 4 | 3 | 3 6 9 | +-------------+

Conformability

vec(T): T: r x c result: (r*c) x 1

vech(T): T: n x n result: (n*(n+1)/2) x 1

invvech(v): v: (n*(n+1)/2) x 1 result: n x n

Diagnostics

vec(T) cannot fail.

vech(T) aborts with error if T is not square. vech() records only the lower triangle of T; it does not require T be symmetric.

invvech(v) aborts with error if v does not have 0, 1, 3, 6, 10, ... rows.

Source code

vec.mata, vech.mata, invvech.mata


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index