0

我目前正在对 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);

检查数据后,我没有发现任何缺失的观察结果。有没有人已经处理过同样的问题?有没有办法避免缺失值分别忽略缺失值?

4

1 回答 1

0

如果你有足够的缺失,你会得到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
    } 
}
于 2013-03-19T17:40:35.853 回答