You don't have to remember which side of A to put the permutation matrix, nor whether to use a transpose operation.Īn application: Order of effects in a regression model The second syntax specifies the order of the rows. If you multiply A on the left (Q`*A), you permute the rows, as shown:Ī = shape ( 1: 25, 5, 5 ) /*, the first syntax means, "copy the columns in the order, 3, 5, 2, 4, and 1." I think this definition is easier to use.) If you multiply A on the right (A*Q), you permute the columns. (The permutation matrix is the transpose of the matrix that I used in the previous article. The following example defines a 5 x 5 matrix, A, with integer entries and a function that creates a permutation matrix. If you use matrix multiplication to permute columns of a matrix, you might not remember whether to multiply the permutation matrix on the left or on the right, but if you use subscripts, it is easy to remember the syntax. Subscripts enable you to permute rows and columns efficiently and intuitively. I ended the article by noting that "there is an easy alternative way" to permute rows and columns: use subscript notation. A previous article shows how to create a permutation matrix and how to use it to permute the order of rows and columns in a matrix. Permutation matrices have many uses, but their primary use in statistics is to rearrange the order of rows or columns in a matrix. Instead, use elementwise multiplication of rows and columns. That article recommends that you never multiply with a large diagonal matrix. Which discusses an efficient way to use diagonal matrices in matrix computations. The advice is similar to the tip in the article, "Never multiply with a large diagonal matrix," This article explains why it is not necessary to multiply by a permutation matrix in a matrix language. ![]() Never multiply with a large permutation matrix! Instead, use subscripts to permute rows and columns. Do you ever use a permutation matrix to change the order of rows or columns in a matrix? Did you know that there is a more efficient way in matrix-oriented languages such as SAS/IML, MATLAB, and R?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |