Hi all,
I looked at Clyde's response on this post regarding looping regressions, but I fail to execute it properly.
I am not sure where I am going wrong with it.
Consider a dependent variable being -y- and three independent variables -x1, x2, x3-.
I want to run:
The below code doesn't work, because each regression runs x1 only, x2 only, and x3 only.
I got around this by making the inner loop with -forvalues- by declaring something like:
However, what if I have 20 variables I want to cumulatively run regression in addition to my previous specification (e.g., run -reg y x1-, then run -reg y x1 x2-, etc until x20?)
Please advise and help!
Thanks.
I looked at Clyde's response on this post regarding looping regressions, but I fail to execute it properly.
I am not sure where I am going wrong with it.
Consider a dependent variable being -y- and three independent variables -x1, x2, x3-.
I want to run:
Code:
reg y x1 reg y x1 x2 reg y x1 x2 x3
The below code doesn't work, because each regression runs x1 only, x2 only, and x3 only.
Code:
local yvar y local xvar x1 x2 x3 foreach y of local ypvar{ foreach p of local xvar{ reg `y' x`p' } }
Code:
local xv1 x1 local xv2 x1 x2 local xv3 x1 x2 x3
Please advise and help!
Thanks.
Comment