1. Learn
  2. /
  3. Courses
  4. /
  5. Quantitative Risk Management in R

Exercise

Different ways of plotting risk-factor and return series

You already know that you can use plot.zoo() to plot multiple time series. For a four-dimensional time series data, the call plot.zoo(data) creates four separate plots by default, unless you include the parameter plot.type = "single" to plot all four series in one plot. You can also add even more parameters such as col to specify different colors and type = "h" to get vertical bars instead of joining points, which can sometimes be a better way of displaying returns.

plot.zoo(x, plot.type, col = 1, type = "l", ...)

In this exercise, you will explore the plot.zoo() function to plot equity risk-factor data and the corresponding returns in different ways. The multivariate time series djstocks and DJ_const are available in your workspace.

Instructions

100 XP
  • Plot djstocks in four separate plots.
  • Plot djstocks in one plot in colors 1 to 4. The code to create an appropriate legend for the plot is provided.
  • Compute the log-returns of djstocks and assign them to djstocks_x.
  • Plot djstocks_x in four separate plots.
  • Plot djstocks_x in four separate plots with vertical bars.