I am coming with several questions concerning looping.
Let's imagine I have 4 dummies: a, b, c and d.
I would like to run the same regression on each of the dummies (2 regression per dummy) and store the estimates (N, R2, Adj R2 , both fixed effects (i.e. adding the line indicating the fixed effects) & dropping the constant + the other interaction terms) before using esttab.
I tried to use group() by combining the different dummies and of course it did not work.
How can we make levelsof go through all the different dummies to do the same regression and to store all the results into one single table?
Code:
levelsof a, local(groups) foreach group of local groups { reghdfe Sales i.var1##i.var2 var3 var4 if a==`group', absorb(year firm) vce(cluster firm) global `group'1 = _b[i.var1##i.var2]+_b[.var2]+_b[var3] +_b[var4] eststo `group'1 global storelist = "${storelist} `yvar'1” } esttab ${storelist}
Eugene
0 Response to Foreach and estimates
Post a Comment