matrix-op | R Documentation |
vech and other matrix operators
vech(A)
vech2mat(v)
duplicationMatrix(n)
tr(x)
blockDiag(...)
A |
a (symmetric) square numeric matrix. |
v |
a numeric vector such that |
n |
a positive integer number; default is |
x |
a square numeric matrix. |
... |
an abitrary numer of matrices or objects coercible into matrices. |
a vector in case of vech
, a scalar in case of tr
,
otherwise a matrix.
For a square matrix A
, vech(A)
returns the vector formed
by the lower triangular portion of the matrix, including the diagonal;
usually, this only makes sense for a symmetric matrix of numeric values.
If v=vech(M)
where M
is a symmetric numeric matrix,
vech2mat(v)
performs the inverse operation and returns the original
matrix M
; this explain the requirement on length(v)
.
For a positive integer n
, D=duplicationMatrix(n)
is a matrix
of dimension (n^2, n*(n+1)/2)
such that D %*% vech(M)
returns
the vec
-form of a symmetric matrix M
of
order n
, that is, the vector which stacks the columns of M
;
for more information, see Section 3.8 of Magnus and Neudecker (1988).
For a square numeric matrix x
, tr(x)
returns its trace.
blockDiag(...)
creates a block-diagonal matrix from a set of matrices
or objects coercible into matrices. Generally, this is useful only for
numeric objects.
Adelchi Azzalini;
the original Octave code of duplicationMatrix
is by Kurt Hornik.
Magnus, Jan R. and Neudecker, Heinz (1988). Matrix differential calculus with application in statistics and econometrics. Wiley series in probability and statistics.
M <- toeplitz(1:4)
v <- vech(M)
vech2mat(v) - M
D <- duplicationMatrix(ncol(M))
# D %*% vech(M) - as.vector(M), must be a one-column matrix of 0s
tr(outer(1:4,2:5))
blockDiag(M[1:2,], 1:2, diag(5:6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.