Hello! I have a panel dataset with around 10000 companies and I want to perform rolling regressions while obtaining the variance of the residuals for each regression performed. I can't use the rolling command and e(rmse) as the regressions suffer from heteroscedasticity and as such rmse is not the standard deviation of the residuals.
I would like to do something like this:
First window:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 1st cell
Second window:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 2nd cell
And keep going like this.
I probably need to write this in code but unfortunately I have never coded in stata before.
Please help either by providing an alternative way of doing this (as it seems rolling cannot) or by helping me code it.
Thank you in advance!
I would like to do something like this:
First window:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 1st cell
Second window:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 2nd cell
And keep going like this.
I probably need to write this in code but unfortunately I have never coded in stata before.
Please help either by providing an alternative way of doing this (as it seems rolling cannot) or by helping me code it.
Thank you in advance!
Comment