请选择 进入手机版 | 继续访问电脑版
楼主: lhjnju
51912 13

[数据管理求助] stata中,如何计算CAR(超额累计日常收益率)? [推广有奖]

  • 0关注
  • 4粉丝

教师

硕士生

70%

还不是VIP/贵宾

-

威望
0
论坛币
30528 个
通用积分
2.1286
学术水平
2 点
热心指数
3 点
信用等级
1 点
经验
2726 点
帖子
85
精华
0
在线时间
155 小时
注册时间
2005-8-21
最后登录
2024-11-29

lhjnju 发表于 2014-4-14 22:01:08 |显示全部楼层 |坛友微信交流群

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

在公司金融学上,经常要计算CAR。例如在某个事件点的股市超额回报率。我最近在做毕业论文,要根据我国上市公司并购日股票价格信息来计算该数值。具体计算过程:先计算预期回报率,再用实际股价回报率减去预期回报率。计算【-5,5】天内的这些差值的综合即CAR。这个预期回报率要用股票综合指数来估算,估算的系数和截距项要根据股票价格[-180,-30]天内股票价格和股票综合指数来估算。例如:6005582009112日进行了并购,要算当天的CAR。即利用【2009.05.062009.10.3】时间段内进行估算。

一个公司的一个并购信息很复杂。倘若是所有公司在所有年内的所有并购信息就更为复杂。在得到【-180-30】内信息时,我先把并购数据和股票价格数据合并,知道并购的当天日期,但然后就不知道用什么命令来过滤出【-180-30】内的记录了?

特别的,一个公司一年内有若干并购,过滤一条记录信息会影响另一条记录计算,怎么办?

怎么一次把所有信息计算出来?

我知道上面是关键一步。只有通过这一步,才可以用statsby命令来计算系数。这里是否有什么小程序可以完成啊?

哪位详细说明一下或者赠送一个小程序来帮一下我。非常感激!谢谢您的帮助!

二维码

扫码加我 拉你入群

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

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

关键词:Stata tata 收益率 CAR statsby 收益率 如何

1044848703 发表于 2015-2-2 11:17:30 |显示全部楼层 |坛友微信交流群
想问下  你知道如何操作吗 同困扰呀

使用道具

卷卷の爱 发表于 2015-2-28 11:47:15 |显示全部楼层 |坛友微信交流群
有没有做出来呀~同求

使用道具

