Out-of-sample forecasting
The garchvol
series is the series of predicted volatilities for each of the returns in the observed time series sp500ret
. For decision making, it is the volatility of the future (not yet observed) return that matters. You get it by applying the ugarchforecast()
function to the output from ugarchfit()
In forecasting, we call this the out-of-sample volatility forecasts, as they involve predictions of returns that have not been used when estimating the GARCH model.
This exercise uses the garchfit
and garchvol
objects that you created in the previous exercise. If you need to check which arguments a function takes, you can use ?name_of_function
in the Console to access the documentation.
This exercise is part of the course
GARCH Models in R
Exercise instructions
- Compute the unconditional volatility using the method
uncvariance()
. - Print the estimated volatilities for the ten last returns in the
sp500ret
sample. - Use
ugarchforecast()
to forecast the volatility for the next five days. - Use
sigma()
to obtain the predicted volatilities for the next five days and print them.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute unconditional volatility
___(___(garchfit))
# Print last 10 ones in garchvol
tail(___, ___)
# Forecast volatility 5 days ahead and add
garchforecast <- ___(fitORspec = garchfit,
___ = ___)
# Extract the predicted volatilities and print them
print(___(___))