What is the easiest way / method to compute the correlation between two time series that are exactly the same size? I thought of multiplying $(x[t]-\mu_x)$ and $(y[t] - \mu_y)$, and adding up the multiplication. So if this single number was positive, can we say these two series are correlated? I can think of some examples however where a linearly another exponentially growing time series would have no relation to eachother, but the computation above would report they were correlated.

Any thoughts?


3 Answers 3


Macro's point is correct the proper way to compare for relationships between time series is by the cross-correlation function (assuming stationarity). Having the same length is not essential. The cross correlation at lag 0 just computes a correlation like doing the Pearson correlation estimate pairing the data at the identical time points. If they do have the same length as you are assuming, you will have exact T pairs where T is the number of time points for each series. Lag 1 cross correlation matches time t from series 1 with time t+1 in series 2. Note that here even though the series are the same length you only have T-2 pair as one point in the first series has no match in the second and one other point in the second series will not have a match from the first. Given these two series you can estimate the cross-correlation at several lags . If any of the cross correlations is statistically significantly different from 0 it will indicate a correlation between the two series.

  • $\begingroup$ Hi Michael, is it possible to quantify "significanly different" -- can I use 1 or 2 standard deviation away from zero as significant? $\endgroup$
    – BBSysDyn
    May 24, 2012 at 16:36
  • $\begingroup$ @user423805 I have changed it to read statistically significantly different from 0. Formally that means that you test the null hypothesis that the correlation is zero vs the alternative that it is not 0. Then compute the two-sided p-value for the test statistic. Generally statistical significance mean p-value <=0.05. Sometimes other values are used to define statistical significance (0.01 for example). Most time series software packages that include mutiple time series can do these tests for you. Our friend IrishStat can speak to this regarding Autobox. $\endgroup$ May 24, 2012 at 17:29
  • $\begingroup$ are there cases in which cross correlation at lag zero and pearson differ? $\endgroup$
    – Bakaburg
    Apr 9, 2015 at 16:42
  • $\begingroup$ Can you help answer my most recent question? I have two series with several significant correlations at various lags and I’m unsure how to interpret. $\endgroup$ Dec 16, 2021 at 3:08

You might want to look at a similar question and my answer Correlating volume timeseries which suggests that you can compute cross-correlations BUT testing them is a horse of a different color ( an equine of a different hue ) due to autoregressive or deterministic structure within either series.

  • $\begingroup$ if I understand correctly, in that answer you are saying crosscorrelation between timeseries is useless. $\endgroup$
    – BBSysDyn
    May 24, 2012 at 16:40
  • $\begingroup$ user423805 MAY be useless unless the data is suitably pre-filtered to obtain I.I.D. This speaks directly to the OP's real concerns about spurious conclusions like "storks bringing babies J. Neyman 1938 en.wikipedia.org/wiki/… and amstat.org/about/statisticiansinhistory/…" etc ( I can think of some examples however where a linearly another exponentially growing time series would have no relation to eachother, but the computation above would report they were correlated. ) $\endgroup$
    – IrishStat
    May 24, 2012 at 17:12
  • $\begingroup$ I think the point is that the series need to be stationary for crosscorrelations to make sense. If filtering is necessary it is to mske the series stationary (like differencing or seasonal differencing). But to call it useless is wrong. $\endgroup$ May 25, 2012 at 3:05
  • $\begingroup$ @Michael I said MAY be useless. $\endgroup$
    – IrishStat
    May 25, 2012 at 11:05
  • 1
    $\begingroup$ @IrishStat It was a good comment and took me back to my training in the 1970s. At that time I was learning about time series/forecasting methods for my civilian work in the US Army. We were using exponential smoothing as a way to forecast based on historical data over subjective estimates that were being used at the supply depots. Someone made the great suggestion to me to look at the more general ARIMA models and the 1970 text by Box and Jenkins and so began my interest in time series that became part of my career. $\endgroup$ May 25, 2012 at 13:26

There is some interesting stuff here


This was actually what I needed. Simple to implement and explain.

  • 3
    $\begingroup$ -1 From what I can gather these answers are only concerned with the standard Pearson product-moment correlation. When applied to two time series, the standard Pearson correlation gives nonsensical results! If you follow these suggestions, all you do is produce statistical artefacts. See e.g. math.mcgill.ca/dstephens/OldCourses/204-2007/Handouts/… $\endgroup$
    – Momo
    Jul 12, 2016 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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