I have an unbalanced panel dataset with daily (financial) data for ±500 companies.
The following is what I'm trying to execute in Stata:
- Running a rolling window fixed effects (fe) regression over 51 days;
- per day and company in my dataset, and;
- FIRST) for all the companies,
- SECOND) for the companies with "1" as dummy variable value,
- THRID) for the companies with "0" as dummy variable value.
- per day and company in my dataset, and;
- Per estimated fe regression, predict the residuals and save them as a new variable in the existing dataset
The eventual goal is to have an overview of the independent variable's coefficients on a day as calculated over the preceding 51 days and with the corresponding residuals as well.
My attempts:
First: I tried the 'rolling' command, but with +500 companies and a dataset covering ±2400 days this is taking too long.
Second: the asreg command isn't supporting 'xtreg' commands and thus doesn't allow me to run a rolling fe regression.
Third: using a loop with 'foreach'. The code I'm written is included below, but yields an error saying 'insufficient observations'.
Code:
xtset SedolID NDaysSince
levelsof SedolID, local(IDlist)
foreach i of local IDlist {
xtreg y x x x x x if NDaysSince>`i' & NDaysSince<52+`i' & Dummy_Var==1, fe
predict residual_`i', resid
estsave reg_`i'
}
My Questions:
- Is it possible to have Stata regress fe with rolling window starting with the most recent date and 'rolling' toward older observations? How to I get Stata to compute the above described regressions?
Christian
0 Response to Panel Data: Rolling window; fixed effects regression; saving coefficients and predicted residuals
Post a Comment