Rolling Correlation: Window Choice, Stationarity, and Estimation Noise
Summary
The document explains rolling correlation for two asset return series: calculate correlation over successive windows and plot the resulting time series. It clarifies that the choice of window depends on assumptions about stationarity. If returns are weakly stationary, differences between window estimates mainly reflect sampling noise, which falls as the window grows. If correlation changes over time, estimates also reflect shifts in the underlying relationship.
Longer windows reduce estimation noise but mix observations from potentially different correlation regimes; shorter windows adapt more quickly while producing noisier estimates. The answers recommend investigating the empirical behavior of rolling estimates and using bootstrap methods cautiously when observations form a dependent time series. They mention common lookbacks used as market conventions, but stress that no window is universally correct without a supporting economic rationale. A separate answer warns that selecting windows to make a chart look compelling invites overfitting. The document does not provide a definitive window rule or a validated interpretation of changing correlation.
Key ideas
- Rolling correlation is calculated on successive windows of paired returns.
- Under weak stationarity, differences across windows can arise from sampling noise.
- When correlation shifts over time, estimates contain both sampling noise and regime changes.
- Longer windows reduce noise but can blend observations from distinct correlation regimes.
- Window selection should be investigated empirically and supported by economic reasoning where possible.
- Bootstrap uncertainty estimates require care when returns are dependent over time.
Tags
Full text
# On moving Linear Correlation (rolling correlation)
# On moving Linear Correlation (rolling correlation)
Let's say I have two random variables $X$ and $Y$ which each represents the daily returns of two given stocks. I can easy calculate their (total) correlation by finding their covariance matrix $\Sigma[X, Y]$. However, I would like to graph their correlation throughout time; not just a single point. Thus, I would like to have a vector of their correlation like so: $C = \{ \textrm{corr}_0, \textrm{corr}_1, \cdots, \textrm{corr}_m \}$. Here is my attempt:
Let $X = \{x_1, x_2, x_3, x_4, \cdots, x_n\}$ and $Y=\{y_1, y_2, y_3, y_4, \cdots, y_n\}$ be random variables. Thus, we define its correlation throughout time (as in the comments, its name is rolling correlation) as
\begin{equation} \textrm{corr}[X, Y | k] := \frac{ \textrm{cov}[X, Y | k]}{\sigma_X \cdot \sigma_Y} := \frac{\displaystyle\sum_i^{i+k-1} (x_i-\bar{x})(y_i-\bar{y})}{(k) \cdot \sigma_X \cdot \sigma_Y}, i = \{1, 2, 3, \cdots n-k+1\} \end{equation}
Equivalently, I would separate both $X$ and $Y$ into $j$ subsets such that each satisfy $|X_j|=|Y_j|=k$ and then calculate their correlation $\textrm{corr}[X_j, Y_j]$ and finally include it into the vector $C$.
Is this the best way to find correlation throughout time? Is it even correct?
Thanks
## Answer by lehalle (score 3)
https://quant.stackexchange.com/a/69137
Your question is indeed on the stationarity of correlations between your two instruments $X$ and $Y$.
To make it clear from a theoretical viewpoint, let's consider their 2D joint distribution $(X,Y)$:
- first you need to decide if you want to consider that they have autocorrelations or if they are iid, in short: is $(X,Y)$ a stochastic process or a pair of random variables?
- then do you assume that the underlying distribution of $(X,Y)$ is the same at any point in time (strong stationarity) or simply that few statistics (like volatility, correlation and average) are the same at any point in time (weak stationarity)?
- note that for Gaussians, weak stationarity imply string stationarity since (vol,cor,mean) is a sufficient statistic.
- of course you can assume that there is no stationarity of any kind there, but all would be more complicated.
To make it simple, assume that $(X,Y)$ is a weakly stationary random variable, then the only difference between the empirical correlation computed on one time window $[t_1,t_1+w_1]$ and on another one $[t_2,t_2+w_2]$ is the sampling noise. It means that when $w_1$ and $w_2$ jointly go towards infinity, Thanks to the Central Limit Theorem: you will obtain the same correlations and the convergence will happen in $1/\sqrt{\min(w_1,w_2)}$ (for uniformly sampled data).
If now you do not believe in the stationarity of the correlations (note that you can have non stationarity of the marginal volatilities, convince yourself that you nevertheless captured it, for instance thanks to 2 GARCHs, such that the correlations are stationary now), then the empirical correlations computed on $[t_1,t_1+w_1]$ and $[t_2,t_2+w_2]$ will not be the same for two reasons
- the estimation noise (like in the stationary case)
- the shift in the covariances (that you could name a covariate shift and read this nice book: Machine Learning in Non-Stationary Environments, by Sugiyama and Kawanabe)
And you face a dilemma: the larger the window $w_1$ and $w_2$
- the less estimation noise
- but the more you mix estimates from different underlying correlations.
This is subtle and there nothing you can really do without empirical investigation:
- how does the times series of empirical correlations changes with time?
- what bootstrap can tell you about the estimation noise? (be careful, if you are witnessing a stochastic process and not iid random variables, bootstrapping is subtle, have a look at Lectures On Some Aspects Of The Bootstrap by Evarist Giné).
## Answer by demully (score 0)
https://quant.stackexchange.com/a/69149
Column A is the price of asset A
Column B is the price of asset B
C is the return of A
D is the return of B
E is CORREL(OFFSET($D,-t,0,t+1,1),OFFSET($E,-t,0,t+1,1))
F is something cool I want to correlate to my correlation to tell a good story
G is CORREL(OFFSET($E,-t,0,t+1,1),OFFSET($F,-t,0,t+1,1)), ie the correlation of correlation to something real.
Hit F9.
Where "t" is a lookback, visually optimised for the coolest-looking chart. The only constraints being 1d, 1w, 1m, 3m, 6m, 200d=9m etc. because deviations from the classic market demarcations of time would be an obvious "tell" for over-fitting.
Apologies for the lack of appropriate statistical notation. And, yes, I exaggerate a little. But the process above pretty much put my two children through private school.
The real answer to your question being is (a) this is really really simple to do, on a rolling basis in Excel; no notation required. And (b) there is no theoretically or empirically correct way to define the sample you use for the evolving calculation of your rolling over time. Unless you are lucky enough to have some intuitive economic theory why return should be price-dependent. But, generally speaking, this itself is considered a heresy against efficiency in the published world that uses the notation rather than Excel formulae plus F9 ;-)
If you want to get really cute, however, you can do it... Calculate your rolling correlations. And then calculate your autocorrelation of correlation. From which you can derive a half-life of correlation persistence... Except I think we both know this is the statistical equivalent of "hitting F9" ;-)
The honest answer is that 65d (ie 65 trading days in a calendar quarter), 200d (ie 9m, lots of things might be 6-12m so people use 9) or 12m; and 3y tend to serve as market benchmarks for "short-term", "tactical" and "medium-term" for these kinds of analyses. They're just the devil that analysts and clients know here.
hope this helps, DEM
ps the intuitive interpretation of evolving correlations over time is a whole different subject, one for another day I'm afeared. Assuming they are, of course, non-stationary (as are most instances in market data).Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.