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)" <>
To   "''" <>
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-----
[] On Behalf Of Christopher F
Sent: Monday, August 01, 2005 8:09 AM
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

*   For searches and help try:
*   For searches and help try:

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