Dear Statalist community,
I have trouble writing the code and would greatly appreciate your help.
I am working on a panel of quarterly data for 37 countries. I investigate the variability of different types of capital flows. For that purpose I will need to run a separate ARIMA (1,1,0) of each type of capital flow for each country and calculate the corresponding residuals. Afterwards, I need to calculate the separate rolling standard deviation (over 5 quarters) of each series of residuals.
So I have:
c_id quarter y1....y19 (with y I name the different types of capital flows)
And I use the following code which needs improvement
local z "y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 y16 y17 y18 y19"
. foreach k of local z {
. qby c_id: reg `k' l.d. `k'
predict residuals, residuals
egen sd_residuals=sd(residuals), by(quarter)
. }
Thank you in advance.
0 Response to Rolling window standard deviation of residuals in ARIMA
Post a Comment