Apologies if this is very simple or has been asked before. I have searched through many topics and have struggled to find an answer. Any help is greatly appreciated.
I am trying to run a regression command for each observation in a dataset, increasing by one observation each time. It may be more useful if I post the code I have that works so far:
Code:
foreach x in 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19 1/20 1/21 1/22 1/23 1/24 1/25 1/26 1/27 1/28 1/29 1/30 1/31 1/32 1/33 1/34 1/35 { reg DV IV1 IV2 IV3 in `x' }
Code:
foreach x in 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19 1/20 1/21 1/22 1/23 1/24 1/25 1/26 1/27 1/28 1/29 1/30 1/31 1/32 1/33 1/34 1/35 { reg DV IV1 IV2 IV3 in `x' est store model_`x' }
Code:
/ invalid name 11 invalid name
Although, I know I could be completely wrong here. I am very much a Stata beginner and I am making a lot of errors along the way!
Any help is greatly appreciated!
Thanks
0 Response to Looping a regression command sequentially by observation and storing each model.
Post a Comment