Get startedGet started for free

Exploring risk-factor time series: equity indexes

In this exercise, you will look at an equity index and plot it for a particular range of dates. The data used in this exercise and in the rest of the course are contained in the package qrmdata. You also need the package xts to manipulate time series.

When the qrmdata library is attached, as it will be throughout the course, you can load a dataset with the data() command. For example, the command data("FTSE") loads the UK FTSE (Financial Times Stock Exchange) index, which you can then refer to as object FTSE.

If you want to extract the data from a certain date range, for example from April 1 to June 30, 2000, you can create a new object using the command ftse00 <- FTSE["2000-04-01/2000-06-30"].

From now onwards, the xts package will also already be loaded into your workspace.

This course touches on a lot of concepts you may have forgotten, so if you ever need a quick refresher, download the xts in R Cheat Sheet and keep it handy!

This exercise is part of the course

Quantitative Risk Management in R

View Course

Exercise instructions

  • Load the Dow Jones index "DJ" from qrmdata.
  • Show the first and last few lines of the DJ index with head() and tail().
  • Plot the DJ index using plot().
  • Extract the DJ index for the crisis period 2008-2009 and assign to object dj0809.
  • Plot the dj0809 using the same plotting function as above.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Load DJ index
___(___)

# Show head() and tail() of DJ index
___(___)
___(___)

# Plot DJ index
___(___)

# Extract 2008-2009 and assign to dj0809
dj0809 <- ___

# Plot dj0809
___(___)
Edit and Run Code