How To Calculate The (Cumulative) Abnormal Returns?

How To Calculate The (Cumulative) Abnormal Returns?
What?
This course is linked to the instruction given in video #22 on www.studyland.nl.
Follow your tutor and perform pre-specified, step-by-step tasks to ensure you
finish data processing and data analyzing techniques very quickly! This task should
take you less one hour of work. Woah!
Goal?
You will calculate the abnormal returns (AR) from the stock price return data, by
estimating the market model for the estimation window (-170, -20). You will also
calculate the betas. Finally, you will learn how to calculate the cumulative
abnormal returns (CAR) for the event window (-10, +10).
Software?
You will have to use Stata. Any version is ok. However I will put the Stata data file
of version 13.0. Please note that Stata 13.0 cannot open later versions of Stata, I
also add the Excel files, just in case you cannot open my files in Stata. I already
have shown in video #3 how to import Excel files in Stata.
Remember: Follow the video instructions accompanied with this tutorial exactly
and you will get the ARs and CARs within a short time!
Page 1 of 10
DATA 1: Download & Rename the Event Stata data file!
a) I’ve downloaded the announcement dates Excel data from Thomson One
Banker database (TOB) on www.thomsonone.com and imported in Stata. You
need the following variables (make sure the variables afterwards are spelled
exactly this way):
Variable
PERMNO
DateAnnounced
Description
Firm identifier
Announcement date
b) Save this event/announcement dates Stata file as Event_data.dta. This is to
make sure we do not get errors if we’re going to merge the data sets.
c) Make sure PERMNO is a numeric variable, since TOB database may give you
the string (text) format. To make sure you have the correct format, type in
Stata’s command field (copy both lines and paste):
destring PERMNO, replace
save Event_data, replace
d) Make sure DateAnnounced is in the Stata’s date format, otherwise you’ll
encounter an error while making the estimation and event windows. How to
check this? Type in the following in Stata’s command field:
describe DateAnnounced
You have to see in the output that display format of DateAnnounced is %td:
If you don’t see %td, then watch video #23 to transform DateAnnounced to
dates.
Page 2 of 10
DATA 2: Download & Rename the Returns Stata data file!
a) I have downloaded the S&P500 firms’ stock price return data from Wharton’s
database CRSP on https://wrds-web.wharton.upenn.edu. You can export it
directly as a Stata file! You need the variables (Make sure the variables
afterwards are spelled exactly this way):
Variable
Description
PERMNO
Daily_date
Returns
SnP_Returns
Firm identifier
Daily dates
Firms’ stock returns
S&P500 Index returns
b) Save this Stata file as CRSP_return_data.dta. This is to make sure we do not
get errors if we’re going to merge the data sets.
c) Make sure PERMNO is a numeric variable, since CRSP database may give you
the string (text) format. To make sure you have the correct format, type in
Stata’s command field (copy both lines and paste):
destring PERMNO, replace
save CRSP_return_data.dta, replace
d) Make sure Daily_date is in the Stata date format, otherwise you will encounter
an error while attempting to make the estimation and event windows. How to
check this? Type in the following in Stata’s command field:
describe Daily_date
You have to see in the output that Daily_date’s display format is %td. CRSP
always gives the correct date formats, so don’t worry:
Page 3 of 10
PART 1: In which directory are your Stata files?
a) Open Stata.
b) Open a new Do-file. Click on <<file>>, <<New>>, and <<Do-file>>.
c) Put the following lines in respectively lines 5 and 6:
clear all
set more off
d) Find the directory where you saved your Stata files. Simply open the folder
where the Stata files are, point your mouse on the Stata file, right click the
mouse, click properties or info, find the address and copy.
For example my Stata files are located in the folder on the address:
/Volumes/ATILLA/Screencasting/Videos/STATA/video #22 (Cumulative)
Abnormal Returns/Stata/Tutorial 1 - Calculate CARs from scratch
e) Paste in line 16 of the Do-file the address you just copied. Put cd in front of the
address and add quotation marks (“ ”) in front and back of the address, like
this:
cd "/replace with Stata files folder/"
in my case this becomes:
cd "/Volumes/ATILLA/Screencasting/Videos/STATA/video #22
(Cumulative) Abnormal Returns/Stata/Tutorial 1 - Calculate CARs from
scratch"
Page 4 of 10
PART 2: Count the number of event dates per firm!
a) Open the Event_data.dta file. Put the following code in line 28 of the Do-file:
use Event_data, clear
b) Copy all the codes below and paste it into line 30 of the Do-file:
// STEP 1
bys PERMNO: gen sub_id = _n
bys PERMNO: egen max_number_events = max(sub_id) // Make a column of
the maximum number of events per firm
order sub_id max_number_events // To put columns in the order you
like
save Event_data_temp, replace // Save this Event_data as
Event_data_temp
c) Copy all the codes below and paste it into line 37 of the Do-file:
/* STEP 2
You need the max_number_events column from STEP 1 to know how many
events a form has
This number is needed to tell the Return data, to make as many
duplicates
You need this because if you merge returns with event dates, you
want to treat each
event date as a different firm to assign the same daily returns of
that firm */
duplicates drop PERMNO, force
keep PERMNO max_number_events // You only need these 2 columns for
now
Page 5 of 10
PART 3: Merge Return data with Event data!
a) Copy all the codes below and paste it into line 55 of the Do-file:
/* STEP 3
Merge the 2 columns from STEP 2 with you return data
It is 1:m merge because the current data has unique PERMNO and
return data has daily data for the same PERMNO */
merge 1:m PERMNO using CRSP_return_data
keep if _merge==3 // Keep successful matches!
drop _merge // Don't need this anymore.
b) Copy all the codes below and paste it into line 63 of the Do-file:
/* STEP 4
expand: Tell Stata how many duplicates of a firm you need
You need this because some firms have multiple event dates
Each of these event dates are treated as "new" or unique firms to
assign the same daily returns from that firm */
expand max_number_events
bys PERMNO Daily_date: gen sub_id = _n
sort PERMNO sub_id Daily_date
order sub_id
c) Copy all the codes below and paste it into line 74 of the Do-file:
/* STEP 5
Merge the return data with the Event_data_temp data set */
merge m:1 PERMNO sub_id using Event_data_temp
keep if _merge==3 // Keep successful matches!
drop _merge max_number_events // Don't need these anymore.
Page 6 of 10
PART 4: Construct the estimation & event windows
a) You will generate the (-170,-20) estimation window and (-10,+10) event
window. Copy all the codes below and paste it into line 92 of the Do-file:
egen id = group(PERMNO sub_id) // Make a unique idea for each firmevent combination
order id // Put this id in front of all columns
drop sub_id // Drop the older id, namely sub_id
gen dummy_announce_before_date = (DateAnnounced<Daily_date)
bys id:
bys id:
replace
bys id:
replace
replace
g j = _n if Daily_date < DateAnnounced
egen N = max(j)
j = j - N - 1
replace j = _n if Daily_date > DateAnnounced
j = j - N - 1 if Daily_date > DateAnnounced
j = 0 if Daily_date == DateAnnounced
order id-DateAnnounced j dummy_announce_before_date
gen estimationwindow= inrange(j,-170,-20)
gen eventwindow = inrange(j,-10,10)
gen estimationwindow_day = j if estimationwindow
gen event_window_day = j if eventwindow==1
bys id: gen subid = _n
order id subid
bys id: egen count_event_days = count(event_window_day)
bys id: gen max_days_in_window = count_event_days if subid==1
tab max_days_in_window // Distribution of the NUMBER of days within
a specific event window
qui su count_event_days
keep if count_event_days==r(max) // Keep only the complete event
windows
egen id2 = group(id)
drop id
rename id2 id
Page 7 of 10
PART 5: CALCULATE ABNORMAL RETURNS & BETAS
a) You will estimate the market model for the (-170,-20) estimation window and
compute the abnormal returns (ARs) for the (-10,+10) event window. Copy all
the codes below and paste it into line 126 of the Do-file:
gen AR=.
gen alphas=.
gen betas=.
su id
local maxid = r(max)
forval i=1/`maxid' {
di "Regression " `i' " of " `maxid' " ... To stop click Break button
on top of this window"
cap qui reg Returns SnP_Returns if estimationwindow==1 & id==`i'
cap replace AR = Returns - _b[_cons] _b[SnP_Returns]*SnP_Returns if eventwindow==1 & id==`i'
cap replace alphas = _b[_cons] if estimationwindow==1 & id==`i'
cap replace betas = _b[SnP_Returns] if estimationwindow==1 &
id==`i'
} //End of code
Page 8 of 10
PART 6: Calculate CAR(-10,+10): Cumulative sum of the ARs from PART 5
a) You will calculate the Cumulative Abnormal Returns (CARs) for the event
window (-10,+10). Namely this is just the cumulative sum of the Abnormal
Returns (ARs) for the event window (-10,+10) that you have calculated in PART
5. Copy the code below and paste it into line 156 of the Do-file:
bys id: egen CAR=sum(AR) if eventwindow==1
Page 9 of 10
PART 7: Calculate Average Abnormal Returns (AAR) and Average Cumulative
Abnormal Returns (CAAR) for (-10,+10) + T-Test
This part is supplementary and is not covered in the video.
Copy the code below and paste it into line 160 of the Do-file select this code and
click on the Do button:
egen nr_of_stocks = group(id)
qui su nr_of_stocks
replace nr_of_stocks = r(max)
// Calculate the Average Abnormal Returns (AAR) per event window day
across all stocks
// Calculate the standard deviation S_AAR per event window day across
all stocks
// Calculate the t-statistic
bys j: egen AAR = mean(AR)
bys j: egen S_AAR = sum((AR - AAR)^2)
replace S_AAR = sqrt(S_AAR/(nr_of_stocks-1))
g t_AAR = sqrt(nr_of_stocks)*AAR/S_AAR
sort id j
g significant_t_AAR = "YES" if abs(t_AAR)>=1.96 & !missing(t_AAR)
replace significant_t_AAR = "NO" if abs(t_AAR)<1.96 & !missing(t_AAR)
// Calculate the Cumulative Average Abnormal Returns (CAAR) across the
sample
// Calculate the standard deviation S_CAAR across the sample
// Calculate the t-statistic
bys id: egen CAAR = sum(AAR)
egen S_CAAR = sum((CAR - CAAR)^2)
replace S_CAAR = sqrt(S_CAAR/(nr_of_stocks-1))
g t_CAAR = sqrt(nr_of_stocks)*CAAR/S_CAAR
g significant_t_CAAR = "YES" if abs(t_CAAR)>=1.96
replace significant_t_CAAR = "NO" if abs(t_CAAR)<1.96
Page 10 of 10