5
$\begingroup$

The autocorrelation coefficient formula of one-dimensional time series is as belows:

$r_k = {\sum\limits^{n-k}_{l=1}}(x_1-\bar x)(x_{l+k}-\bar x)/{\sum\limits^n_{l=1}}(x_l-\bar x)^2$

I want to know how to calculate the autocorrelation coefficient of multi-dimensional time series, such as(five dimensions):

1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
1 2 3 4 6
2 3 4 5 7
1 2 3 4 7
4 5 6 7 8
5 6 7 8 9
4 5 6 7 9
3 4 5 6 8

Thanks in advance.

$\endgroup$

2 Answers 2

3
$\begingroup$

In one dimension, the (empirical) autocorrelation coefficient at lag $k$ (for $k$ between $0$ and $n-1$) of a series of numbers $\mathbf t = t_1, t_2, \ldots, t_n$ is the correlation coefficient of the series shifted by $k$ places:

$$\rho_k(\mathbf t) = \operatorname{Cor}((t_1,t_2,\ldots, t_{n-k}),\ (t_{k+1}, t_{k+2}, \ldots, t_n)).$$

When $\mathbf t$ is a series of $d$-vectors (with $d=1$ corresponding to the usual series of numbers)

$$\mathbf t = (t_{1,1},\ldots, t_{1,d}),\ (t_{2,1},\ldots, t_{2,d}),\ \ldots,\ (t_{n,1},\ldots, t_{n,d}),$$

the concept and the definition remain unchanged. All we need is a generalization to the (empirical) correlation of two sequences of vectors. This correlation is a $d\times d$ matrix $P_k(\mathbf t)$ containing all possible correlations at lag $k:$

$$P_k(\mathbf t)_{i,j} = \operatorname{Cor}(t_{1,i}, t_{2,i}, \ldots, t_{n-k,i}),\ (t_{k+1,j}, t_{k+2,j},\ldots, t_{n, j})).$$

You can readily see this applies without modification to the cross-correlation between any two (equal-length) series of vectors, even when the (common) dimension of the vectors in one series differs from that of the other series.

Alternative autocorrelation formulas for ordinary time series can be generalized in the same way.


Here is R code to illustrate. It uses the built-in cor function in R, which implements several forms of correlation (Pearson, Kendall, and Spearman, with Pearson the default). The ... argument can be used to specify the type of correlation and even how to handle any missing values.

P <- function(lag, t, s, ...) {
  if(missing(s)) s <- t
  if(!is.matrix(t)) t <- matrix(t, ncol = 1)
  if(!is.matrix(s)) s <- matrix(s, ncol = 1)
  n <- nrow(t)
  if (isTRUE(lag < 0) || isTRUE(lag >= n)) return(matrix(NA, nrow(t), ncol(s)))
  cor(t[seq_len(n - lag), ], s[lag + seq_len(n - lag), ], ...)
}

This code converts its input series into matrices (even for series of scalars, where $d=1$ columns are used); arranges to compute the autocorrelation when only a single series is supplied but otherwise will compute the cross-correlation of two series; checks that the lag is legitimate (returning a matrix of missing values otherwise); and then does all the work on the last line by invoking cor.

As an example, after scanning the data in the question into a vector X, we might compute (say) the lag-2 Pearson correlation with the expression

P(2, X)

with the result

       [,1]   [,2]   [,3]   [,4]   [,5]
[1,]  0.000 -0.411 -0.201  0.000 -0.273
[2,] -0.483 -0.290 -0.288 -0.483 -0.281
[3,] -0.397 -0.377 -0.321 -0.397 -0.334
[4,]  0.000 -0.411 -0.201  0.000 -0.273
[5,] -0.397 -0.377 -0.321 -0.397 -0.334

If you only want part of this -- say, the lag-2 cross-correlation between the first three columns of data and the last two columns -- the same code works without modification (demonstrating my claim above):

P(2, X[, 1:3], X[, 4:5])
       [,1]   [,2]
[1,]  0.000 -0.273
[2,] -0.483 -0.281
[3,] -0.397 -0.334

This is the same as the upper right $3\times 2$ block in the first matrix of results.

$\endgroup$
0
$\begingroup$

Sorry, I have not enough reputation to comment.

Correlation for multidimensional data is tricky, if all your dimensions are of the same importance (if you have no dependent variable). If You have 3 variables of the same importance H(height), W (weight) and F(foot size) for example, then if response will be H or response will be W you will have different correlation.

I would suggest the following: as correlation represents amount of variation explained by predictors, you may use another methods to calculate explained variance.

It is possible to perform PCA and use explained by 1st or 1st-2nd etc variance.

$\endgroup$

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.