Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: manipulate ordering of rows matrices |

Date |
Tue, 10 May 2011 09:20:03 +0100 |

Sorry, but I bail out here as this is no clearer to me. How can the first example be correct but the second be what you want? Others may be able to help. On Tue, May 10, 2011 at 9:07 AM, <r.a.nobel@umail.leidenuniv.nl> wrote: > Yes I'm sorry. What is correct for me in this particular case, is that for > example for columns 3,4&5 (which are in fact dummy codings for a variable > consisting of 4 categories) the ones are sorted in an upward diagonal: > > 0 0 0 > 0 0 1 > 0 1 0 > 1 0 0 > > But I need this be done generally done as: > > 0 0 0 > 1 0 0 > 0 1 0 > 0 0 1 > > I hope this makes it more clear, > > Alex > > > >>Quoting Nick Cox <njcoxstata@gmail.com>: > >> It would help if you explained the essence of the difference. What >> makes X2 sorted correctly? >> >> Nick >> >> On Tue, May 10, 2011 at 8:32 AM, <r.a.nobel@umail.leidenuniv.nl> wrote: >> >> > I'm having trouble with the following in Mata: >> > >> > From a large matrix X, I need a new matrix with unique values/rows. As an >> > example, when I use : >> > >> > x1 = uniqrows(X) >> > >> > Then, the matrix given is: >> > >> > x1 = ( >> > 1,0,0,0,0,0,0,0\ >> > 1,0,0,0,1,0,0,0\ >> > 1,0,0,1,0,0,0,0\ >> > 1,0,1,0,0,0,0,0\ >> > 1,1,0,0,0,0,0,0\ >> > 1,1,0,0,1,0,0,1\ >> > 1,1,0,1,0,0,1,0\ >> > 1,1,1,0,0,1,0,0 ) >> > >> > But what I need is: >> > >> > x2 = ( >> > 1,0,0,0,0,0,0,0\ >> > 1,0,1,0,0,0,0,0\ >> > 1,0,0,1,0,0,0,0\ >> > 1,0,0,0,1,0,0,0\ >> > 1,1,0,0,0,0,0,0\ >> > 1,1,1,0,0,1,0,0\ >> > 1,1,0,1,0,0,1,0\ >> > 1,1,0,0,1,0,0,1 ) >> > >> > Of course, this can be done easily for just this matrix, but the problem is >> that >> > I need the correct matrix as part of an estimation command (thus, the >> matrices >> > can be different everytime, dependent on the dataset at hand), so I need a >> sort >> > of general way to ensure the matrix is always sorted correctly. However, >> I've >> > not find a working strategy yet. * * 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/

**References**:**st: manipulate ordering of rows matrices***From:*r.a.nobel@umail.leidenuniv.nl

**Re: st: manipulate ordering of rows matrices***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: manipulate ordering of rows matrices***From:*r.a.nobel@umail.leidenuniv.nl

- Prev by Date:
**Re: st: manipulate ordering of rows matrices** - Next by Date:
**Re: st: variable names in matrix** - Previous by thread:
**Re: st: manipulate ordering of rows matrices** - Next by thread:
**[no subject]** - Index(es):