2
$\begingroup$

I want to get the cross-correlation of two time series x and y in R.

I have calculated an ARIMA model, and I can get the mod1$residuals from signal x. These residuals almost have no autocorrelation, so that's great.

xts <- ts(x,start=1,frequency=12) #convert to a time series
library(fpp)  #load forecasting package
mod1 <- auto.arima(xts)

I now did the same procedure on signal y.

My question is: is this correct? Or should I somehow deduct the mod1 (based on x) from y to de-trend it?

ccf(mod1$residuals, mod2$residuals)

Secondly, I am confused about the order of operations. Should I prewhiten the data before calculating the model?

I found this code:

prewhiten(x, y, x.model = ar.res,ylab="CCF", ...)

Should I estimate the mod1 first and then supply it to the function prewhiten? And are x and y the two time series? Many thanks!

$\endgroup$
4
  • $\begingroup$ Related to this. $\endgroup$ Commented Feb 5, 2016 at 7:39
  • $\begingroup$ I don't fully understand the answer you point to. Do I remove the arima model from both time series? And do I remove the same model or make two models? $\endgroup$
    – dorien
    Commented Feb 5, 2016 at 9:54
  • $\begingroup$ I know I did not manage to provide a clarification there; I posted the link so that other users could see the background of the question. $\endgroup$ Commented Feb 5, 2016 at 10:02
  • $\begingroup$ Regarding terminology, you "estimate" rather than "calculate" model mod1 or ARIMA model. It could be nice to have this fixed in both your question and your answer. $\endgroup$ Commented Feb 7, 2016 at 20:04

1 Answer 1

0
$\begingroup$

Prewhitening seems like a good way to help interpret ccf. (see here)

Prewhitening basically estimates a model (such as ARIMA) on data1, then the residuals data2 and this model are used in a ccf function with data1 residuals. In the case of this question:

 print(prewhiten(y, model=mod1))

will display the ccf graph

$\endgroup$
0

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.