[R-SIG-Finance] rolling forecasts with rugarch

Pippens Pips pippenspips at uchicago.edu
Wed Aug 12 16:27:47 CEST 2015

Hi,This is my first time using this so sorry in advance if my post is not clear. I am trying to use the past 500 days to create a rolling forecast 1 day ahead. So for the 501th day I would use 1-500 and for the 502nd day I would use 2-501. I am using the ugarchroll command for the next 20 days. I understand that the code should be this:
library(quantmod)library(rugarch)library(PerformanceAnalytics)getSymbols("SPY")spyRets=na.omit(Return.calculate(Cl(SPY),method=c('log'))) #log returnsspec=ugarchspec(mean.model=list(armaOrder=c(3,3))) #arma(3,3) and garch(1,1)GARCH=ugarchfit(spec,head(spyRets,500),solver="hybrid") #run regressionspyRetssub=spyRets[1:520,]roll=ugarchroll(spec,data=spyRetssub,n.start=500,refit.every=1,window.size=500,refit.window=c('moving'),solver='hybrid')rollingforecasts=xts(roll at forecast$density$Mu,order.by=index(spyRets[501:520,])) #my forecasts for next 20 days with walk forward
I now check that by manually doing the same forecasts except now I will use the ugarchforecast function and then just change the data to the subset that I want.
setfixed(spec)=as.list(coef(GARCH))forecast501=ugarchforecast(spec,data=spyRets[1:500],n.ahead=1) #give me one step ahead forecastfitted(forecast501) #t+1 fitted value. This matchesforecast502=ugarchforecast(spec,data=spyRets[2:501],n.ahead=1) #give me one step ahead forecastfitted(forecast502) #t+2 fitted value. This does not match with rolling forecastforecast503=ugarchforecast(spec,data=spyRets[3:502],n.ahead=1) #give me one step ahead forecastfitted(forecast503) #t+3 fitted value. This does not match with rolling forecast
The issue is that the 1st forecast matches, however after that the forecasts break down. Is there something that I am doing wrong in my original rolling forecast code that gets the first t+1 day correct but not the rest?
Thanks in advancePippens
	[[alternative HTML version deleted]]

More information about the R-SIG-Finance mailing list