From a set of about 300 variables, I've pared down to about 30 potential x variables. Assuming a linear model, I am hoping to run regressions on all combinations of these, i.e. the smallest model will have 1 x, the biggest will have 30. The idea is that once I have the results, with the r^2, p, t, F, etc, I can choose a model, keeping in mind all factors, such as the principle of parsimony etc.
The problem is: I am not quite sure how to run a loop that chooses x variables and then does regression on them...
The problem is: I am not quite sure how to run a loop that chooses x variables and then does regression on them...
Code:
foreach i=1/30 { forsomething (some loop for choosing which combination of i variables to pick) regress y x* } }
Comment