Hi!
I´m conducting an event study using the following code, however, I´m getting invalid syntax for the "reg ret" command. We are using data for 162 companies' stock prices over ten days and an estimation window of 100 days.
This is our code:
clear
cd "U:\Downloads\masterthesis"
import excel "cuppsatsnyversion", clear first
destring _all, force replace
foreach var of varlist _all {
cap rename `var' `=substr("`var'", 1, 10)'
}
drop CANADAGOOSEHDGNYSSBNTDVT SILVANOFASHGROUPWARU FOOTWAYGROUPPFSHSU GENTILIU GMLEATHERS GROUNDEDPE
rename _all price=
rename priceName date
* Reshape the dataset to long format
reshape long price, i(date) j(company) string
sort company date
* Create a unique identifier for each company and set the panel structure
by company: gen datenum = _n
by company: gen target = datenum if date==22825
egen td = min(target), by(company)
drop target
gen dif = datenum-td
by company: gen event_window = 1 if dif > -10 & dif < 10
egen count_event_obs = count(event_window), by(company)
by company: gen estimation_window = 1 if dif < -10 & dif > -100
egen count_est_obs = count(estimation_window), by(company)
replace event_window = 0 if event_window == .
replace estimation_window = 0 if estimation_window == .
tab company if count_event_obs < 5
tab company if count_est_obs < 30
gen predicted_return = .
su company, meanonly
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}
Regards,
Esther
I´m conducting an event study using the following code, however, I´m getting invalid syntax for the "reg ret" command. We are using data for 162 companies' stock prices over ten days and an estimation window of 100 days.
This is our code:
clear
cd "U:\Downloads\masterthesis"
import excel "cuppsatsnyversion", clear first
destring _all, force replace
foreach var of varlist _all {
cap rename `var' `=substr("`var'", 1, 10)'
}
drop CANADAGOOSEHDGNYSSBNTDVT SILVANOFASHGROUPWARU FOOTWAYGROUPPFSHSU GENTILIU GMLEATHERS GROUNDEDPE
rename _all price=
rename priceName date
* Reshape the dataset to long format
reshape long price, i(date) j(company) string
sort company date
* Create a unique identifier for each company and set the panel structure
by company: gen datenum = _n
by company: gen target = datenum if date==22825
egen td = min(target), by(company)
drop target
gen dif = datenum-td
by company: gen event_window = 1 if dif > -10 & dif < 10
egen count_event_obs = count(event_window), by(company)
by company: gen estimation_window = 1 if dif < -10 & dif > -100
egen count_est_obs = count(estimation_window), by(company)
replace event_window = 0 if event_window == .
replace estimation_window = 0 if estimation_window == .
tab company if count_event_obs < 5
tab company if count_est_obs < 30
gen predicted_return = .
su company, meanonly
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}
Regards,
Esther
Comment