[R-SIG-Finance] Rugarch: Analysing the performance of my forecast

alexios ghalalanos alexios at 4dscape.com
Tue Aug 12 19:57:17 CEST 2014


I'm not sure I understand your question. If it is related to how to
update the forecasts as new data comes in then the answer is below. If
on the other hand you are asking about comparing a GARCH variance
forecast with a realized measure, then you need higher frequency data
from which you can extract and compare the forecast. Have a look at the
highfrequency package and related literature on such comparison.


The ugarchforecast method accepts on object of either uGARCHfit (which
you've used) or uGARCHspec with fixed parameters:

>args(ugarchforecast)
ugarchforecast(fitORspec, data = NULL, n.ahead = 10, n.roll = 0,
out.sample = 0, external.forecasts = list(mregfor = NULL, vregfor =
NULL), ...)

Therefore, you can iterate as new data comes in, calling ugarchforecast
with the expanded dataset. The example below illustrates, but you should
consult the rugarch.tests subfolder in the inst folder of the source file.
########################
>library(rugarch)
>library(xts)
>data(sp500ret)
>spx = as.xts(sp500ret)
>spec = ugarchspec()
>fit = ugarchfit(spec, spx[1:1000])
>f1 = ugarchforecast(fit, n.ahead=10)
# create spec with fixed parameters based on estimated model
>specf = spec
>setfixed(specf)<-as.list(coef(fit))
# equivalent to f1
>f11 = ugarchforecast(specf, spx[1:1000], n.ahead=10)
# append new data
>f2 = ugarchforecast(specf, spx[1:1001], n.ahead=10)
>f3 = ugarchforecast(specf, spx[1:1002], n.ahead=10)
# ...etc
# or if you have a lot of new data
>fn = ugarchforecast(specf, spx[1:1010], n.ahead=10, out.sample=10,
n.roll=9)

# check the matrix returned by fn and compare with what you get
# via the iteration f2, f3 etc:
>fitted(fn)
>sigma(fn)
########################

Keep in mind that you should append new data to old (see vignette or
blog for more details on start up conditions).

-Alexios



On 12/08/2014 17:35, Marc Hatton wrote:
> Hello
> 
> What I would like to do is analyse how accurate the predictions were by
> calculating the sigmas of the new data, and comparing the compared sigmas
> against the actual sigmas.
> 
> I have read over the vignette, and numerous blog posts, but couldn't find a
> solution (I'm sure it's out there somewhere, but I couldn't find it).
> 
> It's easy to pull the sigma values from rugarch's ugarchforecast function:
> spec <- ugarchspec()
> fit <- ugarchfit(ugarchspec, data_original, out.sample=10)
> fore <- ugarchforecast(fit, n.ahead = 10, n.roll=9)
> sigma(fore)
> 
> Now I have new data (let's call it data_new), which contains 10 new
> realised values.
> 
> So, what would be the appropriate way of calculating the sigmas at the 10
> new time intervals? Obviously, the standard formula for standard deviation
> is:
> sigma = sqrt(sum((x-xbar)^2) / (n-1)).
> 
> But how many time intervals (n) should be used?
> 
> I would like a way to calculate the sigmas exactly the same as the rugarch
> methods do.
> 
> MN Hatton
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> 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