I would like to calculate predicted values for each company_ID in my sample by estimating the following regression equation for each company_ID quarterly and excluding firm i:
Here is an example of the used variables included in the regression. The coefficient estimates, as shown below, will then be used to calculate for each company_ID and for each quarter a predicted value by multiplying the coefficient estimates for the full sample with the actual independent variable observations for each company_ID.
I would like to know if the Code I want to use is correct:
Here is an example of the used variables included in the regression. The coefficient estimates, as shown below, will then be used to calculate for each company_ID and for each quarter a predicted value by multiplying the coefficient estimates for the full sample with the actual independent variable observations for each company_ID.
Code:
. xtreg CE lCE ATO accruals laccruals changesales negchangesales Random-effects GLS regression Number of obs = 36,122 Group variable: company_ID Number of groups = 1,166 R-sq: Obs per group: within = 0.0341 min = 1 between = 0.5489 avg = 31.0 overall = 0.0492 max = 53 Wald chi2(6) = 1869.59 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 -------------------------------------------------------------------------------- CE | Coef. Std. Err. z P>|z| [95% Conf. Interval] ---------------+---------------------------------------------------------------- lCE | .088218 .0051389 17.17 0.000 .0781459 .0982902 ATO | -5.80e-08 2.13e-06 -0.03 0.978 -4.24e-06 4.12e-06 accruals | -.0586675 .0015102 -38.85 0.000 -.0616275 -.0557076 laccruals | .0037709 .0015531 2.43 0.015 .0007268 .006815 changesales | .0005675 .0002451 2.32 0.021 .0000872 .0010478 negchangesales | -4.926075 .7808714 -6.31 0.000 -6.456555 -3.395595 _cons | -.1345862 .5538775 -0.24 0.808 -1.220166 .9509939 ---------------+---------------------------------------------------------------- sigma_u | 0 sigma_e | 71.838386 rho | 0 (fraction of variance due to u_i) --------------------------------------------------------------------------------
I would like to know if the Code I want to use is correct:
Code:
egen id=group(company_ID) gen predicted_CE=. forvalues i=1(1)N { xtreg CE lCE ATO accruals laccruals changesales negchangesales if id==`i' predict px if id==`i' replace predicted_CE = px if id==`i' drop px }
Comment