I'm having a problem running a loop regression.
Basically, I have to run a regression for each industry and for each year. Calculating finally the residuals from this regression (it is the modified Jones model, for those people that are doing Accounting Research).
This is the code:
Code:
forval y=1989(1)2018{ forval i=1(1)48{ display `i' display `y' reg TA x1 x2 x3 if `i'== ffind & `y'== fyear & n_obs>=15, noconstant predict r if `i'== ffind & `y'== fyear n_obs>=15, resid replace modjones=r if `i'== ffind& `y'== fyear drop r } }
The problem is that the loop stops immediately the first year with this message error:
Code:
1 1989 no observations r(2000);
How can I stata tell to continue the loop and overcome the problem of no observations? Maybe replacing with missing values
0 Response to Loop Regression
Post a Comment