全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
5833 6
2015-07-25
做收购对公司股价的影响。 对stata 实在认识有限,已经下载完所有股价但是不知道如何在excel 排列数据,如何用 adj closing price 计算 return(在stata里如何求)????另外, 按照普林斯顿那个做的时候
sort company_id date


. by company_id: gen datenum=_n


. by company_id: gen target=datenum if date==eventdate
(1114 missing values generated)


. egen td=min(target), by(company_id)


. drop target


. gen dif=datenum-td


. by company_id: gen event_window=1 if dif>=-10 & dif<=10
(955 missing values generated)


. egen count_event_obs=count(event_window), by(company_id)


. by company_id: gen estimation_window=1 if dif<-10 & dif>=-110
(340 missing values generated)


. egen count_est_obs=count(estimation_window), by(company_id)


. replace event_window=0 if event_window==.
(955 real changes made)


. replace estimation_window=0 if estimation_window==.
(340 real changes made)


. set more off


. gen predicted_return=.
(1123 missing values generated)


. egen id=group(company_id)


. forvalues i=1(1)N { /*note: replace N with the highest value of id */
  2.         l id company_id if id==`i' & dif==0
  3.         reg ret market_return if id==`i' & estimation_window==1
  4.         predict p if id==`i'
  5.         replace predicted_return = p if id==`i' & event_window==1
  6.         drop p
  7. }  
invalid syntax
r(198);出现这个问题咋办???

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-7-25 08:51:32
forvalues i=1(1)N { /*note: replace N with the highest value of id */
你忘了replace了。
另,  l id company_id if id==`i' & dif==0 开头是什么?复制粘贴有乱码?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-7-26 00:43:41
夏目贵志 发表于 2015-7-25 08:51
forvalues i=1(1)N { /*note: replace N with the highest value of id */
你忘了replace了。
另,  l i ...
现在是我运行到这一步,发现我没有market return 这个变量, 我不懂怎么去算这个market return .
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-7-26 08:25:13
cgz2006 发表于 2015-7-26 00:43
现在是我运行到这一步,发现我没有market return 这个变量, 我不懂怎么去算这个market return .
这个。。。数据不足就爱莫能助了。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-7-26 21:59:33

. forvalues i=1(1)66 {  
  2.         l id company_id if id==`i' & dif==0
  3.         reg r mret if id==`i' & estimation_window==1
  4.         predict p if id==`i'
  5.         replace predicted_return = p if id==`i' & event_window==1
  6.         drop p
  7. }  

      +---------------+
      | id   compan~d |
      |---------------|
100. |  1        ABF |
      +---------------+

      Source |       SS       df       MS              Number of obs =      88
-------------+------------------------------           F(  1,    86) =    3.45
       Model |  .000412347     1  .000412347           Prob > F      =  0.0666
    Residual |  .010272807    86  .000119451           R-squared     =  0.0386
-------------+------------------------------           Adj R-squared =  0.0274
       Total |  .010685154    87  .000122818           Root MSE      =  .01093

------------------------------------------------------------------------------
           r |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        mret |   .3529295   .1899555     1.86   0.067    -.0246895    .7305485
       _cons |  -.0013967   .0011753    -1.19   0.238    -.0037332    .0009398
------------------------------------------------------------------------------
(option xb assumed; fitted values)
(7967 missing values generated)
variable predicted_return not found
r(111);

end of do-file

r(111);
我在前面已经gen predicted_return=. 了为什么还会出现说predicted_return 未找见啊??
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-7-27 11:13:44
cgz2006 发表于 2015-7-26 21:59
. forvalues i=1(1)66 {  
  2.         l id company_id if id==`i' & dif==0
  3.         reg r mre ...
光看程序没看出问题。你要是能把数据发上来我可以帮你试试看我这里能不能重现这个问题。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群