if (FALSE) {
data(sp500ret)
spec = ugarchspec()
fit = ugarchfit(spec, sp500ret, out.sample=10)
forc = ugarchforecast(fit, n.ahead = 25, n.roll = 10)
f = fitted(forc)
# this is a 25 x 11 matrix [n.ahead x (n.roll+1)]
# colnames: T+0 date index
T0 = as.POSIXct(colnames(f))
rollT1 = move(T0, by=1)
# rolling estimation
plot(xts(f["T+1",],rollT1))
# unconditional estimates:
par(mfrow=c(3,4))
for(i in 1:11){
# difftime is always in model$modeldata$period
D=generatefwd(T0[i], length.out = 25, by = forc@model$modeldata$period)
plot(xts(f[,i], D), main=paste("T+0:",as.character(T0[i]),sep=""), auto.grid=FALSE)
}
############################
## Intraday Sequency Example
############################
T0 = as.POSIXct("2001-01-01 16:00:00")
# remember to remove the backslash from the code below
interval = format(seq(as.POSIXct("2001-01-01 09:30:00"), as.POSIXct("2001-01-01 16:00:00"),
by="min"), "%H:%M:%S")
by = "mins"
length.out=1000
R = ftseq(T0, length.out, by, interval)
}
Run the code above in your browser using DataLab