Session Ready
Exercise

Commodities data

The plotting function pairs() creates a pairwise scatterplot of the components of a multivariate time series with two or more dimensions. It is used on a zoo object rather than an xts object.

A roughly circular shape of a scatterplot indicates a low correlation between the log-returns of two different commodities. Generally speaking, low correlation is good in a portfolio as it implies that the assets are diversified. High correlation, on the other hand, represents a risk that must be properly modelled.

In this exercise, you will look at gold and oil prices over a 25 year period, calculate their daily and monthly log-returns, and plot them. The data gold and oil, containing the daily prices from 1990-2015 of gold and Brent crude oil, respectively, are available in your workspace.

Instructions
100 XP
  • Use plot() to plot the gold and oil time series separately.
  • Calculate the daily log-returns of each commodity and assign to goldx and oilx, respectively.
  • Calculate the monthly log-returns of each commodity and assign to goldx_m and oilx_m, respectively.
  • Use merge() to merge goldx_m and oilx_m, in that order, into coms.
  • Plot coms, a multivariate series, with vertical bars.
  • Convert coms to a zoo object with as.zoo() and then apply pairs() to create a pairwise scatterplot.