That last line simply runs -regress- w/o covariates, which is equivalent to
a t-test. The robust option -which the text describes as the major advantage
over the t-test- does not make any difference here.
****
sysuse auto, clear
reg pr, nohead
reg pr, robust nohead
ttest pr==0
****
I have cleaned the code if anyone wants to chime in. First time through the
code, you have to comment in those first two -use- and -save- commands to
get your hands on the datasets. Be warned, the second dataset takes a
considerable amount of time to download...
****
//from
http://dss.princeton.edu/usingdata/stata/analysis/eventstudydataprep.html
/*
set memory 200m
use http://dss.princeton.edu/sampleData/eventdates.dta /* about 11k */
save eventdates, replace
use http://dss.princeton.edu/sampleData/stockdata.dta, clear /* about 90m
*/
save stockdata, replace
*/
clear*
use eventdates, clear
by company_id: gen eventcount=_N
by company_id: keep if _n==1
sort company_id
keep company_id eventcount
save eventcount, replace
use stockdata, clear
sort company_id
merge company_id using eventcount
tab _merge
keep if _merge==3
drop _merge
expand eventcount
drop eventcount
sort company_id date
by company_id date: gen set=_n
sort company_id set
save stockdata2, replace
use eventdates, clear
by company_id: gen set=_n
sort company_id set
save eventdates2, replace
use stockdata2, clear
merge company_id set using eventdates2
tab _merge
list company_id if _merge==2
keep if _merge==3
drop _merge
egen group_id = group(company_id set)
******************
// from
http://dss.princeton.edu/usingdata/stata/analysis/eventstudy.html#test2
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
// gen dif=date-event_date
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==.
tab company_id if count_event_obs<5
tab company_id if count_est_obs<30
drop if count_event_obs < 5
drop if count_est_obs < 30
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) */
su id, mean
qui forvalues i=1(1)`=r(max)' { /*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
}
sort id date
gen abnormal_return=ret-predicted_return if event_window==1
by id: egen cumulative_abnormal_return = sum(abnormal_return)
* test = (1/n SAR)/(AR_SD)
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
// 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
****
HTH
Martin
_______________
----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, June 03, 2009 5:06 PM
Subject: st: Event studies significance test
Dear Statalist,
I have a question about testing the significance across all events. I
copied the text, that is on the stata website:
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.
My question: How is this test called, that is used here and why is it
better than a t-test?
Thank you very much
Lisa
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/