Cross-Correlation

Often we are interested in looking for relationships between 2 different time series. There are many ways to do this, but a simple method is via examination of their cross-covariance and cross-correlation.

Let’s examine the CCF between sunspot activity and number of lynx trapped in Canada as in the classic paper by Moran. Here are plots of the time series.

library(WaveletComp)
library(dplyr)
 suns <- ts.intersect(lynx, sunspot.year)[, "sunspot.year"]
 lynx <- ts.intersect(lynx, sunspot.year)[, "lynx"]
 
 plot(cbind(suns, lynx), yax.flip = TRUE)
Fig 1: Time-series plots for sunspot activity and lynx trapped.

Fig 1: Time-series plots for sunspot activity and lynx trapped.

It seems most relevant to treat lynx as the y and sunspots as the x, in which case we are mostly interested in the CCF at negative lags (i.e., when sunspot activity predates inferred lynx abundance). Furthermore, we’ll use log-transformed lynx trappings.

Fig 2: Cross-correlation of sunspot activity and lynx trapped.

Fig 2: Cross-correlation of sunspot activity and lynx trapped.

It looks like lynx numbers are relatively low 3-5 years after high sunspot activity (i.e., significant correlation at lags of -3 to -5).

Wavelet Coherence

The cross-correlation between two time series is a function of frequency; an analogous concept in wavelet theory is the notion of wavelet coherency. To investigate the relationship between two time-series using wavelet coherence analysis, we look at the wavelet coherence plot. The x-axis represents time, the y-axis represents the time scale converted to Fourier period, and the color scale represents the magnitude of R-squared. The cone of influence where edge effects should be considered is shown as a lighter shade. The white line contours designate areas of significant coherence (here for p < 0.1). The arrows designate the relative phase between time-series, a rightward-pointing arrow indicates in-phase coherence between the two signals, and leftward-pointing arrow indicates anti-phase coherence. Downward arrows represent negative correlations, while upwards arrows positive correaltions. The quadrante the arrows are in indicates which time-series leads or lags behind the other.

Fig 3: Phase-differences and their interpretation.

Fig 3: Phase-differences and their interpretation.

Using the same data as in the previous cross-correlation example, lets look at wavelet coherence.
Fig 4: Wavelet Coherence plot for sunspot (x) and lynx(y) relationship

Fig 4: Wavelet Coherence plot for sunspot (x) and lynx(y) relationship

The red band in the lower left corner of the plot extends from period 3 to 5, with left pointing arrow indicating y leading time series (lynx). The downward pointing arrows indicate a negative correlation. Much like in the cross-correlation method, lynx numbers decrease 3 to 5 years after increase in sunspot activity.

Note: cross-correlation data satisfies the stationarity assumption. That means that the process creating the sequence is not supposed to change and neither should the statistical properties of the sequence change, and that includes mean and variance. That is why cross-correlation uses the standard devations and means of the whole sequence even if it computes the lagged cross-correlations of a limited time window. Wavelets analysis does not require stationary time-series and performs local transformations. It will also look at larger window sizes, and so we get lags at higher values with weavelets that we would not get with cross-correlation.

References

  1. E. E. Holmes, M. D. Scheuerell, and E. J. Ward (2020). Applied Time Series Analysis for Fisheries and Environmental Sciences: Correlation within and among time series https://nwfsc-timeseries.github.io/atsa-labs/sec-tslab-correlation-within-and-among-time-series.html

  2. A. Rosch and H. Schmidbauer, (2018). WaveletComp 1.1: A guided tour through the R package

  3. R. Rocha, F. Souza Filho, and S.M.O. da Silva, (2019). Análise da Relação entre a Precipitação Média do Reservatório Orós, Brasil - Ceará, e os índices PDO e AMO Através da Análise de Changepoints e Transformada de Ondeletas. Revista Brasileira de Meteorologia, 34(1), 139-149. Epub May 30, 2019.https://doi.org/10.1590/0102-77863340034

  4. Jan Seifert (2020). The R Cross Correlation Function What the man page will not tell you… https://medium.com/@jan.seifert/the-r-cross-correlation-function-f5f426006425