Hello,
I have a panel data set with daily stock returns across a bunch of firms. I would like to estimate daily alphas (constant) and betas using the Fama French 3-Factor model with a rolling window of 250 days. As the rolling command in STATA takes ages, I use the -fastreg- command from Geertsema (see https://papers.ssrn.com/sol3/papers....act_id=2423171).
I do not manage to adjust the code in that it stores standard errors or t-stats after each regression.
Can anyone help me how to do that in STATA? The code that I use is as follows:
**rolling window betas**
gen mktrf_beta = .
gen smb_beta = .
gen hml_beta = .
gen _cons_beta = .
gen mktrf_beta_f = .
gen smb_beta_f = .
gen hml_beta_f = .
gen _cons_beta_f = .
local maxobs = 400000
local window = 250
timer clear
timer on 1
forvalues k = `window'/`maxobs' {
local first = `k'-`window'+1
local last = `k'
if permno[`last'] == permno[`first'] {
* if window covers same permno, then do estimation
qui fastreg eret mktrf smb hml in `first'/`last'
* save coefficients
foreach x in mktrf smb hml _cons {
qui replace `x'_beta_f = _be[`v'] in `last'
}
}
}
timer off 1
timer list 1
Thank you so much for your help.
Best,
Luce
I have a panel data set with daily stock returns across a bunch of firms. I would like to estimate daily alphas (constant) and betas using the Fama French 3-Factor model with a rolling window of 250 days. As the rolling command in STATA takes ages, I use the -fastreg- command from Geertsema (see https://papers.ssrn.com/sol3/papers....act_id=2423171).
I do not manage to adjust the code in that it stores standard errors or t-stats after each regression.
Can anyone help me how to do that in STATA? The code that I use is as follows:
**rolling window betas**
gen mktrf_beta = .
gen smb_beta = .
gen hml_beta = .
gen _cons_beta = .
gen mktrf_beta_f = .
gen smb_beta_f = .
gen hml_beta_f = .
gen _cons_beta_f = .
local maxobs = 400000
local window = 250
timer clear
timer on 1
forvalues k = `window'/`maxobs' {
local first = `k'-`window'+1
local last = `k'
if permno[`last'] == permno[`first'] {
* if window covers same permno, then do estimation
qui fastreg eret mktrf smb hml in `first'/`last'
* save coefficients
foreach x in mktrf smb hml _cons {
qui replace `x'_beta_f = _be[`v'] in `last'
}
}
}
timer off 1
timer list 1
Thank you so much for your help.
Best,
Luce
Comment