Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Getting variable names in a matrix


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Getting variable names in a matrix
Date   Fri, 10 Feb 2012 16:53:15 +0000

Even if you want a Stata matrix eventually, which is not clear, the fact is that you are trying to do something with Stata matrices which is much, much easier with either Stata variables or Mata matrices. I would back up and re-cast your strategy. 

Nick 
[email protected] 

[email protected]

for my analysis I am generating a matrix for each of 385 formation periods that includes the cumulated return of stocks (named return_v2-return_v1399)

I now want to sort this matrix in order to obtain the highest X% of returns to continue my research. However, everytime I sort the matrix, the rownames get lost and I hence do not know which asset achieved which return.

Is it possible to add an additional row that contains the name of the variable to the matrix? I have experimented with "describe, simple", but did just generate errors. 

Here is the generation of the matrices:

forvalues i = 1(1)385 {

	mkmat return_v2-return_v1399  in `i', matrix(formation_`i')
	matrix rownames formation_`i' = return_v2-return_v1399
	}

I want to have a matrix that looks like this:
( 0.2  0.5  0.71 ...)
( v3   v7   v500 ...)   So how can I obtain the variable names?


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index