FoReco (version 0.2.6)

commat: Commutation matrix

Description

This function returns the (r c r c) commutation matrix P such that P vec(Y) = vec(Y'), where Y is a (r c) matrix.

Usage

commat(r, c)

Value

A sparse (r c r c) matrix, P.

Arguments

r

Number of rows of Y.

c

Number of columns of Y.

References

Magnus, J.R., Neudecker, H. (2019), Matrix Differential Calculus with Applications in Statistics and Econometrics, third edition, New York, Wiley, pp. 54-55.

See Also

Other utilities: Cmatrix(), FoReco2ts(), agg_ts(), arrange_hres(), ctf_tools(), hts_tools(), lcmat(), oct_bounds(), residuals_matrix(), score_index(), shrink_estim(), thf_tools()

Examples

Run this code
Y <- matrix(rnorm(30), 5, 6)
P <- commat(5, 6)
P %*% as.vector(Y) == as.vector(t(Y)) # check

Run the code above in your browser using DataLab