Statalist


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

st: Creating interaction terms of 30 continuous variables


From   Jean-Gael Collomb <jg@ufl.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Creating interaction terms of 30 continuous variables
Date   Wed, 9 Sep 2009 11:13:28 -0400

Hello,
I am trying to explore all possible interaction terms in my dataset  
and I am not sure how to do this efficiently using stata. I have about  
30  continuous variables. It seems that xi is limited to non  
continuous variables and xi3 does not seem to work for 30 variables,  
unless I am doing something wrong. I came up with a solution using  
"foreach" to generate all the interactions terms and then try them in  
a regression model:

foreach x of varlist var1-var30 {
foreach y of varlist var1-var30 {
generate `x'X`y'=`x'*`y'
}
}

The first problem I have is that this created duplicates (i.e.  
var1Xvar2 is the same as var2Xvar1). Furthermore, I feel it is a  
cumbersome way to do it, and I wonder if there is a more efficient way  
to generate all possible pair interaction terms or better yet to have  
an exploratory regression models testing all these pairs out and  
selecting the best model. I saw someone someone doing something  
similar very quickly in NCSS and I was hoping I could do the same in  
STATA.
Thanks for your feedback.


Jean-Gael "JG" E. Collomb
PhD candidate
School of Natural Resources and Environment / School of Forest  
Resources and Conservation
University of Florida
jgcollomb@gmail.com
jg@ufl.edu
+1 (352) 870 6696





*
*   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   |   What's new   |   Site index