Get startedGet started for free

Exploring return series

To analyze risk, the key task is to model the fluctuations in prices and rates over different time periods; these fluctuations are known as returns. To calculate the log-returns of the FTSE stock index and assign to ftse_x, apply the log() and diff() functions in succession:

> ftse_x <- diff(log(FTSE))

As you saw in the video, differencing in this way will always give a NA in the first position of the time series, which can then be removed with diff(log(FTSE))[-1]. However, you will not need to do this in the course unless it is specified in the instructions.

In this exercise, you will calculate and plot log-return series for the equity and FX risk factors that you have previously encountered. The datasets dj0809, djstocks, and GBP_USD have been pre-loaded into your workspace.

This exercise is part of the course

Quantitative Risk Management in R

View Course

Exercise instructions

  • Compute the log-returns of the DJ index in dj0809 and assign to object dj0809_x.
  • Plot the return series dj0809_x.
  • Compute the log-returns of all share prices in djstocks and assign to djstocks_x.
  • Plot the share returns djstocks_x. Note that djstocks_x contains multiple time series.
  • Compute the log-returns of the GBP_USD exchange rate series and assign to erate_x.
  • Plot the return series erate_x.

Hands-on interactive exercise

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

# Compute the log-returns of dj0809 and assign to dj0809_x
dj0809_x <- ___(___)

# Plot the log-returns
___(___)

# Compute the log-returns of djstocks and assign to djstocks_x
djstocks_x <- ___(___)

# Plot the two share returns
___(___)

# Compute the log-returns of GBP_USD and assign to erate_x
erate_x <- ___(___)

# Plot the log-returns
___(___)
Edit and Run Code