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: Keeping the upper triangle of a matrix.


From   Philipp Krueger <[email protected]>
To   [email protected]
Subject   st: Keeping the upper triangle of a matrix.
Date   Thu, 20 Jan 2011 19:22:05 +0100

Dear statlisters,
I am a bit stuck. I have the following dataset

var1; var2; var3
1; 1; aaa
1; 2; def
1; 3; ghi

2; 1; def
2; 2; aaa
2; 3; klm

3; 1; ghi
3; 2; klm
3; 3; aaa

Essentially, the three row vectors of a 3x3 matrix are stacked underneath each other in a dataset. Since the matrix is symmetric, I would like to keep only the observations corresponding to the lower triangle of the matrix (including the diagonal), i.e. observations 1,2,3,5,6,9 in the dataset. All other observations (i.e. 4 and 8 should be dropped. I have tried hard but could not find a solution.
I would greatly appreciate your help.
Many thanks in advance.
Philipp
*
*   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