S&P 500 & NASDAQ-100 Correlation Matrix

This experiment renders a hierarchically clustered correlation matrix of S&P 500 and NASDAQ-100 constituents using USD close price time series data over a 1Y or 1M horizon. All times are given in New York time.

Correlation

The Pearson correlation coefficient is used to determine the correlation. It ranges from -1 to +1. A value of -1 indicates a perfect negative correlation, i.e. the two correlated time series move against each other. A value of +1 indicates a perfect positive correlation, i.e. the two correlated time series move together.

Values between -0.005 and +0.005 round to 0.00 but retain their sign (displayed as +0.00 for positive and -0.00 for negative) to indicate the direction of the near-zero correlation.

Correlation Matrix

Please note that some of the features described in the following are only available in the full-screen UI of the matrix experiment and not in the preview at the bottom.

Hovering over a matrix cell reveals the rolling correlation in the chart below. Clicking on a matrix cell permanently selects it and allows interaction with its rolling correlation chart. A cell can be deselected by clicking it again, double-clicking anywhere in the matrix, clicking the Deselect button, or pressing the Esc key.

Settings

Dataset
Selects the S&P500 or NASDAQ100 constituents as the dataset.
Horizon
Selects a time horizon of 1M (one month) or 1Y (one year). One-year data uses a one-day interval, while one-month data uses a 30-minute interval.
Detrend Data
Removes trends from the time series data via first-differencing.
Sort By
Orders correlations by hierarchical clustering (Cluster), average correlation (AvgCorr), median correlation (MedCorr), or symbol name (Name). When Cluster is selected, the preferred Cluster Method can also be chosen.
Sort Direction
Controls whether the sort order is ascending (Asc) or descending (Desc).
Search
Opens a search panel for navigating directly to a specific symbol pair and viewing their rolling correlation. Can also be opened with Cmd/Ctrl + K.

To quickly navigate the matrix, Cmd/Ctrl + 14 moves to the edges of the corresponding quadrants.

Minimap

On laptop screens and larger, the minimap allows pattern detection across the entire correlation matrix. It is particularly useful when the matrix is ordered by hierarchical clustering or average correlation. The minimap can be used for click-and-drag navigation. The white overlay rectangle shows the currently visible subregion of the matrix. The Minimap setting in the status bar toggles its visibility.

Rolling Correlation Chart

The Chart setting in the status bar toggles the rolling correlation chart panel. The chart visualizes two time series and how the correlation between them changes over time. The rolling correlation is a channel consisting of three lines: the correlation coefficient in the middle and the upper and lower bounds of the confidence interval. For easy cross-pair comparison, the correlation channel y-axis is always fixed from -1 to +1 and the time y-axis is fixed from the earliest to the latest date in the entire dataset (even if both rendered time series have shared missing (leading and/or trailing) data).

If a matrix cell is selected by click or touch, the rolling correlation chart can be interacted with. When the chart is hovered, a legend appears in the top left corner showing the time, values of the two correlated time series, the rolling correlation, and its confidence interval bounds. A blue overlay rectangle marks the rolling window in the chart, and a vertical blue line indicates the cursor position.

Settings

Window Width
Sets the size of the rolling window used to compute the rolling correlation. Higher values produce a smoother correlation channel and narrower confidence bands, and are better for detecting long-term changes. Lower values are more responsive to short-term changes. The blue overlay rectangle visualizes the window width.
CI Level
Controls the width of the confidence interval band. If both bounds share the same sign, the rolling correlation is statistically significant at the selected level over the Window Width. If they cross zero, it is not. The band is narrower for correlations closer to -1 or +1.

The chart always displays the non-detrended time series data, but the correlation channel is computed on the detrended time series data, if Detrend Data is checked.

Leading gaps in the correlation channel are caused by the width of the rolling window and detrending (one additional missing leading data point if Detrend Data is checked). Intermediate gaps are caused by missing time series data or time series data with insufficient variance to compute the rolling correlation within the Window Width.

Status Bar

The status bar at the bottom displays various information (if the width of the device allows for it), including the average correlation (AvgCorr), standard deviation (SD), and median correlation (MedCorr) of all time series. These descriptive statistics help contextualize the correlation coefficients in the matrix. The correlated data points decrease slightly when Detrend Data is checked, as detrending produces one missing leading data point per time series.

The term 'pair-wise complete' refers to pair-wise complete observations, which simply means that the two correlated time series both have an existing data point at a given point in time. If one or both would not have a data point at a given point in time, the observation would not be pair-wise complete. Trivially, only pair-wise complete observations can be correlated.

Technical Details

The client only receives time series data from the server. All statistical computations, including time series detrending, correlation coefficient computation, and hierarchical clustering, are performed by performance-optimized code in a web worker on the client. The experiment uses a 2D virtualization approach to dynamically render only visible matrix cells to the DOM, which significantly reduces its size. When the S&P 500 constituents are selected, more than 30 million data points are correlated.

Display Note

To experience the matrix experiment in full detail, it is recommended to view it on a high-DPI device (e.g., Retina Display).

The material on this website is for informational purposes only and does not constitute investment advice or a recommendation to buy/sell any security.