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
Commands to summarize a dataset (i.e., alternatives to codebook, describe, and sum, or ones that combine several of these outputs)Hi, I once saw either a Stata conference presentation or a Stata Journal article that had a series o…
How to create a new variable based on household compositionHello, For my research, I have a demographic survey with different households and different observa…
Industry dummy is omitted in probit regressionDear members, This is an example from my data. I have firms and some information about them. The la…
Model with Independent lagged variables: FE, RE or POLS?Dear all, i am running a regression using panel data and looking at the effect of company financial…
Issues on replicating contrasts with margins commandHi all, I've read the manual and Richard's guide about margins command, but could not understand so…
Subscribe to:
Post Comments (Atom)
0 Response to Regression for all possible combinations of variables
Post a Comment