-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathEventStudy.do
129 lines (86 loc) · 4.32 KB
/
EventStudy.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import excel "/Users/tatev/Downloads/data.xlsx", sheet("Request file") firstrow
**************************************************************************************************
*generating company id
**************************************************************************************************
gen id = _n
sort Firm_id
by Firm_id: gen company_id = 1 if _n == 1
replace company_id = sum(company_id)
replace company_id = . if missing(Firm_id)
drop if date ==.
**************************************************************************************************
* making the window to [-100, 100]
**************************************************************************************************
gen daily_window_start = dofd(window_start)
gen daily_window_end = dofd(window_end)
gen window_start_100 = daily_window_start + 150
gen window_end_100 = daily_window_end - 150
format daily_window_start daily_window_end window_start_100 window_end_100 %td
**************************************************************************************************
* we need to make sure that only observations in between the the right window time period are used
**************************************************************************************************
keep if ((date > window_start) & (date < window_end))
keep if company_id == 2
gen time = _n
tsset time
**************************************************************************************************
*per firm we wanna run OLS to detrmine gamma_i for only single company e.g. company 1
**************************************************************************************************
reg Firm_return Market_Return event_date if company_id == 2
**************************************************************************************************
*we can use stata's for loop type of approach to do this for all 45 companies
**************************************************************************************************
forvalues i = 2/45{
regress Firm_return Market_Return event_date if company_id == `i'
}
**************************************************************************************************
*what are the firm_ids(string from original data) corresponding to the integers in company_id
**************************************************************************************************
bysort company_id: tab Firm_id
**************************************************************************************************
*Garch(1,1) 1 garch 1 arch model
**************************************************************************************************
* we need the previous residuals and previous error terms from the first equations
clear all
import excel "/Users/tatev/Downloads/DATA_LONGWINDOWFINAL.xlsx", sheet("Window-250,250") firstrow clear
gen id = _n
sort Firm_id
by Firm_id: gen company_id = 1 if _n == 1
replace company_id = sum(company_id)
replace company_id = . if missing(Firm_id)
drop if date ==.
keep if ((date > window_start) & (date < window_end))
keep if company_id == `i'
gen time = _n
tsset time
reg Firm_return Market_Return event_date
*creating residuals
predict resid, residuals
*variance model using
arch resid event_date , arch(1/1) garch(1/1)
**************************************************************************************************
*Obtaining test statistics
**************************************************************************************************
*number of unique companies in our simple
gen n =_N
gen test1_gamma_numerator = sum(gamma_i/n)
**************************************************************************************************
*We need the residuals at time period 0 for each company for calculating adjusted test statistics
**************************************************************************************************
clear all
import excel "/Users/tatev/Downloads/DATA_LONGWINDOWFINAL.xlsx", sheet("Window-250,250") firstrow clear
gen id = _n
sort Firm_id
by Firm_id: gen company_id = 1 if _n == 1
replace company_id = sum(company_id)
replace company_id = . if missing(Firm_id)
drop if date ==.
keep if ((date > window_start) & (date < window_end))
keep if Firm_id == "24MYL"
gen time = _n
tsset time
reg Firm_return Market_Return event_date
*creating residuals
predict resid, residuals
tabulate resid if event_date == 1
tabulate Firm_id