Dear Stata Community,
I'm hoping to get some guidance with calculating the test statistic for my event study analysis. I'm aiming to compute for each company_id the value of test statistic using the formula cumulative_abnormal_return/sqrt(5)*ar_sd.
Context:
The problem I'm facing is that Stata generates the test variable but leaves it empty (without any values). This prevents me from calculating the desired test statistic (cumulative_abnormal_return/sqrt(5)*ar_sd).
code snippet:
clear
import excel "/Users/...per stata.xlsx", sheet("Foglio2") firstrow clear
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
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<-40 & dif>=-240
egen count_est_obs=count(estimation_window), by(company_id)
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.
gen predicted_return=.
egen id=group(company_id)
forvalues i=1(1) 332{
l id company_id if id==`i' & dif==0
reg ret market_ret if id==`i' & estimation_window==1
predict p if id==`i'
replace predicted_return = p if id==`i'
drop p
}
sort id date
gen abnormal_return=ret-predicted_return
by id: egen cumulative_abnormal_return = sum(abnormal_return) if event_window==1
sort id date
sort company_id
by company_id: gen sporca=1 if dif<=-3 & dif>=-40
by company_id: egen ar_sd = sd(abnormal_return) if sporca==1
egen std=min(ar_sd), by(company_id)
Unfortunatly the data file that I'm using is too heavy, I post a screenshot with the basic elements
Any guidance you can offer would be greatly appreciated.
Thank you for your time and assistance!
I'm hoping to get some guidance with calculating the test statistic for my event study analysis. I'm aiming to compute for each company_id the value of test statistic using the formula cumulative_abnormal_return/sqrt(5)*ar_sd.
Context:
- I'm working on an event study to assess the impact of an event on various companies (company_id).
- I've successfully completed the initial stages of the analysis, as shown in the provided code snippet.
- The code calculates the cumulative abnormal return (CAR) for each company around the event window.
- I've also computed the standard deviation of abnormal returns (AR_SD) for a specific estimation window.
The problem I'm facing is that Stata generates the test variable but leaves it empty (without any values). This prevents me from calculating the desired test statistic (cumulative_abnormal_return/sqrt(5)*ar_sd).
code snippet:
clear
import excel "/Users/...per stata.xlsx", sheet("Foglio2") firstrow clear
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
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<-40 & dif>=-240
egen count_est_obs=count(estimation_window), by(company_id)
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.
gen predicted_return=.
egen id=group(company_id)
forvalues i=1(1) 332{
l id company_id if id==`i' & dif==0
reg ret market_ret if id==`i' & estimation_window==1
predict p if id==`i'
replace predicted_return = p if id==`i'
drop p
}
sort id date
gen abnormal_return=ret-predicted_return
by id: egen cumulative_abnormal_return = sum(abnormal_return) if event_window==1
sort id date
sort company_id
by company_id: gen sporca=1 if dif<=-3 & dif>=-40
by company_id: egen ar_sd = sd(abnormal_return) if sporca==1
egen std=min(ar_sd), by(company_id)
Unfortunatly the data file that I'm using is too heavy, I post a screenshot with the basic elements
Any guidance you can offer would be greatly appreciated.
Thank you for your time and assistance!
Comment