1
$\begingroup$

So far I know, the cross-correlation of two time-series $a(t)$ and $b(t)$ for which $N$ observations are available is given by $r^N(\tau)=\frac{1}{N} \sum_{t=\tau+1}^Na(t-\tau)b(t)$, where $\tau$ indicates the time-lag. However, I am not sure how to cross-correlate two multi-dimensional time-series. For instance, let $x(t)$ and $y(t)$ two multidimensional time-series of dimension $q$ and $p$, respectively, and assume that I have $N$ observations that I arranged in a matrix form as it follows

\begin{equation} x^{N}:= \begin{bmatrix} x_1(1) & \dots & x_q(1) \\ \vdots & \ddots & \vdots \\ x_1(N) & \dots & x_q(N) \end{bmatrix}\,, \end{equation}

and

\begin{equation} y^{N}:= \begin{bmatrix} y_1(1) & \dots & y_p(1) \\ \vdots & \ddots & \vdots \\ y_1(N) & \dots & y_p(N) \end{bmatrix}\,. \end{equation}

My instinct would suggest that the cross-correlation $R_{xy}(\tau)$ between $x^N$ and $y^N$ is given by

\begin{equation} R_{xy}(\tau)= \begin{bmatrix} \frac{1}{N}\sum_{t=\tau+1}^N x_1(t-\tau)y_1(t) & \frac{1}{N}\sum_{t=\tau+1}^N x_1(t-\tau)y_2(t) & \cdots & \frac{1}{N}\sum_{t=\tau+1}^N x_1(t-\tau)y_p(t)] \\ \frac{1}{N}\sum_{t=\tau+1}^N x_2(t-\tau)y_1(t) & \frac{1}{N}\sum_{t=\tau+1}^N x_2(t-\tau)y_2(t) & \cdots & \frac{1}{N}\sum_{t=\tau+1}^N x_2(t-\tau)y_p(t)] \\ \vdots & \vdots & \ddots & \vdots \\ \frac{1}{N}\sum_{t=\tau+1}^N x_q(t-\tau)y_1(t) & \frac{1}{N}\sum_{t=\tau+1}^N x_q(t-\tau)y_2(t) & \cdots & \frac{1}{N}\sum_{t=\tau+1}^N x_q(t-\tau)y_p(t)] \end{bmatrix}\,. \end{equation}

Is it correct?

Also, is there any Python function that would allow me to compute the cross-correlation between $x^N$ and $y^N$? If so, what's that function name?

$\endgroup$
2
  • 1
    $\begingroup$ There's an inconsistency--perhaps it's a typographical error, or maybe it's what you're trying to ask? In the univariate formula you have not included a factor of $1/N.$ As far as Python functions go, note that every entry in $R_{xy}(\tau)$ is $1/N$ times one of your $r^N(\tau),$ so if you know of a Python function to compute the latter, you're good to go. $\endgroup$
    – whuber
    May 31, 2022 at 14:00
  • $\begingroup$ It was a typographical error. I added the term $1/N$ in the univariate formula. $\endgroup$
    – Barzi2001
    May 31, 2022 at 14:05

1 Answer 1

1
$\begingroup$

The summation indices should be from $\tau+1$ to $N$, assuming 1-indexed series, and the cross-correlation matrix looks fine. At least in statsmodels library, which is a popular tool for time series workloads, there isn't any function to calculate a sample cross-correlation matrix with $\tau=[0,N-1]$ entries, which would be a 3D tensor.

$\endgroup$
4
  • 1
    $\begingroup$ Perfect. Thanks for your answer to both the questions. Yes, I am aware that $R_{xy}(\tau)$ is a tensor. And thanks also for pointing me to statsmodel library that I was not aware of. Nevertheless, it seems that I must implement my own function for building up such a cross-correlation tensor $R_{xy}(\tau)$. $\endgroup$
    – Barzi2001
    Jun 1, 2022 at 9:41
  • $\begingroup$ Regarding the text, there were a typo that is now correct. The summation now goes from $t=1$ to $t=N$. I used the same formulation of cross-correlation that you can find here: diva-portal.org/smash/get/diva2:316456/…. See for example (4) in the cited paper. $\endgroup$
    – Barzi2001
    Jun 1, 2022 at 9:42
  • $\begingroup$ If you have $N$ samples for both series, the summation can't start with $t=1$ unless you make assumptions over $x(-t)$ $\endgroup$
    – gunes
    Jun 1, 2022 at 9:45
  • $\begingroup$ Correct. I have fixed the issue. Thanks again. $\endgroup$
    – Barzi2001
    Jun 1, 2022 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.