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:

enter image description here

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:

enter image description here

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

  • $\begingroup$ Why do we have to stationarise the series? I thought the cross-correlation function can be directly perform on any 2 time-series data. $\endgroup$ Commented Sep 18, 2017 at 10:20
  • $\begingroup$ 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." $\endgroup$
    – guy
    Commented Oct 27, 2017 at 12:30
  • $\begingroup$ @guy links dead, would you mind elaborating or re-posting? $\endgroup$
    – Frank
    Commented Jun 19, 2019 at 22:52
  • 1
    $\begingroup$ @Frank I believe this was the link as it relates to CCF plots: newonlinecourses.science.psu.edu/stat510/lesson/8/8.2 $\endgroup$
    – guy
    Commented Jun 28, 2019 at 18:11

2 Answers 2


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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