I have a panel variable - company name and I am trying to run repeated regressions by company and store residuals after each regression
I have written the following code:
Code:
generate rebit = . foreach conm i = 1/73 { capture reg LnEBIT time if conm ==`i' capture predict temp, resid capture replace rebit = temp if conm ==`i' capture drop temp }
number of companies = 73
So the loop will have to run 73 times and after each regression should store the residuals for that company regression.
But when I run this code, Stata gives me the following error:
invalid syntax
r(198);
Could you please let me know where I am going wrong and how to correct this code?
Thank you for your help and advice.
0 Response to Foreach regression loop - Stata 16
Post a Comment