Exercises
Download Historical Data
- Get the code for S & P 500 Index using the Yahoo Finance database either from the Quandl website or the
Rconsole. - Download historical close prices for the years 2010 -- 2014 and save them in the variable
close_prices.
- Get the code for S & P 500 Index using the Yahoo Finance database either from the Quandl website or the
Visual Inspection of the Data
- Plot the close prices as a linechart. What kind of process would be appropriate?
- Plot the logarithm (
log()) of the close prices as a linechart. What kind of process would be appropriate? - Calculate the log - returns and save your results in the variable
log_returns. - Plot the log - returns. What kind of process would be appropriate?
- Plot the acf
acf()of the log - returns and the squared log - returns.
Fitting a GARCH Model to Historical Data
- Use the
garchFit()function to fit a GARCH(1,1) model to the log - returns. - Replace the normal distribution with a Student - t - distribution.
- Which model explains the data better?
- Use the
Forecasting Volatility (Homework)
- Write your own function
vola_forecast()for k - step ahead forecasts \(\sigma_T(k)\), with forecast origin \(T\), of the volatility for the two models from exercise 3. - Note:
- You can check your results by comparing them with the output from the
predict()function in packagefGarchwhich returns values of \(\sigma_T(k)\) . - You can use the following forecasting relations for a GARCH(1,1) model:
- You can check your results by comparing them with the output from the
- Write your own function
vola_forecast <- function(ARGUMENTS) {
Body
}