楼主: sheren33
5023 13

[其他] stata 做event study遇到问题 [推广有奖]

  • 0关注
  • 0粉丝

VIP1

高中生

5%

还不是VIP/贵宾

-

威望
0
论坛币
3456 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
175 点
帖子
18
精华
0
在线时间
20 小时
注册时间
2010-9-14
最后登录
2011-4-28

15论坛币
用stata做EVENT STUDY遇到问题,http://dss.princeton.edu/usingdata/stata/analysis/eventstudy.html#car 用了这个LINK提供的步骤,但是到Estimating Normal Performance这个部分的时候指令出现错误forvalues i=1(1)N { /*note: replace N with the highest value of id */         l id company_id if id==`i' & dif==0        reg ret market_return if id==`i' & estimation_window==1         predict p if id==`i'        replace predicted_return = p if id==`i' & event_window==1         drop p}  主要是这个指令,有哪位能帮我解决这个问题一下,比较急,麻烦了

最佳答案

蓝色 查看完整内容

sum id local N=r(max) forvalues i=1(1)`N' { /*note: replace N with the highest value of id */ list id company_id if id==`i' & dif==0 reg ret market_return if id==`i' & estimation_window==1 predict p if id==`i' replace predicted_return = p if id==`i' & event_window==1 drop p } 或者加入2行。
关键词:event study Stata study Event Even
沙发
蓝色 发表于 2010-10-24 06:30:48 |只看作者 |坛友微信交流群
sum id
local N=r(max)



forvalues i=1(1)`N' { /*note: replace N with the highest value of id */
        list id company_id if id==`i' & dif==0
        reg ret market_return if id==`i' & estimation_window==1
        predict p if id==`i'
        replace predicted_return = p if id==`i' & event_window==1
        drop p
}


或者加入2行。

使用道具

藤椅
sheren33 发表于 2010-10-24 06:45:10 |只看作者 |坛友微信交流群
forvalues i=1(1)N {
  2. /*note: replace N with the highest value of id */
  3. id company_id if id==`i' & dif==0
  4. reg ret market_return if id==`i' & estimation_window==1
  5. predict p if id==`i'
  6.
. replace predicted_return = p if id==`i' & event_window==1
  7.
. drop p
  8.
. }
invalid syntax
r(198);
请大家帮忙啊

使用道具

板凳
蓝色 发表于 2010-10-24 10:19:03 |只看作者 |坛友微信交流群
能不能提供部分数据,这样才能执行程序的。

使用道具

报纸
sheren33 发表于 2010-10-24 16:52:17 |只看作者 |坛友微信交流群
蓝色 发表于 2010-10-24 10:19
能不能提供部分数据,这样才能执行程序的。
好的,数据在这里
论坛不能上传CSV格式,这里是EXCEL的表格格式

多谢了

eventdate.xlsx

9.65 KB

1stockdata.xlsx

20.66 KB

使用道具

地板
蓝色 发表于 2010-10-24 18:14:33 |只看作者 |坛友微信交流群
/*
forvalues i=1(1)N { /*note: replace N with the highest value of id */
        list id company_id if id==`i' & dif==0
        reg ret market_return if id==`i' & estimation_window==1
        predict p if id==`i'
        replace predicted_return = p if id==`i' & event_window==1
        drop p
}

括号里面不是说把N 用最大的id  值替代,这样循环才能知道到那里。

使用道具

7
sheren33 发表于 2010-10-24 19:01:30 |只看作者 |坛友微信交流群
那我再问下,我这个情况是3个公司,是把三个公司里的最大值放进去么

使用道具

8
sheren33 发表于 2010-10-24 19:07:42 |只看作者 |坛友微信交流群
蓝色 发表于 2010-10-24 18:23
sum id
local N=r(max)



forvalues i=1(1)`N' { /*note: replace N with the highest value of id */
        list id company_id if id==`i' & dif==0
        reg ret market_return if id==`i' & estimation_window==1
        predict p if id==`i'
        replace predicted_return = p if id==`i' & event_window==1
        drop p
}


或者加入2行。
我加入这两行出现的结果
sum id


    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
          id |     15654     31.5573    17.91308          1         62


.
. local N=r(max)


.
. forvalues i=1(1)`N' {
  2.
. list 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.
. }
insufficient observations
r(2001);

使用道具

9
sheren33 发表于 2010-10-24 19:16:28 |只看作者 |坛友微信交流群
这是把两行加在中间
forvalues i=1(1)`N' {
  2.
. sum id
  3.
. local N=r(max)
  4.
. list id company_id if id==`i' & dif==0
  5.
.         reg ret market_return if id==`i' & estimation_window==1
  6.
.         predict p if id==`i'
  7.
.         replace predicted_return = p if id==`i' & event_window==1
  8.
.         drop p
  9.
. }

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
          id |     15654     31.5573    17.91308          1         62

      Source |       SS       df       MS              Number of obs =       2
-------------+------------------------------           F(  1,     0) =       .
       Model |      5.5778     1      5.5778           Prob > F      =       .
    Residual |           0     0           .           R-squared     =  1.0000
-------------+------------------------------           Adj R-squared =       .
       Total |      5.5778     1      5.5778           Root MSE      =       0

------------------------------------------------------------------------------
         ret |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
market_ret~n |  -.0036699          .        .       .            .           .
       _cons |   35.58836          .        .       .            .           .
------------------------------------------------------------------------------
(option xb assumed; fitted values)
(15402 missing values generated)
(0 real changes made)

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
          id |     15654     31.5573    17.91308          1         62

       +---------------+
       | id   compan~d |
       |---------------|
  518. |  2         GM |
       +---------------+
insufficient observations
r(2001);

使用道具

10
sheren33 发表于 2010-10-25 02:29:43 |只看作者 |坛友微信交流群
两个都得到INSUFFICIENT OBSERVATIONS,该怎么解决呢

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 16:57