# Testing whether the correlation between two time series is constant through time

The Problem:

Given two time series, I want to determine if the (Pearson) correlation between the two time series is constant throughout time.

Example:

For example, I have the following two time series:

Clearly, there is correlation between them. If I calculate the Pearson correlation coefficient I get $$\rho = 0.960$$. However, I want to test whether this correlation coefficient remains the same throughout time. In principle, the correlation of two time series could change through time right?

My current 'solution':

I partition the two time series into sub-time series of equal length. In this case the total length of the time series is $$n \approx 2600$$, so I split each time series into 52 time series of length 50. Then I calculate the Pearson coefficient for each of the 52 pairs. I then plot the coefficients:

Apart from the three earlier points, the correlation looks to be fairly constant. However, this method isn't very mathematical. Is there a more rigorous test that I can do to determine if the correlation remains constant?

• Hi: You're dealing in a very dangerous-subtle area here because the correlation of two time series should only be defined after the series have been filtered so that the residuals are white noise. I can't explain this here ( too long and I wouldn't do it justice anyway ) but I would google for "pre-whitening a time series" or "transfer response" because what you're doing can lead to incorrect inference if not done correctly. If you google for those terms, you will see what I am referring to. Apologies for not providing all the details but it's quite involved. Commented Aug 6, 2020 at 16:29
• This gives some idea of the issue. online.stat.psu.edu/stat510/lesson/9/9.1 Commented Aug 6, 2020 at 16:31