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

st: Re: generating combinations of dummies


From   Christopher F Baum <[email protected]>
To   [email protected]
Subject   st: Re: generating combinations of dummies
Date   Sun, 22 Aug 2004 16:24:05 -0400

CM wrote

I have a dataset that includes 14 dummy variables
(0/1). Essentially, I want to be able to generate
variables (to be included in the dataset), each of
which represents a pairwise combination of the 14
dummies.

For example, let the 14 dummies be represented by
x1...x14. Then I want another variable x1x2 which
equates to 1 if x1 and x2 both equal 1; 0 otherwise.
And then I would need this done for all 14c2 ("14
choose 2") combinations. I suppose I could do it
manually, but there's gotta be a simpler way.

Probably more importantly, is it possible to add these
variables in a regression without eating into the 800
max matsize that I get to use in Stata Intercooled?



If you include the dummies in the regression, you will use 104 d.f., no doubt about it (unless some are dropped due to zero variance). But I don't see that creating them takes up that much space--they can (and should) be stored as byte, obviously:

clear
set obs 100
forv i=1/14 {
g v`i' = uniform()
g byte x`i'=(v`i'>0.5)
drop v`i'
}

forv i=1/13{
forv j=`i'/14{
g byte v`i'_`j' = x`i'*x`j'
}
}

drop x*

Kit

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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