Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: transpose of matrix


From   "FEIVESON, ALAN H. (AL) (JSC-SK) (NASA)" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: transpose of matrix
Date   Mon, 1 Aug 2005 09:19:47 -0500

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: [email protected]
[mailto:[email protected]] On Behalf Of Christopher F
Baum
Sent: Monday, August 01, 2005 8:09 AM
To: [email protected]
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      [email protected]
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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index