This function returns the (\(r c \times r c\))
commutation matrix \(\mathbf{P}\) such that
\(\mathbf{P} \mbox{vec}(\mathbf{Y}) = \mbox{vec}(\mathbf{Y}'),\)
where \(\mathbf{Y}\) is a (\(r \times c\)) matrix (Magnus and Neudecker, 2019).
Usage
commat(r, c)
Value
A sparse (\(r c \times r c\)) matrix, \(\mathbf{P}\).
Arguments
r
Number of rows of \(\mathbf{Y}\).
c
Number of columns of \(\mathbf{Y}\).
References
Magnus, J.R. and Neudecker, H. (2019), Matrix Differential Calculus with Applications
in Statistics and Econometrics, third edition, New York, Wiley, pp. 54-55.