I am a beginner in Stata and panel data, therefore please excuse me beforehand if my question is novice -- and thank you in advance for any input or suggestions.
I have data on 62 teams, that looks like this:
Team | Week | Treat | projco | hirchsc |
1 | 1 | 0 | 13 | 16 |
1 | 2 | 0 | 13 | 16 |
1 | 3 | 0 | 13 | 16 |
2 | 1 | 0 | 31 | 70 |
2 | 2 | 0 | 31 | 70 |
2 | 3 | 0 | 31 | 70 |
...... | ||||
62 | 50 | 1 | 55 | 76 |
62 | 51 | 1 | 55 | 76 |
62 | 52 | 1 | 55 | 76 |
I want to create a loop that will run a regression for each of the 62 teams, store the coefficients for each of the regressions and plot these. I have tried many times, but either my syntax is not working, or I will get the same regression 62 times, which is not what I want.
This is my code so far, but it is obviously not right,
foreach i in Team 1/62 {
2. xtreg projco hirchsc treat c.treat#c.hirchsc, i(Team)
3. eststo reg_`i'
}
Thank you very much in advance and I hope I am not bothering too much,
Best wishes,
Elena.
0 Response to creating a loop for multiple regressions
Post a Comment