Dear all
I am looking for two alternatives to calculate fitted values and residuals (The dependent variable is ret and the independent variables are x y z ) from :
1- a rolling 5 year regression:
Here I want to run a regression using data from the most recent 5 years and calculate the fitted and residual, then move one year forward and drop one year and then calculate the fitted and residual. I understand that I will be able to calculate the fitted and residual values starting from the fifth year in this case.
In this option, can I do something like:
rolling _b[constant] _b[x] _b[y] _b[z] , window(5) : reg ret x y z
gen fitted=_b[_cons]+_b[x]+_b[y]+_b[z]
gen residual= ret-fitted
2- a recursive regression that adds one year each time
Here I want to run a regression using data from the most recent 5 years, calculate the fitted and residual values, then move one year forward WITHOUT dropping a year, i.e. the regression will be subsequently estimated for 6 years, then 7 years, then 8 years, and so one. I also want to calculate the fitted and residual values each time the regression is estimated.
In the second option, can I do something like:
rolling _b[constant] _b[x] _b[y] _b[z] , window(5) recursive : reg ret x y z
gen fitted=_b[_cons]+_b[x]+_b[y]+_b[z]
gen residual= ret-fitted
Thanks in a dvance
I am looking for two alternatives to calculate fitted values and residuals (The dependent variable is ret and the independent variables are x y z ) from :
1- a rolling 5 year regression:
Here I want to run a regression using data from the most recent 5 years and calculate the fitted and residual, then move one year forward and drop one year and then calculate the fitted and residual. I understand that I will be able to calculate the fitted and residual values starting from the fifth year in this case.
In this option, can I do something like:
rolling _b[constant] _b[x] _b[y] _b[z] , window(5) : reg ret x y z
gen fitted=_b[_cons]+_b[x]+_b[y]+_b[z]
gen residual= ret-fitted
2- a recursive regression that adds one year each time
Here I want to run a regression using data from the most recent 5 years, calculate the fitted and residual values, then move one year forward WITHOUT dropping a year, i.e. the regression will be subsequently estimated for 6 years, then 7 years, then 8 years, and so one. I also want to calculate the fitted and residual values each time the regression is estimated.
In the second option, can I do something like:
rolling _b[constant] _b[x] _b[y] _b[z] , window(5) recursive : reg ret x y z
gen fitted=_b[_cons]+_b[x]+_b[y]+_b[z]
gen residual= ret-fitted
Thanks in a dvance
Comment