我目前正在对2836家公司进行几项事件研究。我根据几个因素对每家公司的回报进行回归(由FF汇编)。因此,我编写了以下循环:
gen predicted_return4=.
forvalues i = 1(1)2836 {
l id acq_company_id if id==`i' & dif==0
reg ret ${ff} if id==`i' & estimation_window==1
predict p4 if id==`i'
replace predicted_return4 = p4 if id==`i' & event_window==1
drop p4
}这个循环运行得相当好。然而,在几次回归之后,出现了一个错误(见下文)。
+---------------+
| id acq_co~d |
|---------------|
48818. | 21 8 |
+---------------+
Source | SS df MS Number of obs = 220
-------------+------------------------------ F( 3, 216) = 53.77
Model | .012074753 3 .004024918 Prob > F = 0.0000
Residual | .016167584 216 .00007485 R-squared = 0.4275
-------------+------------------------------ Adj R-squared = 0.4196
Total | .028242337 219 .00012896 Root MSE = .00865
------------------------------------------------------------------------------
ret | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mktrf | .9786525 .119806 8.17 0.000 .7425141 1.214791
smb | .201586 .172118 1.17 0.243 -.1376599 .5408319
hml | -.1526954 .2606448 -0.59 0.559 -.6664282 .3610374
_cons | .0004081 .0005981 0.68 0.496 -.0007708 .001587
------------------------------------------------------------------------------
(option xb assumed; fitted values)
(5800880 missing values generated)
(5 real changes made)
**no observations**
r(2000);在检查数据后,我没有发现任何遗漏的观察结果。有没有人已经处理过同样的问题?有没有办法避免分别忽略缺失值的缺失值?
发布于 2013-03-20 01:40:36
如果你有足够的遗漏,你会得到error 2000。你应该想把它困住。试试像这样的东西
gen predicted_return4=.
forvalues i = 1(1)2836 {
l id acq_company_id if id==`i' & dif==0
capture noisily reg ret ${ff} if id==`i' & estimation_window==1
quietly if _rc == 0 {
predict p4 if id==`i'
replace predicted_return4 = p4 if id==`i' & event_window==1
drop p4
}
}https://stackoverflow.com/questions/15504417
复制相似问题