LoslegenKostenlos loslegen

Roll, roll, roll

You can visualize the time-variation in volatility by using the function chart.RollingPerformance() in the package PerformanceAnalytics. An important tuning parameter is the choice of the window length. The shorter the window, the more responsive the rolling volatility estimate is to recent returns. The longer the window, the smoother it will be. The function sd.annualized lets you compute annualized volatility under the assumption that the number of trading days in a year equals the number specified in the scale argument.

In this exercise you need to complete the code to compute the rolling estimate of annualized volatility for the daily S&P 500 returns in sp500ret for the period 2005 until 2017.

Diese Übung ist Teil des Kurses

GARCH Models in R

Kurs anzeigen

Anleitung zur Übung

  • Load the package PerformanceAnalytics.
  • Compute the one month estimate, setting the scale argument to the number of trading days in a year.
  • Compute the three months estimate, setting the scale argument to the number of trading days in a year.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Load the package PerformanceAnalytics
___

# Showing two plots on the same figure
par(mfrow=c(2,1)) 

# Compute the rolling 1 month estimate of annualized volatility
chart.RollingPerformance(R = sp500ret["2000::2017"], width = ___,
     FUN = "sd.annualized", scale = ___, main = "One month rolling volatility")

# Compute the rolling 3 months estimate of annualized volatility
chart.RollingPerformance(R = ___, width = ___,
     FUN = ___, scale = ___, main = "Three months rolling volatility")
Code bearbeiten und ausführen