Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Mata and subsets...


From   Matthew Baker <matthew.baker@hunter.cuny.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Mata and subsets...
Date   Thu, 1 Mar 2012 15:03:47 -0500

Dear Listers --

I have a question about obtaining subsets and their complements in
mata. To be clear, what I am trying to do is get a listing of both the
subsets and their corresponding complements.

For example,
mata
mm_subsets(4,2)

gives me the subsets:
       1   2   3   4   5   6
    +-------------------------+
  1 |  1   1   1   2   2   3  |
  2 |  2   3   4   3   4   4  |
    +-------------------------+

But the question is: is there also an (efficient, general) way to
obtain the corresponding complements:

       1   2   3   4   5   6
    +-------------------------+
  1 |  3   2   2   1   1   1  |
  2 |  4   4   3   4   3   2  |
    +-------------------------+

I'm hoping for a general method that doesn't depend upon having four
items or the two-element subsets but am baffled about how to do this
without looping, etc.

Thanks in advance!

Matt Baker






-- 
Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index