transforms vector with unique coskewness or cokurtosis elements to the full coskewness and cokurtosis matrix. Also works in the reverse direction by extracting the unique coskewness and cokurtosis elements from full the coskewness or cokurtosis matrices.
M3.vec2mat(M3, p)
M3.mat2vec(M3)
M4.vec2mat(M4, p)
M4.mat2vec(M4)matrix of dimension p x p^2, or a vector with (p * (p + 1) * (p + 2) / 6) unique coskewness elements
number of variables; the number of instruments for which the coskewness or cokurtosis matrix/vector was computed
matrix of dimension p x p^3, or a vector with (p * (p + 1) * (p + 2) * (p + 3) / 12) unique coskewness elements
For documentation on the coskewness and cokurtosis matrices, we refer to ?CoMoments. Both the full matrices and reduced form can be the output of M3.MM and M4.MM, depending on the optional argument as.mat.
data(managers)
p <- ncol(edhec)
# transform coskewness between matrix and vector format
m3 <- M3.MM(edhec, as.mat=TRUE)
m3bis <- M3.vec2mat(M3.MM(edhec, as.mat=FALSE), p)
sum((m3 - m3bis)^2)
#> [1] 0
# transform cokurtosis between matrix and vector format
m4 <- M4.MM(edhec, as.mat=FALSE)
m4bis <- M4.mat2vec(M4.MM(edhec, as.mat=TRUE))
sum((m4 - m4bis)^2)
#> [1] 0