Hello all, I am a new STATA user and trying to run a foreach regression loop.
I have 32 independent variables of which B C D are log transformed, E and F are categorical, and the rest are dummy variables.
I have a log transformed independent variable (ln_A) that I want to regress against various combinations of the independent variables.
The total number of observations in my dataset is 800. I am interested in obtaining the regression coefficients for each combination of variables regressed against ln_y and export the coefficients as well r2, adj_r2, and rmse into an excel file.
the code I have tried so far is as follows:
local predictors ln_B ln_C ln_D E F G H I J…etc
local regressors
foreach p of local predictors {
local regressors `regressors’ `p’
regress ln_A `regressors’
outreg2 using file, excel e(r2_a rmse)
}
This code works but for each iteration it adds another variable to the regression. Whereas, I want to randomize the combination of variables used for each iteration so it would be something like:
reg ln_A ln_B E F I J
reg lnA E K L N F
etc.
All help would be greatly appreciated!
Related Posts with Regression for all possible combinations of variables
Question for controlling the variables reported in a regression tableMy question is a two parter -I am attempting the below regression using twelve controls. Is it possi…
Saving the country graphs by their names (in a loop)Hi... I have created a code that titles the graphs by their "id". I want to title the graphs by thei…
R(2000) error in clogithet regressionI have two subgroups of respondents: the ones who saw traffic-light labelling and the ones who did n…
Likely a very simple question: what is the syntax for adjusting the y axis position offset?Greetings, I'm running Stata 15 on OSX. I'm struggling to figure out how to adjust the position of …
dropping observationsHi b1 is month of birth and b2 is year of birth. I want to drop all the observations below March 20…
Subscribe to:
Post Comments (Atom)
0 Response to Regression for all possible combinations of variables
Post a Comment