[R-SIG-Finance] rugarch and fGarch

alexios ghalanos alexios at 4dscape.com
Thu Jun 14 21:36:37 CEST 2012


Please try to make the reproducible examples a little more compact.

As I said in the previous email the dates shown are the dates aligned to 
the n.ahead forecast. The fact that you do not get the last 21 days is 
because the rolling method uses only out.sample data i.e. forecasts only 
up to the available out.sample (see the ugarchforecast function).
I also mentioned that n.ahead MUST BE <= refit.every (i.e. 
n.ahead<=out.sample per refit), and that a change to accommodate the 
case of n.ahead>refit.every might come in due course.
The point of using the rolling function is for backtesting models for 
which you need realized (i.e. out.sample) data to do so. I will again 
urge you to wrap your own function which makes use of the 
ugarchfit+ugarchforecast functions if you want more customization.

-Alexios

On 14/06/2012 19:07, Belgarath wrote:
> Thank you very much Alexios.
>
> One more question, related to my point (4) two messages above, where I
> probably have not been very clear. Please see the following code.
>
> ---
> getSymbols("^GSPC", src="yahoo")
> getSymbols("^VIX", src="yahoo")
> SPY.log.ret=ClCl(GSPC)
> #GA3=garchFit(formula=~arma(1,0)+aparch(1,1),data=last(SPY.log.ret,1371),cond.dist="sstd")
> #summary(GA3)
> modeltofit=ugarchspec(variance.model = list(model = "apARCH", garchOrder =
> c(1, 1),
>                      submodel = NULL, external.regressors = NULL,
> variance.targeting = FALSE),
>                      mean.model = list(armaOrder = c(1, 0), include.mean =
> TRUE, archm = FALSE,
>                      archpow = 1, arfima = FALSE, external.regressors = NULL,
> archex = FALSE),
>                      distribution.model = "sstd", start.pars = list(),
> fixed.pars = list())
>
> #GAA3=ugarchfit(spec=modeltofit,data=last(SPY.log.ret,1371),fit.control=list(scale=1))
> #show(GAA3)
> volforecast=ugarchroll(spec=modeltofit,data=last(SPY.log.ret,1371), n.ahead
> = 21,
>                         forecast.length = 420, refit.every = 21,
>                         fit.control=list(scale=1))
> sigma=as.data.frame(volforecast,which="density",n.ahead=21)
> sigmat <- as.Date(strptime(sigma[,1],format="%Y-%m-%d"))
> sigma2 <- xts(sigma[,3],order.by=sigmat)*100*sqrt(252)
> plot(sigma2)
> lines(Cl(VIX), col="red")
>
> sigmat <- as.Date(index(first(last(GSPC,420+21),420)))
> sigma2 <- xts(sigma[,3],order.by=sigmat)*100*sqrt(252)
>
> plot(sigma2)
> lines(Cl(VIX), col="red")
>
> ---
>
> As you can see the two are very distant: I think the dates that are passed
> by the as.data.frame(volforecast,which="density",n.ahead=21) refers to the
> forecast date (i.e. 2012-05-07     20.7   means the vol is forecasted to be
> 20.7 on the 2012-05-07) not the date in which the forecast is made (i.e. the
> forecast for the 21d vol made on the 2012-05-07 is 20.7). I realise I was
> not very clear in my previous question...
>
> So if I instead use
>
> ---
> sigmat2 <- as.Date(index(first(last(GSPC,420+21),420)))
> sigma3 <- xts(sigma[,3],order.by=sigmat)*100*sqrt(252)
>
> plot(sigma3)
> lines(Cl(VIX), col="red")
>
> ----
>
> they are now aligned.
>
> So if I want the 21d forecast aligned with the date they have been made I
> have to go for the second version, correct?
>
> In this way thou I missed the last 21 days in the sample, do you think there
> is a way to get them back?
>
> Thank you very much for all the help!
> Rgds,
> marco
>
>
>
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/rugarch-and-fGarch-tp4633077p4633432.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list