I'd like to derive a Z-statistic by means of the Patell test (https://www.eventstudytools.com/sign...e-tests#Patell). Unfortunately, I did not found an option within Stata to perform the test or found any material on the forum. Is there anyone who's got either a command to use or code to execute? I've tried the code underneath, but is does not seem to provide good values (CAR: cumulative abnormal returns/AR: abnormal return/CAAR: cumulative average abnormal return).
Thanks in advance,
Paul
Code:
gen temp123=1
levelsof temp123, local(123)
foreach id of local 123{
by ticker: egen s2_short_`id' = sd(logret) if estimation_window_short`id'==1
by ticker: egen L_short_`id' = count(logret) if estimation_window_short`id'==1
by ticker: egen aRM_short_`id' = mean(logret) if estimation_window_short`id'==1
by ticker: egen R_short_`id' = max(logret) if eventid==`id' &estimation_window_short`id'==1
}
foreach id of local 123{
by ticker: gen Rsum_short_t_`id' = logret-aRM_short_`id' if estimation_window_short`id'==1
}
foreach id of local 123{
by ticker: egen Rsum_short_`id' = sum(Rsum_short_t_`id'^2) if estimation_window_short`id'==1
}
foreach id of local 123{
drop Rsum_short_t_`id'
}
//3.10.1.2 Part-by-part calculation of statistic
//(Rmt-ARm)^2
foreach id of local 123{
gen part1_s_`id' = R_short_`id'- aRM_short_`id' if estimation_window_short`id'==1
replace part1_s_`id' = part1_s_`id'^2 if estimation_window_short`id'==1
}
//(Rmt-ARm)^2/sum(Rmt-ARm)^2
foreach id of local 123{
gen part2_s_`id' = part1_s_`id'/Rsum_short_`id' if estimation_window_short`id'==1
}
//1+(1/L)+(part2)
foreach id of local 123{
gen part3_s_`id' = 1+(1/L_short_`id')+part2_s_`id' if estimation_window_short`id'==1
}
//s2(part3)^0.5
foreach id of local 123{
gen part4_s_`id' = sqrt(s2_short_`id'*part3_s_`id') if estimation_window_short`id'==1
}
foreach id of local 123{
by ticker: replace part4_s_`id' = part4_s_`id'[_n-1] if missing(part4_s_`id')&event_window_short`id'==1
}
//3.10.1.3 Standardize abnormal returns Patell short
foreach id of local 123{
gen AR_sd_s_pat`id' =. if estimation_window_short`id'==1
}
foreach id of local 123{
replace AR_sd_s_pat`id' = abnormal_return_short`id'/part4_s_`id' if event_window_short`id'==1
}
//3.10.1.4 Drop variables
foreach id of local 123{
drop R_short_`id' aRM_short_`id' L_short_`id' s2_short_`id' part1_s_`id' part2_s_`id' part3_s_`id' part4_s_`id'
}
save temp11.dta, replace
//3.10.2 Cummulate standardized Patell abnormal returns short
use temp11.dta, clear
foreach id of local 123 {
by ticker: egen CAR_pat_t_s`id'= sum(AR_sd_s_pat`id') if event_window_short`id'==1
}
foreach id of local 123 {
by ticker: gen CAR_pat_s`id' = CAR_pat_t_s`id'*(1/(sqrt(3))) if event_window_short`id'==1
}
//3.10.3 Derive Patell Z-statistic
foreach id of local 123 {
egen CAAR_P_s`id'= mean(CAR_pat_s`id') if eventid==`id'
}
foreach id of local 123 {
egen No_CAAR_P_s`id'= count(CAAR_P_s`id')
replace No_CAAR_P_s`id'= sqrt(No_CAAR_P_s`id')
}
foreach id of local 123 {
gen test_P_s`id'= CAAR_P_s`id'* No_CAAR_P_s`id'
}

0 Response to Code of Patell Z-statistic
Post a Comment