I aim to forecast the SP500excessreturns using the rolling window option in Stata with the moving window of 120 observations (there are 500 observations in total). The code looks in the following way:

set obs 500
egen a = fill(1 2)
egen b = fill(1 0,5)    
g SP500excessreturns = a + rnormal(0,1)*50
g Defaultspread = b + rnormal(0,1)*60
egen Date = fill(1 2)
tsset Date
local dep SP500excessreturns
local indep Defaultspread
xi: rolling _b , window(120)  saving(betas, replace) keep(Date): regress `dep' `indep'
merge 1:1 _n using betas.dta
gen forecast_`dep' = _b_cons+_b_Defaultspread*Defaultspread[_n+119]

However, the results do not seem to be correct as the path of the predicted variable appears to be almost flat (with real data). What could be the reason for this issue?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.