Duplication matrix
edit
The duplication matrix
D
n
{\displaystyle D_{n}}
is the unique
n
2
×
n
(
n
+
1
)
2
{\displaystyle n^{2}\times {\frac {n(n+1)}{2}}}
matrix which, for any
n
×
n
{\displaystyle n\times n}
symmetric matrix
A
{\displaystyle A}
, transforms
v
e
c
h
(
A
)
{\displaystyle \mathrm {vech} (A)}
into
v
e
c
(
A
)
{\displaystyle \mathrm {vec} (A)}
:
D
n
v
e
c
h
(
A
)
=
v
e
c
(
A
)
{\displaystyle D_{n}\mathrm {vech} (A)=\mathrm {vec} (A)}
.
For the
2
×
2
{\displaystyle 2\times 2}
symmetric matrix
A
=
[
a
b
b
d
]
{\displaystyle A=\left[{\begin{smallmatrix}a&b\\b&d\end{smallmatrix}}\right]}
, this transformation reads
D
n
v
e
c
h
(
A
)
=
v
e
c
(
A
)
⟹
[
1
0
0
0
1
0
0
1
0
0
0
1
]
[
a
b
d
]
=
[
a
b
b
d
]
{\displaystyle D_{n}\mathrm {vech} (A)=\mathrm {vec} (A)\implies {\begin{bmatrix}1&0&0\\0&1&0\\0&1&0\\0&0&1\end{bmatrix}}{\begin{bmatrix}a\\b\\d\end{bmatrix}}={\begin{bmatrix}a\\b\\b\\d\end{bmatrix}}}
The explicit formula for calculating the duplication matrix for a
n
×
n
{\displaystyle n\times n}
matrix is:
D
n
T
=
∑
i
≥
j
u
i
j
(
v
e
c
T
i
j
)
T
{\displaystyle D_{n}^{T}=\sum \limits _{i\geq j}u_{ij}(\mathrm {vec} T_{ij})^{T}}
Where:
u
i
j
{\displaystyle u_{ij}}
is a unit vector of order
1
2
n
(
n
+
1
)
{\displaystyle {\frac {1}{2}}n(n+1)}
having the value
1
{\displaystyle 1}
in the position
(
j
−
1
)
n
+
i
−
1
2
j
(
j
−
1
)
{\displaystyle (j-1)n+i-{\frac {1}{2}}j(j-1)}
and 0 elsewhere;
T
i
j
{\displaystyle T_{ij}}
is a
n
×
n
{\displaystyle n\times n}
matrix with 1 in position
(
i
,
j
)
{\displaystyle (i,j)}
and
(
j
,
i
)
{\displaystyle (j,i)}
and zero elsewhere
Here is a C++ function using Armadillo (C++ library) :
arma :: mat duplication_matrix ( const int & n ) {
arma :: mat out (( n * ( n + 1 )) / 2 , n * n , arma :: fill :: zeros );
for ( int j = 0 ; j < n ; ++ j ) {
for ( int i = j ; i < n ; ++ i ) {
arma :: vec u (( n * ( n + 1 )) / 2 , arma :: fill :: zeros );
u ( j * n + i - (( j + 1 ) * j ) / 2 ) = 1.0 ;
arma :: mat T ( n , n , arma :: fill :: zeros );
T ( i , j ) = 1.0 ;
T ( j , i ) = 1.0 ;
out += u * arma :: trans ( arma :: vectorise ( T ));
}
}
return out . t ();
}
Elimination matrix
edit
An elimination matrix
L
n
{\displaystyle L_{n}}
is a
n
(
n
+
1
)
2
×
n
2
{\displaystyle {\frac {n(n+1)}{2}}\times n^{2}}
matrix which, for any
n
×
n
{\displaystyle n\times n}
matrix
A
{\displaystyle A}
, transforms
v
e
c
(
A
)
{\displaystyle \mathrm {vec} (A)}
into
v
e
c
h
(
A
)
{\displaystyle \mathrm {vech} (A)}
:
L
n
v
e
c
(
A
)
=
v
e
c
h
(
A
)
{\displaystyle L_{n}\mathrm {vec} (A)=\mathrm {vech} (A)}
. [1]
By the explicit (constructive) definition given by Magnus & Neudecker (1980) , the
1
2
n
(
n
+
1
)
{\displaystyle {\frac {1}{2}}n(n+1)}
by
n
2
{\displaystyle n^{2}}
elimination matrix
L
n
{\displaystyle L_{n}}
is given by
L
n
=
∑
i
≥
j
u
i
j
v
e
c
(
E
i
j
)
T
=
∑
i
≥
j
(
u
i
j
⊗
e
j
T
⊗
e
i
T
)
,
{\displaystyle L_{n}=\sum _{i\geq j}u_{ij}\mathrm {vec} (E_{ij})^{T}=\sum _{i\geq j}(u_{ij}\otimes e_{j}^{T}\otimes e_{i}^{T}),}
where
e
i
{\displaystyle e_{i}}
is a unit vector whose
i
{\displaystyle i}
-th element is one and zeros elsewhere, and
E
i
j
=
e
i
e
j
T
{\displaystyle E_{ij}=e_{i}e_{j}^{T}}
.
Here is a C++ function using Armadillo (C++ library) :
arma :: mat elimination_matrix ( const int & n ) {
arma :: mat out (( n * ( n + 1 )) / 2 , n * n , arma :: fill :: zeros );
for ( int j = 0 ; j < n ; ++ j ) {
arma :: rowvec e_j ( n , arma :: fill :: zeros );
e_j ( j ) = 1.0 ;
for ( int i = j ; i < n ; ++ i ) {
arma :: vec u (( n * ( n + 1 )) / 2 , arma :: fill :: zeros );
u ( j * n + i - (( j + 1 ) * j ) / 2 ) = 1.0 ;
arma :: rowvec e_i ( n , arma :: fill :: zeros );
e_i ( i ) = 1.0 ;
out += arma :: kron ( u , arma :: kron ( e_j , e_i ));
}
}
return out ;
}
For the
2
×
2
{\displaystyle 2\times 2}
matrix
A
=
[
a
b
c
d
]
{\displaystyle A=\left[{\begin{smallmatrix}a&b\\c&d\end{smallmatrix}}\right]}
, one choice for this transformation is given by
L
n
v
e
c
(
A
)
=
v
e
c
h
(
A
)
⟹
[
1
0
0
0
0
1
0
0
0
0
0
1
]
[
a
c
b
d
]
=
[
a
c
d
]
{\displaystyle L_{n}\mathrm {vec} (A)=\mathrm {vech} (A)\implies {\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\end{bmatrix}}{\begin{bmatrix}a\\c\\b\\d\end{bmatrix}}={\begin{bmatrix}a\\c\\d\end{bmatrix}}}
.
Notes
edit
References
edit
Magnus, Jan R.; Neudecker, Heinz (1980), "The elimination matrix: some lemmas and applications", SIAM Journal on Algebraic and Discrete Methods , 1 (4): 422–449, doi :10.1137/0601049, ISSN 0196-5212 .
Jan R. Magnus and Heinz Neudecker (1988), Matrix Differential Calculus with Applications in Statistics and Econometrics , Wiley. ISBN 0-471-98633-X.
Jan R. Magnus (1988), Linear Structures , Oxford University Press. ISBN 0-19-520655-X