# Does correlation assume stationarity of data?

Inter-market analysis is a method of modeling market behavior by means of finding relationships between different markets. Often times, a correlation is computed between two markets, say S&P 500 and 30-Year US treasuries. These computations are more often than not based on price data, which is obvious to everyone that it does not fit the definition of stationary time series.

Possible solutions aside (using returns instead), is the computation of correlation whose data is non-stationary even a valid statistical calculation?

Would you say that such a correlation calculation is somewhat unreliable, or just plain nonsense?

• what do you mean by "valid statistical calculation" you should say valid statistical (estimation) calculation of something. Here the something is very important. Correlation is a valid calculation of the linear relation between two set of data. I don't see why you need stationarity, did you mean auto-correlation ? – robin girard Feb 18 '11 at 13:13
• there is a new site which might be more suitable for your question: quant.stackexchange.com. Now you are clearly confusing calculation with interpretation. – mpiktas Feb 18 '11 at 13:45
• @mpiktas, the quant community is settled on using returns vs prices because of the stationarity of returns and the non-stationarity of prices. I'm asking here for something more than an intuitive explanation of why this should be so. – Milktrader Feb 18 '11 at 14:38
• @robin, there are several things that may have you question a statistical analysis. Sample size comes to mind, as does more obvious things such as manipulated data. Does non-stationarity of data call into question a correlation calculation? – Milktrader Feb 18 '11 at 15:10
• not the calculation, maybe the interpretation if the correlation is not high. If it is high it means high correlation (i.e. high linear relation), two non stationnary time series say $(X_t)$ and $(Y_t)$ can be potentially highly correlated (for example when $X_t=Y_t$. – robin girard Feb 18 '11 at 15:25

The correlation measures linear relationship. In informal context relationship means something stable. When we calculate the sample correlation for stationary variables and increase the number of available data points this sample correlation tends to true correlation.

It can be shown that for prices, which usually are random walks, the sample correlation tends to random variable. This means that no matter how much data we have, the result will always be different.

Note I tried expressing mathematical intuition without the mathematics. From mathematical point of view the explanation is very clear: Sample moments of stationary processes converge in probability to constants. Sample moments of random walks converge to integrals of brownian motion which are random variables. Since relationship is usually expressed as a number and not a random variable, the reason for not calculating the correlation for non-stationary variables becomes evident.

Update Since we are interested in correlation between two variables assume first that they come from stationary process $Z_t=(X_t,Y_t)$. Stationarity implies that $EZ_t$ and $cov(Z_t,Z_{t-h})$ do not depend on $t$. So correlation

$$corr(X_t,Y_t)=\frac{cov(X_t,Y_t)}{\sqrt{DX_tDY_t}}$$

also does not depend on $t$, since all the quantities in the formula come from matrix $cov(Z_t)$, which does not depend on $t$. So the calculation of sample correlation

$$\hat{\rho}=\frac{\frac{1}{T}\sum_{t=1}^T(X_t-\bar{X})(Y_t-\bar{Y})}{\sqrt{\frac{1}{T^2}\sum_{t=1}^T(X_t-\bar{X})^2\sum_{t=1}^T(Y_t-\bar{Y})^2}}$$ makes sense, since we may have reasonable hope that sample correlation will estimate $\rho=corr(X_t,Y_t)$. It turns out that this hope is not unfounded, since for stationary processes satisfying certain conditions we have that $\hat{\rho}\to\rho$, as $T\to\infty$ in probability. Furthermore $\sqrt{T}(\hat{\rho}-\rho)\to N(0,\sigma_{\rho}^2)$ in distribution, so we can test the hypotheses about $\rho$.

Now suppose that $Z_t$ is not stationary. Then $corr(X_t,Y_t)$ may depend on $t$. So when we observe a sample of size $T$ we potentialy need to estimate $T$ different correlations $\rho_t$. This is of course infeasible, so in best case scenario we only can estimate some functional of $\rho_t$ such as mean or variance. But the result may not have sensible interpretation.

Now let us examine what happens with correlation of probably most studied non-stationary process random walk. We call process $Z_t=(X_t,Y_t)$ a random walk if $Z_t=\sum_{s=1}^t(U_t,V_t)$, where $C_t=(U_t,V_t)$ is a stationary process. For simplicity assume that $EC_t=0$. Then

\begin{align} corr(X_tY_t)=\frac{EX_tY_t}{\sqrt{DX_tDY_t}}=\frac{E\sum_{s=1}^tU_t\sum_{s=1}^tV_t}{\sqrt{D\sum_{s=1}^tU_tD\sum_{s=1}^tV_t}} \end{align}

To simplify matters further, assume that $C_t=(U_t,V_t)$ is a white noise. This means that all correlations $E(C_tC_{t+h})$ are zero for $h>0$. Note that this does not restrict $corr(U_t,V_t)$ to zero.

Then \begin{align} corr(X_t,Y_t)=\frac{tEU_tV_t}{\sqrt{t^2DU_tDV_t}}=corr(U_0,V_0). \end{align}

So far so good, though the process is not stationary, correlation makes sense, although we had to make same restrictive assumptions.

Now to see what happens to sample correlation we will need to use the following fact about random walks, called functional central limit theorem:

\begin{align} \frac{1}{\sqrt{T}}Z_{[Ts]}=\frac{1}{\sqrt{T}}\sum_{t=1}^{[Ts]}C_t\to (cov(C_0))^{-1/2}W_s, \end{align} in distribution, where $s\in[0,1]$ and $W_s=(W_{1s},W_{2s})$ is bivariate Brownian motion (two-dimensional Wiener process). For convenience introduce definition $M_s=(M_{1s},M_{2s})=(cov(C_0))^{-1/2}W_s$.

Again for simplicity let us define sample correlation as

\begin{align} \hat{\rho}=\frac{\frac{1}{T}\sum_{t=1}^TX_{t}Y_t}{\sqrt{\frac{1}{T}\sum_{t=1}^TX_t^2\frac{1}{T}\sum_{t=1}^TY_t^2}} \end{align}

Let us start with the variances. We have

\begin{align} E\frac{1}{T}\sum_{t=1}^TX_t^2=\frac{1}{T}E\sum_{t=1}^T\left(\sum_{s=1}^tU_t\right)^2=\frac{1}{T}\sum_{t=1}^Tt\sigma_U^2=\sigma_U\frac{T+1}{2}. \end{align}

This goes to infinity as $T$ increases, so we hit the first problem, sample variance does not converge. On the other hand continuous mapping theorem in conjunction with functional central limit theorem gives us

\begin{align} \frac{1}{T^2}\sum_{t=1}^TX_t^2=\sum_{t=1}^T\frac{1}{T}\left(\frac{1}{\sqrt{T}}\sum_{s=1}^tU_t\right)^2\to \int_0^1M_{1s}^2ds \end{align} where convergence is convergence in distribution, as $T\to \infty$.

Similarly we get

\begin{align} \frac{1}{T^2}\sum_{t=1}^TY_t^2\to \int_0^1M_{2s}^2ds \end{align} and \begin{align} \frac{1}{T^2}\sum_{t=1}^TX_tY_t\to \int_0^1M_{1s}M_{2s}ds \end{align}

So finally for sample correlation of our random walk we get

\begin{align} \hat{\rho}\to \frac{\int_0^1M_{1s}M_{2s}ds}{\sqrt{\int_0^1M_{1s}^2ds\int_0^1M_{2s}^2ds}} \end{align} in distribution as $T\to \infty$.

So although correlation is well defined, sample correlation does not converge towards it, as in stationary process case. Instead it converges to a certain random variable.

• The mathematical point of view explanation is what I was looking for. It gives me something to contemplate and explore further. Thanks. – Milktrader Feb 18 '11 at 16:41
• This response seems to sidestep the original question: Aren't you just saying that yes, calculating correlation makes sense for stationary processes? – whuber Feb 18 '11 at 16:58
• @whuber, I was answering the question having in mind the comment, but I reread the question again and as far as I understand the OP asks about calculation of correlation for non-stationary data. Calculation of correlation for stationary processes makes sense, all the macroeconometric analysis (VAR, VECM) relies on that. – mpiktas Feb 18 '11 at 17:35
• I'll try to clarify my question with a response. – whuber Feb 18 '11 at 18:57
• @whuber my take away from the answer is that a correlation based on non-stationary data yields a random variable, which may or may not be useful. Correlation based on stationary data converges to a constant. This may explain why traders are attracted to "x-day rolling correlation" because the correlated behavior is fleeting and spurious. Whether "x-day rolling correlation" is valid or useful is for another question. – Milktrader Feb 18 '11 at 19:12

...is the computation of correlation whose data is non-stationary even a valid statistical calculation?

Let $W$ be a discrete random walk. Pick a positive number $h$. Define the processes $P$ and $V$ by $P(0) = 1$, $P(t+1) = -P(t)$ if $V(t) > h$, and otherwise $P(t+1) = P(t)$; and $V(t) = P(t)W(t)$. In other words, $V$ starts out identical to $W$ but every time $V$ rises above $h$, it switches signs (otherwise emulating $W$ in all respects).

(In this figure (for $h=5$) $W$ is blue and $V$ is red. There are four switches in sign.)

In effect, over short periods of time $V$ tends to be either perfectly correlated with $W$ or perfectly anticorrelated with it; however, using a correlation function to describe the relationship between $V$ and $W$ wouldn't be useful (a word that perhaps more aptly captures the problem than "unreliable" or "nonsense").

Mathematica code to produce the figure:

With[{h=5},
pv[{p_, v_}, w_] := With[{q=If[v > h, -p, p]}, {q, q w}];
w = Accumulate[RandomInteger[{-1,1}, 25 h^2]];
{p,v} = FoldList[pv, {1,0}, w] // Transpose;
ListPlot[{w,v}, Joined->True]]
• it is good that your answer points that out but I wouldn't say the process are correlated, I would say they are dependent. This is the point. Calculation of correlation is valide and here it will say "no correlation" and we all know this does not mean "no dependence". – robin girard Feb 18 '11 at 19:48
• @robin That's a good point, but I constructed this example specifically so that for potentially long periods of time these two processes are perfectly correlated. The issue is not one of dependence versus correlation but inherently is related to a subtler phenomenon: that the relationship between the processes changes at random periods. That, in a nutshell, is exactly what can happen in real markets (or at least we ought to worry that it can happen!). – whuber Feb 18 '11 at 19:56
• @whubert yes, and this is a very good example showing that there are processes that have very high correlation for potentially long periods of time and still are not correlated at all (but highly dependent) when regarding the larger temporal scale. – robin girard Feb 19 '11 at 7:47
• @robin girard, I think the key here is that for non-stationary processes the theoretical correlation varies with time, when for the stationary processes theoretical correlation stays the same. So with sample correlation which basically is one number, it is impossible to capture the variation of true correlations in case of non-stationary processes. – mpiktas Feb 21 '11 at 7:09