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
Sending output to file _instead of_ Results windowI have a do-file that produces a lot of output from various types of commands. I would like to store…
custom xline value per group in xtlineHi. I'm trying to produce a graph for each US state using -xtline- and the -xline- option (Stata 15.…
Tabulating across variables after using multencodeHi Everyone, I have a string variable that contains multi-picklist values separated by a semi-colon…
Gravity model for importsHi, I am new to STATA and I am having some problems in estimating a fixed effects gravity model est…
Combining graphs from a loopHi, I am making histograms using the following command that I want to loop for 122 countries, Code…
Subscribe to:
Post Comments (Atom)
0 Response to Regression for all possible combinations of variables
Post a Comment