Get startedGet started for free

Higher dimension time series

1. Higher dimension time series

So far you had to deal with a limited number of time series. But what if you do not have 5, or 10 times series but 100? Imagine you have a universe of 100 stocks. If we want to know more about the relationship between those stocks,

2. 100 x 100 correlation matrix

you can create a 100 x 100 correlation matrix, named cor_mat. Can you see anything? Obviously not, the information contained in this matrix is far too dense to fit a standard display.

3. Correlation matrix as heatmap

In this case a very convenient tool to use is a heatmap. A heatmap is a representation of data in the form of a map or diagram in which data values are represented as colors. R offers several ways to do this but once again the corrplot package is a good solution. Let's look at an example. Here we represented the correlation matrix between 100 different stocks return as a heatmap. The correlation coefficients are shown as colors: the darker the color (red or blue) the higher the correlation coefficient in absolute value. To make things even clearer, given that correlation matrices are symmetrical, you don't have to draw the entire matrix but just the upper or lower half. This is done using the argument type equals upper. As you can see, it is easier to spot significant relationships. Instead of going through the entire matrix you can zoom directly on the part you're interested in and identify strong relationships between pairs of stocks.

4. Let's practice!

Let's practice!