This is a special case of multiplying by a permutation matrix. I looked
briefly in the Mata manual to see if one could form a permutation matrix
directly without using the element-loop suggested by Kit - for example some
sort of command such as
matrix H = P(5,5,4,3,2,1), matrix H=P(5,3,4,1,2,5)
but knowing nothing about Mata, I wasn't able to tell. Is there a simple
Mata command to generate an arbitrary permutaion matrix?
Al Feiveson
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Christopher F
Baum
Sent: Monday, August 01, 2005 8:09 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: transpose of matrix
Amadou wants to "transpose" a column vector--but what he really means is to
reverse the order of its elements.
Elementary row and column operations, my dear Watson. The mirror image of an
identity matrix does what he wants.
mat j = J(5,5,0)
forv i = 1/5 {
mat j[`i',5-`i'+1] = 1
}
mat list j
mat list b
mat c = j*b
mat list c
Kit Baum, Boston College Economics baum@bc.edu
http://ideas.repec.org/e/pba1.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/