duplication_matrix: Duplication Matrix 'D'

Description Usage Arguments Value Examples

View source: R/aux_funs.R

Description

Create a duplication matrix for duplicating entries of a vector. This is particularly useful for converting a vector vech(M) to a vector vec(M), where M is a symmetric matrix. See vec() and vech() and the example below.

Usage

1

Arguments

K

An integer scalar. The number of variables of the VAR(p) system.

Value

A (K^2 x [K^2 + K]/2) selection matrix containing ones and zeros. When multiplied with a vector, it will select entries of that vector to be duplicated.

Examples

1
2
3
4
5
6
7
8
K <- 6

AA <- matrix(1:K^2, K, K)
AA[upper.tri(AA)] <- t(AA)[upper.tri(AA)]

AA

all(vec(AA) == duplication_matrix(K) %*% vech(AA))

nielsaka/zeitreihe documentation built on March 17, 2020, 8:38 p.m.