Thank you very much Nick - I am learning a lot through the process of revising this code.
-
Login or Register
- Log in with
gen sic_2 = real(substr(sic,1,2)) xtset sic_2 fyear gen uhat = . gen ta = (ib - oancf)/L.at gen x1 = 1/L.at gen x2 = (d.revt - d.rect)/L.at gen x3 = ppegt/L.at forvalues j = 1/`=_N' { capture noisily { reg ta x1 x2 x3 if sic_2 == sic_2[`j'] & fyear == fyear[`j'] & _n != `j', nocons if e(N) >= 10 { predict uhat_2 in `j', resid replace uhat = uhat_2 in `j' drop uhat_2 } } }
predict uhat_2 in `j', resid replace uhat = uhat_2 in `j' drop uhat_2
replace uhat = ta - (_b[x1] * x1 + _b[x2] * x2 + _b[x3] * x3) in `j'
xtset sic_2 fyear
xtset gvkey fyear
egen combo = group(sic_2 year) summarize combo forvalues k = 1/`r(max)' { forvalues j= `=scalar(e)’/`=scalar(f)’ { capture noisily reg ta x1 x2 x3 if combo == `k' & obs != `j', nocons capture noisily predict uhat_2, resid capture noisily replace uhat_2=. if e(N) < 10 capture noisily replace uhat= uhat_2 if combo == `k' & obs == `j' capture noisily drop uhat_2 display `k', `j' } }
egen combo = group(sic_2 year) summarize combo forvalues k = 1/`r(max)' { forvalues j= `=scalar(e)’/`=scalar(f)’ { capture noisily reg ta x1 x2 x3 if combo == `k' & obs != `j', nocons capture noisily predict uhat_2, resid capture noisily replace uhat_2=. if e(N) < 10 capture noisily replace uhat= uhat_2 if combo == `k' & obs == `j' capture noisily drop uhat_2 display `k', `j' } }
Comment