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
Managing time factor in repeated-measures ANOVAHello, I'm analysing data from a protocol which in fact works under the same structure as described …
pvar with system gmmcan somebody help me with command for panel var using system GMM?? …
How to regress with seasonality dummy variablesExcuse my perhaps dumb question, however I have a dataset consisting of daily crime date and weather…
Error when using medsem command in simultaneous group SEM estimationHi all, I am running a between groups SEM with multiple mediators. In one group there is a signific…
Inserting blank rows at specific observations in datasetI am trying to manipulate a text (.tex) document (a multiple-choice exam) in Stata, which I realize …
Subscribe to:
Post Comments (Atom)
0 Response to Regression for all possible combinations of variables
Post a Comment