40664015 发表于 2015-3-27 20:14:43 |显示全部楼层 |坛友微信交流群
Event Studies with Stata
An event study is used to examine reactions of the market to events of interest. A simple event study involves the following steps:
•        Cleaning the Data and Calculating the Event Window
•        Estimating Normal Performance
•        Calculating Abnormal and Cumulative Abnormal Returns
•        Testing for Significance
•        Testing Across All Events
This document is designed to help you conduct event studies using Stata. We assume that you already have data with a date variable, which we call "date", and a company identifier, which we have called "company_id". If you need to prepare your data or want to try out the commands with our sample data, go to data preparation page.
We also assume that you have a basic familiarity with Stata. If you need assistance with Stata commands, you can find out more about it here. Your task will be much easier if you enter the commands in a do file, which is a text file containing a list of Stata commands.
Cleaning the data and Calculating the Event and Estimation Windows
It's likely that you have more observations for each company than you need. It's also possible that you do not have enough for some. Before you can continue, you must make sure that you will be conducting your analyses on the correct observations. To do this, you will need to create a variable, dif, that will count the number of days from the observation to the event date. This can be either calendar days or trading days.
For number of trading days:
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
For calendar days:
gen dif=date-event_date
As you can see, calculating the number of trading days is a little trickier than calendar days. For trading days, we first need to create a variable that counts the number of days within each company_id. Then we determine which observation occurs on the event date. We create a variable with the event date's day number on all of the observations within that company_id. Finally, we simply take the difference between the two, creating a variable, dif, that counts the number of days between each individual observation and the event day. Next, we need to make sure that we have the minimum number of observations before and after the event date, as well as the minimum number of observations before the event window for the estimation window. Let's say we want 2 days before and after the event date (a total of 5 days in the event window) and 30 days for the estimation window. (You can of course change these numbers to suit your analysis.)
by company_id: gen event_window=1 if dif>=-2 & dif<=2
egen count_event_obs=count(event_window), by(company_id)
by company_id: gen estimation_window=1 if dif<-30 & dif>=-60
egen count_est_obs=count(estimation_window), by(company_id)
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.
The procedure for determining the event and estimation windows is the same. First we create a variable that equals 1 if the observation is within the specified days. Second, we create another variable that counts how many observations, within each company_id, has a 1 assigned to it. Finally, we replace all the missing values with zeroes, creating a dummy variable. You can now determine which companies do not have a sufficient number of observations.
tab company_id if count_event_obs<5
tab company_id if count_est_obs<30
The "tab" will produce a list of company_ids that do not have enough observations within the event and estimation windows, as well as the total number of observations for those company_ids. To eliminate these companies:
drop if count_event_obs < 5
drop if count_est_obs < 30
You should make sure the dataset has been saved under a different name before dropping any observations!
At this point you can also drop some variables you won't need any longer: count_event_obs and count_est_obs.
Estimating Normal Performance
Now we are at the point where we can actually start an analysis. First we need a way to estimate Normal Performance. To do this, we will run a seperate regression for each company using the data within the estimation window and save the alphas (the intercept) and betas (the coefficient of the independent variable). We will later use these saved regression equations to predict normal performance during the event window.
Note that return, the dependent variable in our regression, is simply the CRSP variable for a given stock's return, while the independent variable vretd that we use to predict ret is the value-weighted return of an index for whatever exchange the stock trades on. Use the equivalent variables for your dataset
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)N { /*note: replace N with the highest value of id */
        l id company_id if id==`i' & dif==0  *其中l是list的意思
        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
}  
Here, we created a variable "id" that numbers the companies from 1 to however many there are. The N is the number of company-event combinations that have complete data. This process iterates over the companies, runs a regression in the estimation window for each, and then uses that regression to predict a 'normal' return in the event window.
Abnormal and Cumulative Abnormal Returns
We can now calculate the abnormal and cumulative abnormal returns for our data. The daily abnormal return is computed by subtracting the predicted normal return from the actual return for each day in the event window. The sum of the abnormal returns over the event window is the cumulative abnormal return.
sort id date
gen abnormal_return=ret-predicted_return if event_window==1
by id: egen cumulative_abnormal_return = sum(abnormal_return)
Here we simply calculate the abnormal return for each observation in the event window. Then we set the cumulative abnormal return equal to the sum of the abnormal returns for each company.
Testing for Significance
We are going to compute a test statistic, test, to check whether the average abnormal return for each stock is statistically different from zero.*

TEST= ((ΣAR)/N) / (AR_SD/sqrt(N))
where AR is the abnormal return and AR_SD is the abnormal return standard deviation. If the absolute value of test is greater than 1.96, then the average abnormal return for that stock is significantly different from zero at the 5% level. The value of 1.96 comes from the standard normal distribution with a mean of 0 and a standard deviation of 1. 95% of the distribution is between ±1.96.
sort id date
by id: egen ar_sd = sd(abnormal_return)
gen test =(1/sqrt(number of days in event window)) * ( cumulative_abnormal_return /ar_sd)
list company_id cumulative_abnormal_return test if dif==0
Note: this test uses the sample standard deviation. A less conservative alternative is to use the population standard deviation. To derive this from the sample standard deviation produced by Stata, multiply ar_sd by the square root of n-1/n; in our example, by the square root of 4/5.
This will output the results of your event study into an Excel-readable spreadsheet file:
outsheet  company_id event_date cumulative_abnormal_return test using stats.csv if dif==0, comma names
Testing Across All Events
Instead of, or in addition to, looking at the average abnormal return for each company, you probably want to calculate the cumulative abnormal for all companies treated as a group. Here's the code for that:
reg cumulative_abnormal_return if dif==0, robust
The P-value on the constant from this regression will give you the significance of the cumulative abnormal return across all companies. This test preferable to a t-test because it allows you to use robust standard errors.
Further Reading
Capital Market Responses To Environmental Performance In Developing Countries, section t hree: Event Study Methodology, working paper from the World Bank
Note
* Thank you to Kim Baum for useful feedback

使用道具

tracy3768 发表于 2015-5-12 15:26:58 |显示全部楼层 |坛友微信交流群
同困惑啊,哈哈,求指导!

使用道具

楼主,会了吗,同困惑,求解答

使用道具

qianmen3 发表于 2016-6-19 18:59:13 |显示全部楼层 |坛友微信交流群
仅供参考~~
Step 1: Cleaning the data and Calculating the Event and Estimation Windows
cd c:\stata14\data\实证公司金融作业
use "repurchase class",clear
joinby gvkey using "crsp daily 07-09 new ret"
sort gvkey InitialAuthDate datadate
by gvkey InitialAuthDate: gen datenum=_n
by gvkey InitialAuthDate: gen target= datenum if datadate== InitialAuthDate
by gvkey InitialAuthDate: egen td=min(target)
label variable td "by gvkey InitialAuthDate: egen td=min(target)"
gen dif= datenum-td
by gvkey InitialAuthDate: gen estimation_window=1 if dif<-150 & dif>=-250
label variable estimation_window"by gvkey: gen estimation_window=1 if dif<-150 & dif>=-250"
replace estimation_window=0 if estimation_window==.
by gvkey InitialAuthDate: gen event_window=1 if dif>=-1 & dif<=1
label variable event_window"by gvkey: gen event_window=1 if dif>=-1 & dif<=1"
replace event_window=0 if event_window==.
by gvkey InitialAuthDate, sort: egen max_event_window=max( event_window)
count if max_event_window==0
drop if max_event_window==0
by gvkey InitialAuthDate, sort: egen max_est_window=max( estimation_window)
count if max_est_window==0
drop if max_est_window==0
count if target!=.
save "c:\stata14\data\实证公司金融作业\event_study_repurchase_class.dta"
merge m:1 datadate using "c:\stata14\data\实证公司金融作业\mkt index small.dta"
drop if _merge==2
rename _merge merge_mkt_index
sort gvkey InitialAuth datadate
Step 2: Estimating Normal Performance
egen id=group(gvkey InitialAuthDate)
gen pre_ret=.
drop if event_window==0 & estimation_window==0
forvalues i=1(1)797 {
qui reg ret vwretd if id==`i' & estimation_window==1
qui predict p if id==`i'
qui replace pre_ret=p if id==`i' & event_window==1
drop p
}
Step 3: Abnormal and Cumulative Abnormal Returns
gen abn_ret= ret-pre_ret if event_window==1
sort id datadate
by id: egen cum_abn_ret=sum( abn_ret) if event_window==1
label variable pre_ret"predicted value from market model"
label variable abn_ret"= ret-pre_ret if event_window==1"
label variable cum_abn_ret"by id: egencum_abn_ret=sum( abn_ret) if event_window==1"
Step 4:Testing for Significance
ttest cum_abn_ret=0
reg cum_abn_ret, robust

使用道具

tkt718 发表于 2016-7-6 01:05:29 来自手机 |显示全部楼层 |坛友微信交流群
lhjnju 发表于 2014-4-14 22:01
在公司金融学上,经常要计算CAR。例如在某个事件点的股市超额回报率。我最近在做毕业论文,要根据我国上市公 ...
赞一个!厉害

使用道具

fxq2327 学生认证  发表于 2016-10-20 16:34:14 |显示全部楼层 |坛友微信交流群
请问你解决“一个公司一年内有若干并购,过滤一条记录信息会影响另一条记录计算,怎么办?
怎么一次把所有信息计算出来?”这个问题了吗?如果解决,请教教我,有报酬!

使用道具

水绕苇丛 发表于 2016-10-20 17:09:47 |显示全部楼层 |坛友微信交流群
我能想到的一个变通办法是:
(1)筛选出一年内只有一次并购的公司,按照老办法做
(2)对于存在多次并购的公司,把其变成多个一年一次并购的样本,沿用上面的老办法

使用道具

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

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

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

GMT+8, 2024-12-6 07:27