| 所在主题: | |
| 文件名: eventdates1981.dta | |
| 资料下载链接地址: https://bbs.pinggu.org/a-1733709.html | |
| 附件大小: | |
|
各位大神求助!我是stata新手,做stata数据出现问题啦!
我们用的是普林斯顿的event studyhttp://dss.princeton.edu/online_help/stats_packages/stata/eventstudy.html 我们是做收购的event, 很多公司在相同的一年有很多收购,这些事件发生的时间都不相同。但是代码只能取第一个,后面的几笔同公司收购全部都自动删除掉了。 可是这会影响我们的结果…… 有没有什么办法能够保留所有的收购,而不是每个公司保留一笔?或者是不是代码中出现了什么限制呀?我上传下我们的一年的数据,希望有大神能够帮我们解答,谢谢啦! use stockdata1981.dta, replace sort company_id date replace prc= abs(prc) by company_id: gen ret= (prc - prc[_n-1])/prc[_n-1] merge m:m company_id using eventdates1981.dta keep if _merge==3 sort company_id date by company_id: gen datenum=_n by company_id: gen target=datenum if date==event_date egen td=min(target), by(company_id) drop target gen dif=datenum-td *set the window* by company_id: gen event_window=1 if dif>=-1 & dif<=1 egen count_event_obs=count(event_window), by(company_id) by company_id: gen estimation_window=1 if dif<=-6 & dif>=-205 egen count_est_obs=count(estimation_window), by(company_id) replace event_window=0 if event_window==. replace estimation_window=0 if estimation_window==. *list of company_ids that do not have enough observations within the event and estimate window* set more off tab company_id if count_event_obs<3 tab company_id if count_est_obs<200 *drop if not enough* drop if count_event_obs < 3 drop if count_est_obs < 200 drop count_event_obs count_est_obs *Estimating Normal Performance* set more off /* this command just keeps stata from pausing after each screen of output */ gen predicted_return=. egen id=group(company_id) /* for multiple event dates, use: egen id = group(group_id) */ forvalues i=1(1)98 { /*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 } *Abnormal and Cumulative Abnormal Returns* sort id fyear gen abnormal_return=ret-predicted_return if event_window==1 sort company_id by company_id: egen cumulative_abnormal_return = sum(abnormal_return) sort id egen evacar = mean(abnormal_return) *Testing for Significance* sort id date by id: egen ar_sd = sd(abnormal_return) gen test =(1/sqrt(98)) * ( cumulative_abnormal_return /ar_sd) list company_id cumulative_abnormal_return test if dif==0 *output* outsheetcompany_id event_date cumulative_abnormal_return test using stats.csv if dif==0, comma names *Testing Across All Events* reg cumulative_abnormal_return if dif==0, robust 而且中间出现了一个问题,就是在做循环回归的时候,98个公司到51就不跑了,说是 no observation, 不明白这是怎么回事嗷呜…… 多谢各位大神! |
|
熟悉论坛请点击新手指南
|
|
| 下载说明 | |
|
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。 2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。 3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。 (如有侵权,欢迎举报) |
|
京ICP备16021002号-2 京B2-20170662号
京公网安备 11010802022788号
论坛法律顾问:王进律师
知识产权保护声明
免责及隐私声明