# How do I interpret this cross correlation function (CCF) plot?

I am working on some exchange rates data. I have two series:

• $X_t$ with the official exchange rate (e.g. forex)
• $Y_t$ with the exchange rate on the "black market" (e.g. currency exchange houses at airports).

I am interested in modelling the relationship between these two series. It is reasonable to model $Y_t$ as a function of $X_t$ and lagged values of this series (because the black market kinda follows the official market). I would like to get insight on two questions:

• Average lag in the response of the black market (how long does it take for currency exchange houses to react to changes in the official market).
• The magnitude of the reaction (do currency exchange houses overreact?, or they kind of smooth the movements in the official market?)

Here's how the data looks like:

I've read that the "cross correlation function (CCF) is helpful for identifying lags of the $X$-variable that might be useful predictors of $Y_t$". (link)

So I produced such plots for 20, 50 and 150 lags (I have in total 520 obs) with the following code in R .

ccf(x = toy$xa, y = toy$ya, lag.max = 20)
ccf(x = toy$xa, y = toy$ya, lag.max = 50)
ccf(x = toy$xa, y = toy$ya, lag.max = 250)


And here's how they look:

Does it mean that up to 170 lags might be useful predictors?, or am I doing something wrong?

• Why do we have to stationarise the series? I thought the cross-correlation function can be directly perform on any 2 time-series data. Sep 18, 2017 at 10:20
• See onlinecourses.science.psu.edu/stat510/node/74 "... often (perhaps most often) is helpful to de-trend and/or take into account the univariate ARIMA structure of the x-variable before graphing the CCF."
– guy
Oct 27, 2017 at 12:30
• @guy links dead, would you mind elaborating or re-posting? Jun 19, 2019 at 22:52
• @Frank I believe this was the link as it relates to CCF plots: newonlinecourses.science.psu.edu/stat510/lesson/8/8.2
– guy
Jun 28, 2019 at 18:11

## 2 Answers

I won't be able to tell you what exactly this means, but here is an explanation about CCF.

First you want to make sure that the process is stationary. @Hernando Casas's answer helps there. Next note that the formula for cross correlation between $X$ and $Y$ at lag $k$ is

\begin{equation*} \rho_{X,Y}(k) = \dfrac{Cov\left( X_1, Y_{1+k}\right)}{ \sqrt{VarX_1 \, VarY_1}}\,. \end{equation*}

The stationarity is essential so that the variances and covariances can be reduced to only the 1st and $(1+k)th$ variables. At lag $0$, this just tells you the correlation between the two series. At $k$th lag, the cross correlation tells you the correlation between between $X$ and $Y$ at lag $k$. Since $X$ and $Y$ have large correlation at lag $0$, you can expect them to have large crosscorrelation upto larger lags.

Clearly, your data were generated by a non-stationary process. You can try to "stationarize" the series. First differencing is one of the most common (and simple) methods to transform a non-stationary series to a (at least weak) stationary series apt for many statistical methods.