Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: nchoosek in Stata?

From   "Dimitriy V. Masterov" <>
Subject   st: nchoosek in Stata?
Date   Mon, 8 Dec 2003 16:23:03 -0600 (CST)

Dear Statalisters,

I am trying to create a new data set by relabeling vector observations
from a treatment and a control group. I would like to include all possible
relabelings in this final data set.

To elaborate, let's say I have a matrix X that is n by k, and it contains
values for k variables for n people. I would like to create a data set that
consists of ALL possible reassignments of the vector observations to two
groups. Thus for example if I have two outcomes and two people, and let's
say my actual data looks like this:

x1 x2 treatment
1  1    1
0  0    0

I would like to get something like this:

x1 x2 treatment permutation
1  1    1	1
0  0    0	1
1  1    0	2
0  0    1	2

Is this feasible with Stata 8.2 SE? It looks to me that most of the
permutation modules I found with "findit" and Google simply assign treatment
at random, rather than generating ALL possible combinations. I realize
this may be impossible with Stata due to memory considerations, but let's
say I had a 10 vector observations with a treatment group of 5 people.
This means that there would be [10!/(5!(10-5)!)]=252 possible
permutations, counting the one that you actually observe. Is there a
clever way to do this?

I would be very grateful for any help.


Dimitriy V. Masterov

Center for Social Program Evaluation
1155 East 60th St. Room 038
Chicago, IL 60637
Work: (773)256-6005
Fax: (773)256-6313

*   For searches and help try:

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