全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
5526 8
2016-11-21
悬赏 50 个论坛币 未解决
以如下数据为例:超额累积收益的算法为:1.首先利用前7天的数据估算模型Ri,t=αi+βi×Rm,t+ε系数;2.然后根据估算数据预测后3天的收益率;3.最后用(实际收益率-估算收益率)之和即为后三天的累积超额收益率。
理论不难,但是如何在stata上实现呢?特别是当数据量巨大,日期不一致的情况!非常感谢各位的帮助,希望能尽快解决!

stock

day

r

rm

1

1

-0.07314

-0.01561

1

2

-0.00123

-0.02643

1

3

-0.05679

-0.02389

1

4

-0.02356

0.012236

1

5

0.014745

0.007692

1

6

-0.00661

-0.00327

1

7

0.033245

-0.00438

1

8

0.002574

0.007692

1

9

-0.0077

-0.03381

1

10

-0.05951

-0.00903

2

7

-0.02069

-0.00438

2

8

0.007042

0.007692

2

9

-0.01282

-0.03381

2

10

-0.00354

-0.00903

2

11

-0.00592

-0.01136

2

12

-0.05483

0.002299

2

13

0.016393

0.009174

2

14

0.024814

-0.00114

2

15

-0.00242

0.015927

2

16

0.001214

-0.00448


二维码

扫码加我 拉你入群

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

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

全部回复
2016-11-22 02:18:40
继续求帮助
二维码

扫码加我 拉你入群

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

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

2017-2-18 11:13:24
87602192 发表于 2016-11-22 02:18
继续求帮助
我现在也遇到同样的问题,楼主你最后怎么解决的?
二维码

扫码加我 拉你入群

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

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

2017-2-27 15:00:55
还没有解决,暂时放下了这个问题。
我想等以后有时间了可以换个思路来解决这个问题。
二维码

扫码加我 拉你入群

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

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

2019-6-17 09:06:12
sort companyid date
by companyid: gen datenum=_n
by companyid: gen target=datenum if date==Eventdate
egen td=min(target), by(companyid)
drop target
gen dif=datenum-td

by companyid: gen event_window=1 if dif>=-10 & dif<=30
egen count_event_obs=count(event_window), by(companyid)
by companyid: gen estimation_window=1 if dif<-20 & dif>=-220
egen count_est_obs=count(estimation_window), by(companyid)
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.


tab companyid if count_event_obs<20
tab companyid if count_est_obs<100
.
  drop if count_event_obs < 20
drop if count_est_obs < 100

set more off /* this command just keeps stata from pausing after each screen of output */

gen predicted_return=.
egen id=group(companyid)
/* for multiple event dates, use: egen id = group(group_id) */
forvalues i=1(1)569 { /*note: replace N with the highest value of id */
        l id companyid if id==`i' & dif==0
        reg ln_return ln_Mktreturn if id==`i' & estimation_window==1
        predict p if id==`i'
        replace predicted_return = p if id==`i' & event_window==1
        drop p
}  



sort id date
gen abnormal_return=ln_return-predicted_return if event_window==1
by id: egen cumulative_abnormal_return = sum(abnormal_return)

sort id date
by id: egen ar_sd = sd(abnormal_return)
gen test =(1/sqrt(41)) * ( cumulative_abnormal_return /ar_sd)
list companyid cumulative_abnormal_return test if dif==0


reg cumulative_abnormal_return if dif==0, robust
二维码

扫码加我 拉你入群

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

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

2019-6-17 09:06:55
以上是我计算CAR的do文件里面的,你自己改一下参数就可以
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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